Skip to content
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

provide a flag to override dotfile_for_shell #19

Closed
damianoneill opened this issue Jan 14, 2021 · 6 comments
Closed

provide a flag to override dotfile_for_shell #19

damianoneill opened this issue Jan 14, 2021 · 6 comments

Comments

@damianoneill
Copy link

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.

@stefanmaric
Copy link
Owner

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.

@damianoneill
Copy link
Author

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.

@stefanmaric
Copy link
Owner

@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.

@stefanmaric
Copy link
Owner

stefanmaric commented Jan 14, 2021

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.

@damianoneill
Copy link
Author

Thanks Stefan, appreciate that.

stefanmaric added a commit that referenced this issue Mar 19, 2021
- Improve switching Go versions performance to nearly instant (#19, thanks @jimeh)
- Add support for darwin-arm64 (M1 chips) (#20, thanks @joelanford)
- Tweak docs, guidelines, and configs to make it easier to contribute
- Format all documents with Prettier for consistency
- Add Github template for BUG reports
- Update screencast with more recent version of g
@stefanmaric
Copy link
Owner

Won't be going forward with this request for the time being. If anyone is still interested, feel free to keep the thread going.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants