# Regression with flox 1.0.5

**URL:** <https://discourse.flox.dev/t/regression-with-flox-1-0-5/899>\
**Category:** Bug Reports\
**Created:** [May 15, 2024, 7:31am UTC](https://discourse.flox.dev/t/regression-with-flox-1-0-5/899 "2024-05-15T07:31:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![etorreborre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/etorreborre/32/428_2.png) [@etorreborre](https://discourse.flox.dev/u/etorreborre)\
**Post date:** [May 15, 2024, 7:31am UTC](https://discourse.flox.dev/t/regression-with-flox-1-0-5/899/1 "2024-05-15T07:31:39Z")

</div>

Hi, there seems to be a regression with flox `1.0.5`.

I am now seeing this message again:

```auto
/Users/etorreborre/.cache/flox/run/etorreborre/default.d62f59a1/activate/bash:13: command not found: shopt
/nix/store/0bscac2mkvbgr21nvj63r0hgwqfwmy17-set-prompt.bash.sh:16: command not found: shopt

```

This is when I enter a directory with `direnv` and my configuration is

```auto
eval "$(flox activate -d $FLOX/my_env)"

```

Then I get a direnv message:

```auto
direnv: ([/Users/etorreborre/.cache/flox/run/etorreborre/default.d62f59a1/bin/direnv export zsh]) is taking a while to execute. Use CTRL-C to give up.

```

---

<div class="post-metadata">

**Author:** ![ghudgins](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/ghudgins/32/588_2.png) [@ghudgins](https://discourse.flox.dev/u/ghudgins)\
**Post date:** [May 15, 2024, 3:16pm UTC](https://discourse.flox.dev/t/regression-with-flox-1-0-5/899/2 "2024-05-15T15:16:11Z")

</div>

We’re looking into it! we made a number of activate changes in this release. will get back to you shortly

---

<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:** [May 15, 2024, 11:00pm UTC](https://discourse.flox.dev/t/regression-with-flox-1-0-5/899/3 "2024-05-15T23:00:34Z")

</div>

With 1.05 we changed the order of `hook.on-activate` and `profile` scripts such that the hooks are always run first now (and always in Bash). This allows you to `eval` in your hook and it should just work in most cases.

Could you share your manifest so I could take a look and do some debugging?

---

<div class="post-metadata">

**Author:** ![etorreborre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/etorreborre/32/428_2.png) [@etorreborre](https://discourse.flox.dev/u/etorreborre)\
**Post date:** [May 16, 2024, 7:29am UTC](https://discourse.flox.dev/t/regression-with-flox-1-0-5/899/4 "2024-05-16T07:29:44Z")

</div>

Thanks for helping. I sent the result of `flox -vv activate` and my manifest file to Michael via the Slack workspace.

---

<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:** [May 16, 2024, 5:25pm UTC](https://discourse.flox.dev/t/regression-with-flox-1-0-5/899/5 "2024-05-16T17:25:08Z")

</div>

Thanks again Eric for sending those traces offline. We’ll get back to you ASAP with a workaround. 👍

---

<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:** [May 17, 2024, 9:12pm UTC](https://discourse.flox.dev/t/regression-with-flox-1-0-5/899/6 "2024-05-17T21:12:56Z")

</div>

Thanks again Eric for your patience. As a workaround, please try:

```auto
eval "$(FLOX_SHELL=bash flox activate -d $FLOX/my_env)"

```

The reason for the problem is because [`direnv` always parses the contents of `.envrc` in a (non-interactive) `bash` sub-shell](https://direnv.net/#how-it-works), irrespective of the shell that you are using. (This is similar to the way that the flox `on-activate` hook is always processed using `bash`, for much the same reasons.) The `FLOX_SHELL` environment variable provides a way to override the `flox` shell detection logic in the meantime, but I’ll also update the code to always switch into `bash` mode when we detect `direnv` as the parent process of the `flox` invocation.

Thanks again for the bug report!

---

<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:** [May 24, 2024, 2:28pm UTC](https://discourse.flox.dev/t/regression-with-flox-1-0-5/899/7 "2024-05-24T14:28:51Z")

</div>

Hi Eric, I think I know what’s going on.

Your use of direnv is taking place within an existing flox activation, and it is that outermost `flox activate` invocation that is a) correctly detecting your shell as `/bin/zsh` and b) _leaking_ the `FLOX_SHELL=/bin/zsh` environment variable into your subsequent environment. As a result, when you use `direnv` it invokes flox with `FLOX_SHELL` defined and pointing to zsh, which then causes flox to emit zsh syntax when `direnv` invokes flox from the `.envrc` (using bash).

The fix for this should be to stop leaking `FLOX_SHELL` into the environment - I’ll draw up a PR for that ASAP.

Here’s a reproducer that illustrates the behavior:

```sh
flox [limeytexan/default (remote)] brantley@Michaels-MacBook-Pro ~ % echo $FLOX_SHELL

flox [limeytexan/default (remote)] brantley@Michaels-MacBook-Pro ~ % cd direnvtest
direnv: loading ~/direnvtest/.envrc
direnv: export +DYLD_FALLBACK_LIBRARY_PATH ~ACLOCAL_PATH ~CPATH ~FLOX_ENV ~FLOX_ENV_CACHE ~FLOX_ENV_DESCRIPTION ~FLOX_ENV_DIRS ~FLOX_ENV_DIRS_activate ~FLOX_ENV_LIB_DIRS ~FLOX_ENV_LIB_DIRS_activate ~FLOX_ENV_PROJECT ~FLOX_PROMPT_ENVIRONMENTS ~FLOX_PROMPT_ENVIRONMENTS_activate ~INFOPATH ~LIBRARY_PATH ~MANPATH ~PATH ~PKG_CONFIG_PATH ~XDG_DATA_DIRS ~_FLOX_ACTIVE_ENVIRONMENTS ~_add_env ~_del_env
flox [limeytexan/default (remote)] brantley@Michaels-MacBook-Pro direnvtest % cd ..
direnv: unloading
flox [limeytexan/default (remote)] brantley@Michaels-MacBook-Pro ~ % export FLOX_SHELL=$SHELL
flox [limeytexan/default (remote)] brantley@Michaels-MacBook-Pro ~ % echo $FLOX_SHELL        
/bin/zsh
flox [limeytexan/default (remote)] brantley@Michaels-MacBook-Pro ~ % cd direnvtest
direnv: loading ~/direnvtest/.envrc
/private/tmp/direnvtest/.flox/run/aarch64-darwin.direnvtest/activate.d/zsh:36: unexpected token `(', conditional binary operator expected
direnv: export +_flox_activate_tracelevel -FLOX_ORIG_ZDOTDIR ~FLOX_ENV ~FLOX_ENV_CACHE ~FLOX_ENV_DESCRIPTION ~FLOX_ENV_DIRS ~FLOX_ENV_LIB_DIRS ~FLOX_ENV_PROJECT ~FLOX_PROMPT_ENVIRONMENTS ~FLOX_ZSH_INIT_SCRIPT ~_FLOX_ACTIVE_ENVIRONMENTS ~_add_env ~_del_env
flox [limeytexan/default (remote)] brantley@Michaels-MacBook-Pro direnvtest % 

```

Will let you know once we release a patch for this.

---

<div class="post-metadata">

**Author:** ![etorreborre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/etorreborre/32/428_2.png) [@etorreborre](https://discourse.flox.dev/u/etorreborre)\
**Post date:** [May 25, 2024, 10:49am UTC](https://discourse.flox.dev/t/regression-with-flox-1-0-5/899/8 "2024-05-25T10:49:45Z")

</div>

Great investigation, thanks Michael.

---

<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:** [May 25, 2024, 11:13am UTC](https://discourse.flox.dev/t/regression-with-flox-1-0-5/899/9 "2024-05-25T11:13:36Z")

</div>

And … the fix for this was merged with [fix: do not leak FLOX\_SHELL into subsequent activations by limeytexan · Pull Request #1493 · flox/flox · GitHub](https://github.com/flox/flox/pull/1493) which should be included with v1.0.6. So if you can just `unset FLOX_SHELL` when you see this bug in the span between now and then then you shouldn’t ever have to think about it again! 🙂

Thanks again for all the great feedback!
