g
                                
                                
                                
                                    g copied to clipboard
                            
                            
                            
                        provide a flag to override dotfile_for_shell
Hi @stefanmaric thanks for this version manager.
Is it possible to provide a flag to the installer to specify the dotfile for shell.
I'm using the installer in an ansible role (https://galaxy.ansible.com/damianoneill/smg). Ansible uses a non-login shell over ssh, therefore for bash this will always select ~/.bashrc where ideally I want to update the dotfile for the login shell i.e. ~/.bash_profile.
Therefore if you could provide a way for me to overload the get_dotfile_for_shell response that would be fantastic.
Alternatively, if you have another suggestion that would be great.
Thanks, Damian.
Hi @damianoneill,
Since g is intended for interactive user sessions where one would change go versions from time to time while working on different projects, I have to ask: in your target environment are you supposed to switch go versions?
Because if not, I would instead install go at the system level without g-install.
The way I'm using this is that I have a playbook for managing hosts, a subset, the hosts used by developers have a role that copies a playbook to the individual hosts that each individual developer runs. This playbook installs a set of version managers; nvm, pyenv, sdkman, etc and some other user home specific stuff.
My expectation is as you said that g would be used in an interactive login shell, the problem is that when the developers run their playbook, ansible itself uses ssh in a non-login shell, see here https://stackoverflow.com/a/35989041 for an overview.
Thanks Stefan.
@damianoneill interesting use case. The thing is that g-install doesn't really check if the shell is login or non-login (it wouldn't actually know, since the recommended way to install it is piping the script from curl/wget to sh), g-install assumes non-login (except for bash in macos) since g is an userspace tool.
I think I can add a flag to force the setup upon login profile files. But first I have to consider the implications.
I might give it a look during the weekend. In the meantime, maybe you can patch the .bash_profile yourself after g-install has finished.
source ~/.bashrc
printf '\n%s %s %s %s' \
  "export GOPATH=\"$(printf '%s' "$GOPATH" | sed "s|${HOME}|\$HOME|g")\";" \
  "export GOROOT=\"$(printf '%s' "$GOROOT" | sed "s|${HOME}|\$HOME|g")\";" \
  "export PATH=\"\$GOPATH/bin:\$PATH\";" \
  "# g-install: do NOT edit, see https://github.com/stefanmaric/g" >> ~/.bash_profile
Edited to fix typos in example script.
Thanks Stefan, appreciate that.
Won't be going forward with this request for the time being. If anyone is still interested, feel free to keep the thread going.