Skip to content

Switching directories doesn't change go version #294

@Integralist

Description

@Integralist

👋🏻

I use https://www.warp.dev/ with a Zsh shell and a https://starship.rs/ prompt (I also use Zoxide for switching directories but the reported issue happens even with standard cd).

I'm finding that when I switch between project directories (where each project has its own .go-version file and are set with different Go versions), that changing directory doesn't trigger the go binary to be the expected version.

Here is my ~/.zshrc configuration:

if [ ! -d "$HOME/.goenv" ]; then
  git clone https://github.com/syndbg/goenv.git ~/.goenv
fi
export GOENV_ROOT="$HOME/.goenv"
export PATH="$GOENV_ROOT/bin:$PATH"
eval "$(goenv init -)"
export PATH="$GOROOT/bin:$PATH"
export PATH="$PATH:$GOPATH/bin"

At the time of reporting this issue, I'm using the latest release:

$ goenv --version
goenv 2.0.6

If I open up a new terminal instance at my home directory ~/ and run which go I see:

/Users/integralist/.goenv/versions/1.20.0/bin/go

This aligns with goenv global.

Now if I cd into a project directory with a .go-version file containing 1.20.2 and re-run go version I'll still see the global Go 1.20.0 being used. If I reload my shell scripts (e.g. source ~/.zshrc) then running both which go and go version will now report the expected 1.20.2 version.

Now if I cd into another project with a .go-version file containing 1.18.5 and re-run go version I'll still see the previous Go version 1.20.2 being used. If I reload my shell scripts (e.g. source ~/.zshrc) then running both which go and go version will now report the expected 1.18.5 version.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions