Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 26, 2025

When starting tmux from a vfox-activated shell, environment variables like GOPATH were not updated because tmux inherits __VFOX_PID from the parent shell, causing vfox to skip re-initialization despite running in a different process.

Changes

  • bash/zsh hooks: Check PID match instead of just existence
    • Old: if [[ -z "$__VFOX_PID" || -z "$__VFOX_SHELL" ]]
    • New: if [[ -z "$__VFOX_PID" || "$__VFOX_PID" != "$$" || "$__VFOX_SHELL" != "bash|zsh" ]]

This ensures re-initialization when:

  • PID differs (tmux, new shell sessions)
  • Shell type changes (switching between bash/zsh)
  • First activation (variables unset)

Note: Fish shell unchanged - uses process-event-based hooks that don't exhibit this issue.

Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG]: vfox golang env GOPATH in tmux not working</issue_title>
<issue_description>Version
The version you are currently using
OS
macOS、Linux

Describe the bug
GOPATH in tmux not working

Screenshots[optional]

echo $GOROOT;echo $GOPATH
/home/vb/.version-fox/temp/1724860800-47300/golang
/home/vb/.version-fox/temp/1724860800-47300/golang/packages
❯ tmux
❯ echo $GOROOT;echo $GOPATH
/home/vb/.version-fox/temp/1724860800-47300/golang
/home/vb/go

Then I try to source ~/.zshrc
But it still doesn't work

source ~/.zshrc
❯ echo $GOROOT;echo $GOPATH
/home/vb/.version-fox/temp/1724860800-47300/golang
/home/vb/go
❯ vfox activate zsh

if [[ -z "$__VFOX_PID" ]]; then
  export GOROOT=$'/home/vb/.version-fox/temp/1724860800-47300/golang';export GOPATH=$'/home/vb/.version-fox/temp/1724860800-47300/golang/packages';export __VFOX_SHELL=$'zsh';export PATH=$'/home/vb/.version-fox/temp/1724860800-47300/golang/bin:/home/vb/.version-fox/temp/1724860800-47300/golang/packages/bin:/home/vb/.local/share/zinit/polaris/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/home/vb/go/bin';export __VFOX_CURTMPPATH=$'/home/vb/.version-fox/temp/1724860800-47300';

  export __VFOX_PID=$$;

  _vfox_hook() {
    trap -- '' SIGINT;
    eval "$("/usr/local/bin/vfox" env -s zsh)";
    trap - SIGINT;
  }
  typeset -ag precmd_functions;
  if [[ -z "${precmd_functions[(r)_vfox_hook]+1}" ]]; then
    precmd_functions=( _vfox_hook ${precmd_functions[@]} )
  fi
  typeset -ag chpwd_functions;
  if [[ -z "${chpwd_functions[(r)_vfox_hook]+1}" ]]; then
    chpwd_functions=( _vfox_hook ${chpwd_functions[@]} )
  fi

  trap 'vfox env --cleanup' EXIT
fieval "$(vfox activate zsh)"

vb@debian ~echo $GOROOT;echo $GOPATH
/home/vb/.version-fox/temp/1724860800-47300/golang
/home/vb/go

</issue_description>

Comments on the Issue (you are @copilot in this section)

@jan-bar Create a new terminal and immediately execute: `env | grep __VFOX`. Let me see if it is consistent with the problem I encountered

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Dec 26, 2025
Copilot AI changed the title [WIP] Fix GOPATH not working in tmux session Fix environment variables not updating in tmux sessions Dec 26, 2025
Copilot AI requested a review from bytemain December 26, 2025 08:52
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

Successfully merging this pull request may close these issues.

[BUG]: vfox golang env GOPATH in tmux not working

2 participants