Skip to content

Conversation

@icezyclon
Copy link

@icezyclon icezyclon commented Jun 15, 2025

This is a draft PR regarding #254

Added the following changes:

  • export _VF_EXTRA_PATH which we can use to know if virtualfish was the one to set this or not (just VIRTUAL_ENV would be ambiguous)
  • on active: prepend _VF_EXTRA_PATH to fish_user_paths (which will automatically update PATH) (note: use -g here to NOT set it as universal variables, because -x does not actually do anything in this case)
  • on deactivate: clear BOTH fish_user_paths and PATH (_VF_EXTRA_PATH may be part of only PATH if we are in a sub-shell because fish_user_paths is restored at fish startup) and delete _VF_EXTRA_PATH
  • on virtual.fish load: if we are in a virtual environment, set by virtualfish AND _VF_EXTRA_PATH does not appear in fish_user_paths, then we just loaded into a sub-shell and must re-order _VF_EXTRA_PATH to the front of fish_user_paths (and out of regular PATH)
  • added a lot of debug output to make testing and reasoning easier
  • I tried changing as little as possible otherwise

Use cases I have tried:

  • activating and deactivating an environment
  • spawning sub-shells with activated and deactivated environment
  • reloading virtual.fish by sourcing it again (is guarded against by the not contains -- "$_VF_EXTRA_PATH" $fish_user_paths)

I added a lot of debug output to make it easy to test, for actually merging this would of course be removed!

…f virtual.fish if required (contains debug output)
@icezyclon
Copy link
Author

icezyclon commented Jun 15, 2025

I just realized, we could also not use fish_user_paths at all, keeping the normal PATH, but still move the _VF_EXTRA_PATH to the front (because fish_add_paths did not end up working as expected anyway).
Just as a possible option I wanted to add

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.

1 participant