udhos / update-golang

update-golang is a script to easily fetch and install new Golang releases with minimum system intrusion
MIT License
1.86k stars 227 forks source link

Source profile upon creation #33

Closed jaredbrogan closed 2 years ago

jaredbrogan commented 2 years ago

After executing sudo ./update-golang.sh (when performing a clean install), I expect to immediately be able to run go commands from anywhere. However, since the profile modifications aren't sourced after being created or updated, the user will have to either do it themselves manually or re-login to their session to access it globally.

Suggested changes: Add source "$abs_profiled" after line #320

udhos commented 2 years ago

Problem is, the script usually is run as root sudo ./update-golang.sh. Sourcing the profile in the sudo context will not affect the user shell when sudo exits.

Maybe, another approach is to leave a message to user that one might need to source the profile in order to get immediate effect?

jaredbrogan commented 2 years ago

Very good point! I do think your suggestion of outputting a message to the user to source it upon completion. You might want to consider putting it at the end of the script output, separating the message with a newline at the start, otherwise users may not see it as easily.

udhos commented 2 years ago

I have added this https://github.com/udhos/update-golang/commit/20a10826721e76d6db24d05282b65fac2e94661f:

update-golang.sh: 
update-golang.sh: HINT: If this is the first time you run this script, the env vars
update-golang.sh:       updated in the profile will only take effect for new shells.
update-golang.sh:       If you want them to affect the current shell, use this:
update-golang.sh: 
update-golang.sh:       source /etc/profile.d/golang_path.sh
update-golang.sh: 

Does it help?

jaredbrogan commented 2 years ago

Yep, looks good!