kerolloz / go-installer

Go-Installer: Effortless Golang Installation with One Command! 🚀
MIT License
142 stars 16 forks source link

.bashrc fills with exports #16

Closed berkersal closed 9 months ago

berkersal commented 9 months ago

If the installation script from https://git.io/go-installer is run multiple times. Exports are keep appending to .bashrc. This is the result after 2 installations

export GOROOT=/home/tango/.go
export GOPATH=/home/tango/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
export GOROOT=/home/tango/.go
export GOPATH=/home/tango/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

I am using ansible-playbook to install if it makes any difference:

- name: Install GO
  shell: curl -sL https://git.io/go-installer | bash -
kerolloz commented 9 months ago

Hello @berkersal Thank you for reporting this issue. I believe this issue has been already fixed in a previous version of go-installer. I'm not sure how ansible-playbook is handling the installation. I'm also wondering how you caused that issue. For example, did you try running the script twice without using ansible-playbook? because the script should not install Go if it's already installed and hence will not keep appending the exports. Also if you're upgrading your Go version, the script is responsible for removing the installed Go version first and clearing the exports and then installing the new version of Go and finally adding the exports again at the end, which means you'll end up with exports only once (no repetition). Please let me know how I can help you further.

berkersal commented 9 months ago

Okay, I've found a solution. Wrapping the command as below fixes my problem. I think it is because how ansible handles the shell. Hope it will be helpful to people in the future.

  - name: Install GO
    shell: bash -ilc "curl -sL https://git.io/go-installer | bash -"