# Git installed with flox gets replaced with default one in VS Code integrated terminal if launched from default env with code

**URL:** <https://discourse.flox.dev/t/git-installed-with-flox-gets-replaced-with-default-one-in-vs-code-integrated-terminal-if-launched-from-default-env-with-code/1010>\
**Category:** Bug Reports\
**Created:** [December 17, 2024, 6:49pm UTC](https://discourse.flox.dev/t/git-installed-with-flox-gets-replaced-with-default-one-in-vs-code-integrated-terminal-if-launched-from-default-env-with-code/1010 "2024-12-17T18:49:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anttiharju](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/anttiharju/32/718_2.png) [@anttiharju](https://discourse.flox.dev/u/anttiharju)\
**Post date:** [December 17, 2024, 6:49pm UTC](https://discourse.flox.dev/t/git-installed-with-flox-gets-replaced-with-default-one-in-vs-code-integrated-terminal-if-launched-from-default-env-with-code/1010/1 "2024-12-17T18:49:33Z")

</div>

Context: [@z-mitchell.bsky.social on Bluesky](https://bsky.app/profile/z-mitchell.bsky.social/post/3ldjbz52hkk2n)

iTerm zsh from ~

```auto
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)

```auto
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](https://flox.dev/docs/tutorials/default-environment/#initial-setup)

---

<div class="post-metadata">

**Author:** ![zmitchell](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/zmitchell/32/639_2.png) [@zmitchell](https://discourse.flox.dev/u/zmitchell)\
**Post date:** [December 18, 2024, 3:01pm UTC](https://discourse.flox.dev/t/git-installed-with-flox-gets-replaced-with-default-one-in-vs-code-integrated-terminal-if-launched-from-default-env-with-code/1010/2 "2024-12-18T15:01:54Z")

</div>

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?

> **[Terminal Shell Integration in Visual Studio Code](https://code.visualstudio.com/docs/terminal/shell-integration)**
>
> Visual Studio Code's embedded terminal can integrate with some shells to enhance the capabilities of the terminal.

 ![IMG_1837](https://canada1.discourse-cdn.com/flex036/uploads/floxdev/original/1X/2e24e5f6c9aaabd05c62584419d2b9a679c6f8d3.png)

---

<div class="post-metadata">

**Author:** ![anttiharju](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/anttiharju/32/718_2.png) [@anttiharju](https://discourse.flox.dev/u/anttiharju)\
**Post date:** [December 18, 2024, 6:52pm UTC](https://discourse.flox.dev/t/git-installed-with-flox-gets-replaced-with-default-one-in-vs-code-integrated-terminal-if-launched-from-default-env-with-code/1010/3 "2024-12-18T18:52:03Z")

</div>

I tried disabling the following settings

```auto
	"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](https://stackoverflow.com/questions/67129028/path-variable-in-visual-studio-code-different-from-terminal-on-mac) which points to [Where PATHs come from – Scripting OS X](https://scriptingosx.com/2017/05/where-paths-come-from/)

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.

---

<div class="post-metadata">

**Author:** ![brantley](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/brantley/32/602_2.png) [@brantley](https://discourse.flox.dev/u/brantley)\
**Post date:** [January 2, 2025, 2:11pm UTC](https://discourse.flox.dev/t/git-installed-with-flox-gets-replaced-with-default-one-in-vs-code-integrated-terminal-if-launched-from-default-env-with-code/1010/4 "2025-01-02T14:11:50Z")

</div>

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](https://github.com/flox/flox/pull/2552).

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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![anttiharju](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/anttiharju/32/718_2.png) [@anttiharju](https://discourse.flox.dev/u/anttiharju)\
**Post date:** [January 7, 2025, 7:21pm UTC](https://discourse.flox.dev/t/git-installed-with-flox-gets-replaced-with-default-one-in-vs-code-integrated-terminal-if-launched-from-default-env-with-code/1010/5 "2025-01-07T19:21:11Z")

</div>

Hi Michael,

No worries! Was busy myself too

Unfortunately the first nix command doesn’t work for me

```auto
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)

```

---

<div class="post-metadata">

**Author:** ![anttiharju](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/anttiharju/32/718_2.png) [@anttiharju](https://discourse.flox.dev/u/anttiharju)\
**Post date:** [January 8, 2025, 6:46pm UTC](https://discourse.flox.dev/t/git-installed-with-flox-gets-replaced-with-default-one-in-vs-code-integrated-terminal-if-launched-from-default-env-with-code/1010/6 "2025-01-08T18:46:44Z")

</div>

Noticed that 1.3.9 was released, the issue appears to be resolved

nice work 🙂

---

<div class="post-metadata">

**Author:** ![brantley](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/brantley/32/602_2.png) [@brantley](https://discourse.flox.dev/u/brantley)\
**Post date:** [January 8, 2025, 9:28pm UTC](https://discourse.flox.dev/t/git-installed-with-flox-gets-replaced-with-default-one-in-vs-code-integrated-terminal-if-launched-from-default-env-with-code/1010/7 "2025-01-08T21:28:40Z")

</div>

> [@anttiharju](#):
>
> Unfortunately the first nix command doesn’t work for me
> 
> ```auto
> 
> ```

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!
