Context: @z-mitchell.bsky.social on Bluesky
iTerm zsh from ~
antti@harju ~ % flox --version
1.3.8
antti@harju ~ % echo $FLOX_ENV
/Users/antti/.flox/run/aarch64-darwin.default.run
antti@harju ~ % which git
/Users/antti/.flox/run/aarch64-darwin.default.run/bin/git
antti@harju ~ % echo $PATH
/Users/antti/.flox/run/aarch64-darwin.default.run/bin:/Users/antti/.flox/run/aarch64-darwin.default.run/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Applications/iTerm.app/Contents/Resources/utilities
antti@harju ~ % code tmp
VS Code integrated terminal (also zsh)
antti@harju tmp % flox --version
1.3.8
antti@harju tmp % echo $FLOX_ENV
/Users/antti/.flox/run/aarch64-darwin.default.run
antti@harju tmp % which git
/usr/bin/git
antti@harju tmp % echo $PATH
/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/antti/.flox/run/aarch64-darwin.default.run/bin:/Users/antti/.flox/run/aarch64-darwin.default.run/sbin:/Applications/iTerm.app/Contents/Resources/utilities:/Users/antti/Library/Application Support/Code/User/globalStorage/github.copilot-chat/debugCommand
antti@harju tmp % cat ~/.zshrc
eval "$(flox activate -m run -d ~)"
antti@harju tmp % cat ~/.zprofile
eval "$(flox activate -m run -d ~)"
antti@harju tmp % flox activate -d ~
â ERROR: Environment 'default' is already active
Happens the same way on two different macs.
Goal is to replace homebrew with flox.
Iâm expecting default env to be on or off, now it seems to be in a halfway mode where itâs active but executing git doesnât call the one installed by flox. In other words I canât activate the environment or use the git installed in it
zsh/flox config should be as instructed under initial setup here The default environment - Flox Docs
It looks like VS Code does a couple of weird things to your shell when using the integrated terminal. Could you try disabling these settings one at a time?
I tried disabling the following settings
"terminal.integrated.enablePersistentSessions": false,
"terminal.integrated.persistentSessionReviveProcess": "never",
"terminal.integrated.inheritEnv": false,
"terminal.integrated.shellIntegration.enabled": false,
"terminal.integrated.shellIntegration.showCommandGuide": false,
"terminal.integrated.allowChords": false,
"terminal.integrated.detectLocale": "off",
"terminal.integrated.suggest.quickSuggestions": false,
"terminal.integrated.suggest.suggestOnTriggerCharacters": false,
"terminal.integrated.shellIntegration.decorationsEnabled": "never",
"terminal.integrated.initialHint": false
And the issue persists. Are you able to reproduce?
I tried Googling the issue again and found conda - PATH variable in Visual Studio Code different from Terminal on Mac - Stack Overflow which points to Where PATHs come from â Scripting OS X
which explains
Imagine you are pre- pending ~/bin
to your PATH
because you want to override some standard tools with your own. (Dangerous, but letâs assume you know what you are doing.) Then some process launches a subshell which can call path_helper
again. path_helper
will âfindâ your additions to the defined PATH
, but it will append to the list of default paths from /etc/paths
and /etc/paths.d
, changing your order and thus which tools will be used.
A better way to override built-in commands which is not affected by path_helper
would be to use bash
aliases or functions in your profile.
I hope the above is relevant or helpful, Iâm out of my depth here.
Hi @anttiharju,
Apologies for the extended [holiday] delay getting back to you, and many thanks for the bug report! Weâve seen a few PATH-related issues with 1.3.8 and have been working on a fix in PR2552.
Would it be possible for you to try again with the following flox
version, created from the above PR? There are a few ways to do this, but I suspect the easiest/quickest would be to run the following commands:
nix copy --extra-experimental-features nix-command --from https://cache.flox.dev /nix/store/b1ci4l9j3wdw0pca24xpz9mwaspsfzy4-flox-1.3.8
sudo mv /usr/local/bin/flox /usr/local/bin/flox.orig
sudo ln -s /nix/store/b1ci4l9j3wdw0pca24xpz9mwaspsfzy4-flox-1.3.8/bin/flox /usr/local/bin/flox
Important: following the above youâll need to make a trivial (whitespace in hook or package addition/removal) change to your default environment with flox edit -d ~
and then fully log out of all shells and VScode sessions before trying again. This should get you using the correct version of git
from within VScode - please let us know!
And if for whatever reason you encounter problems with this new version you can of course back it out with sudo mv -f /usr/local/bin/flox.orig /usr/local/bin/flox
.
Again, many thanks for the feedback and for using Flox!
Hi Michael,
No worries! Was busy myself too
Unfortunately the first nix command doesnât work for me
nix copy --extra-experimental-features nix-command --from https://cache.flox.dev /nix/store/b1ci4l9j3wdw0pca24xpz9mwaspsfzy4-flox-1.3.8
warning: error: unable to download 'https://cache.flox.dev/nix-cache-info': SSL connect error (35); retrying in 289 ms
warning: error: unable to download 'https://cache.flox.dev/nix-cache-info': SSL connect error (35); retrying in 607 ms
warning: error: unable to download 'https://cache.flox.dev/nix-cache-info': SSL connect error (35); retrying in 1002 ms
warning: error: unable to download 'https://cache.flox.dev/nix-cache-info': SSL connect error (35); retrying in 2081 ms
error: unable to download 'https://cache.flox.dev/nix-cache-info': SSL connect error (35)
Noticed that 1.3.9 was released, the issue appears to be resolved
nice work
1 Like
Ah ⌠yes that old chestnut! A number of nix
commands wonât work unless in the presence of certain environment variables, and our solution is to have you run those commands from within a flox environment where those variables are defined. So I should have advised you to flox activate
(any env would work) prior to invoking nix
- will remember for next time!
And thank you for confirming the fix worked as included in v1.3.9! I was meaning to circle back and let you know that it would be easiest to just upgrade and try the new version.
Again, many thanks for the feedback!
1 Like