Skip to content

doc/install: mention how to update environment variables before testing the installation #24756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aa153 opened this issue Apr 7, 2018 · 11 comments
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge help wanted
Milestone

Comments

@aa153
Copy link

aa153 commented Apr 7, 2018

go1.10.1 linux/amd64
debian 9
installing go
editing $HOME/.profile doesn't help but $HOME/.bashrc does.

There is a paragraph
"Add /usr/local/go/bin to the PATH environment variable. You can do this by adding this line to your /etc/profile (for a system-wide installation) or $HOME/.profile"
under "Install the Go tools" header.
It would be nice to append "... or $HOME/.bashrc" there.
https://golang.org/doc/install

@mvdan
Copy link
Member

mvdan commented Apr 7, 2018

How so? Putting environments in .profile or .bash_profile is better than .bashrc, as it gets executed only once per login instead of on every interactive shell. And the environment variable will also be available even when there isn't an interactive shell involved.

@mvdan
Copy link
Member

mvdan commented Apr 7, 2018

If this is about you having modified .profile but not seeing its effect, it's because you need to log out and log back into your user session. Perhaps that should be explicitly mentioned in the install guide.

@bcmills
Copy link
Contributor

bcmills commented Apr 8, 2018

If your .profile is idempotent, you don't even need to log out: you can just source it again in the current shell. (But I agree that we should mention that in the doc.)

@bcmills bcmills changed the title Little fix to Getting Started page on golang.org doc/install: mention how to update environment variables before testing the installation Apr 8, 2018
@bcmills bcmills added the Documentation Issues describing a change to documentation. label Apr 8, 2018
@bcmills bcmills added this to the Unreleased milestone Apr 8, 2018
@aa153
Copy link
Author

aa153 commented Apr 8, 2018

I've found solution here: https://wiki.debian.org/EnvironmentVariables

Graphical logins do not read a shell's startup files (/etc/profile and ~/.profile and so on) by default, but you as a user may choose to create a ~/.xsessionrc file which does this.

So i created ~/.xsessionrc and added

if [ -f ~/.profile ]; then
. ~/.profile
fi

And it works after logout and login again. Should I remove this issue from list as my mistake?

@agnivade
Copy link
Contributor

agnivade commented Apr 8, 2018

It would still be good to mention the bit about logging out and in (or sourcing the file again). Would you like to send a PR ?

Since you encountered it first hand, you can probably write in a manner suited for people who can stumble into this issue again.

@aa153
Copy link
Author

aa153 commented Apr 8, 2018

Probably someone more experienced can do it. Text to append on page (for Linux section):

For logging in with graphical display manager you should create or edit file ~/.xsessionrc and put there:

if [ -f ~/.profile ]; then
. ~/.profile
fi

Then log out and log in again.

@mvdan
Copy link
Member

mvdan commented Apr 8, 2018

I think the advice should be more generic, or link to a page on the internet covering common issues with shell profile files. Otherwise, this advice is only going to apply to certain Linux systems that use X11, potentially further confusing users that don't have that setup.

@aa153
Copy link
Author

aa153 commented Apr 8, 2018

Agree. I think it would be better someone Linux seasoned and with fluent english write this text because I'm new to Linux.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/105557 mentions this issue: doc: add a note about loading profile files

@ghost
Copy link

ghost commented Apr 8, 2018

Debian based distros now have /etc/profile.d.

bootstrapping go

The above is written for go-1.9.2 using gcc-4.7.1 , and I cited therein V. Batts' .SlackBuild, which obviously in 2018 has been updated.

Linux, Mac OS X, and FreeBSD tarballs

Using the path for the go executable from the above section, V. Batts $GOROOT_FINAL in the below would be /usr/local/go.

# Put the profile scripts for setting PATH and env variables
mkdir -p $PKG/etc/profile.d
cat > $PKG/etc/profile.d/go.csh << EOF
#!/bin/csh
setenv GOROOT ${GOROOT_FINAL}
setenv PATH \${GOROOT}/bin:\${PATH}
EOF
cat > $PKG/etc/profile.d/go.sh << EOF
#!/bin/sh
export GOROOT="${GOROOT_FINAL}"
export PATH="\${GOROOT}/bin:\${PATH}"
EOF

chmod 0755 $PKG/etc/profile.d/go.csh
chmod 0755 $PKG/etc/profile.d/go.sh

Such an executable shell script can also be sourced.

#!/bin/sh
export GOROOT=/usr/local/go
export PATH=${GOROOT}/bin:${PATH}

@ghost
Copy link

ghost commented Apr 8, 2018

https://github.com/golang/go/wiki/SettingGOPATH

Perhaps the idea for the use of a shell's rc file came from the above Wiki Page.

@golang golang locked and limited conversation to collaborators Apr 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge help wanted
Projects
None yet
Development

No branches or pull requests

5 participants