# Setopt command not found

**URL:** <https://discourse.flox.dev/t/setopt-command-not-found/837>\
**Category:** Help\
**Created:** [March 14, 2024, 8:35am UTC](https://discourse.flox.dev/t/setopt-command-not-found/837 "2024-03-14T08:35:29Z")\
**Posts on this page:** 11\
**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:** [March 14, 2024, 8:35am UTC](https://discourse.flox.dev/t/setopt-command-not-found/837/1 "2024-03-14T08:35:29Z")

</div>

Hi there,

I am having an issue after upgrading to 1.0.1. I edited one of my environments and when it activates again I get this message:

```auto
/Users/etorreborre/.cache/flox/run/etorreborre/ockam.9c6cb2142223c368f7ae284619de6e8b0bc0a8dcbf47ddf7949aa687ee698051/activate/zsh:13: setopt: command not found
/Users/etorreborre/.cache/flox/run/etorreborre/ockam.9c6cb2142223c368f7ae284619de6e8b0bc0a8dcbf47ddf7949aa687ee698051/activate/zsh:14: setopt: command not found

```

What can I do to fix this?

Thanks.

---

<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:** [March 14, 2024, 9:02am UTC](https://discourse.flox.dev/t/setopt-command-not-found/837/2 "2024-03-14T09:02:03Z")

</div>

One more thing. I tried to reinstall flox-0.9.0 but 1.0.1 is still there:

```auto
❯ ll /usr/local/bin/flox                                                                                                                                                                                                                                                                                                                                                                              
lrwxr-xr-x - root 14 Mar 09:59 /usr/local/bin/flox -> /nix/store/lvc5ckmxqmb01v4jdi5z4vj06667yabc-flox-0.9.0/bin/flox*

❯ /nix/store/lvc5ckmxqmb01v4jdi5z4vj06667yabc-flox-0.9.0/bin/flox --version                                                                                                                                                                                                                                                                                                                           
Version: 1.0.1

```

---

<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:** [March 14, 2024, 11:53am UTC](https://discourse.flox.dev/t/setopt-command-not-found/837/3 "2024-03-14T11:53:43Z")

</div>

> [@etorreborre](#):
>
> ` setopt: command not found`

we’ll look at it right away. we implemented `setopt` to handle a situation where newly installed packages weren’t getting into environments and this seems to be an unintended side effect. track this for updates, will try to follow-up here if we get a resolution and timing! [activation does not work when setopts is not available · Issue #1174 · flox/flox · GitHub](https://github.com/flox/flox/issues/1174)

---

<div class="post-metadata">

**Author:** ![ysndr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/ysndr/32/340_2.png) [@ysndr](https://discourse.flox.dev/u/ysndr)\
**Post date:** [March 14, 2024, 12:07pm UTC](https://discourse.flox.dev/t/setopt-command-not-found/837/4 "2024-03-14T12:07:32Z")

</div>

Hi Eric!

In the past command path hashing has prevented users from seeing newly installed software within their Flox environment (i.e. the shell had a system `python` command path cached and did not pick up a floc installed version).

`setopt` is used to prevent zsh from hashing commands for the duration of a Flox environment apparently it’s the zsh alternative to `set +h` in bash.

> <https://github.com/flox/flox/blob/main/pkgdb/src/buildenv/realise.cc#L109-L112>

Since `setopt` is a builtin in zsh, we wouldn’t expect this to ever be a concern unless the scripts are executed in the wrong shell (i.e. bash) for some reason.

Could you post your value of `$SHELL` and (presuming that you use zsh, `zsh --version`)?

---

<div class="post-metadata">

**Author:** ![ysndr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/ysndr/32/340_2.png) [@ysndr](https://discourse.flox.dev/u/ysndr)\
**Post date:** [March 14, 2024, 12:11pm UTC](https://discourse.flox.dev/t/setopt-command-not-found/837/5 "2024-03-14T12:11:08Z")

</div>

> [@etorreborre](#):
>
> One more thing. I tried to reinstall flox-0.9.0 but 1.0.1 is still there:

Do you have `$FLOX_VERSION` set to anything?  
Previous versions would export `FLOX_VERSION` to activated shells, if you were to activate an environment within one activated by an older flox version you might still have a conflicting version set.

---

<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:** [March 14, 2024, 1:18pm UTC](https://discourse.flox.dev/t/setopt-command-not-found/837/6 "2024-03-14T13:18:41Z")

</div>

Hi Yannik,

My `SHELL` variable is set to `/bin/zsh` and `zsh --version` returns `zsh 5.9 (x86_64-apple-darwin23.0)`. I also don’t have any `FLOX_VERSION` variable set.

---

<div class="post-metadata">

**Author:** ![ysndr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/ysndr/32/340_2.png) [@ysndr](https://discourse.flox.dev/u/ysndr)\
**Post date:** [March 14, 2024, 5:27pm UTC](https://discourse.flox.dev/t/setopt-command-not-found/837/7 "2024-03-14T17:27:17Z")

</div>

Is there a chance that the activation with `setopt: command not found` was ran in a bash subshell?  
For some background I only get to reproduce this when running `SHELL=zsh bash -c 'eval "$(flox activate)"'` because flox respects currently expects $SHELL to be the same as the executing shell (our plan is to improve that, but it would be good to confirm that your issue is indeed related to that).

---

<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:** [March 14, 2024, 6:02pm UTC](https://discourse.flox.dev/t/setopt-command-not-found/837/8 "2024-03-14T18:02:51Z")

</div>

The activation happens via my `.envrc` file which contains something like:

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

```

---

<div class="post-metadata">

**Author:** ![ysndr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/ysndr/32/340_2.png) [@ysndr](https://discourse.flox.dev/u/ysndr)\
**Post date:** [March 14, 2024, 6:11pm UTC](https://discourse.flox.dev/t/setopt-command-not-found/837/9 "2024-03-14T18:11:53Z")

</div>

ah, I’'d need to check but i think direnv executes .envrc in bash _always_, thus the iscrepancy between `SHELL` and parent shell.  
Thanks that is helpful.  
For a workaround you can edit your .envrc to

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

```

---

<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:** [March 14, 2024, 6:16pm UTC](https://discourse.flox.dev/t/setopt-command-not-found/837/10 "2024-03-14T18:16:54Z")

</div>

> [@ysndr](#):
>
> `FLOX_SHELL=bash`

I confirm that this works fine, thanks!

---

<div class="post-metadata">

**Author:** ![ysndr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.flox.dev/ysndr/32/340_2.png) [@ysndr](https://discourse.flox.dev/u/ysndr)\
**Post date:** [March 14, 2024, 6:50pm UTC](https://discourse.flox.dev/t/setopt-command-not-found/837/11 "2024-03-14T18:50:29Z")

</div>

FYI, the fix is being tracked here:

> <https://github.com/flox/flox/pull/1176>
>
> We currently rely on \`$SHELL\` for our detection of the executing shell.
> However…, sub shells do not reliably reset this variable.
> When \`flox activate --print-script\` is \`eval\`'ed in a sub shell
> \-- e.g. a direnv issued bash -- an incompatible script may produced.
> 
> SHELL=zsh bash -c 'eval "$(flox activate --print-script)"'
> .../activate/zsh:13: setopt: command not found
> .../activate/zsh:14: setopt: command not found
> 
> This PR implements detection of the parent shell by determining
> and inspecting the exe path of the parent process.
> If determining the parent process fails,o r the process is an unsupported shell,
> we fall back to the existing \`$SHELL\` detection.
> 
> Both methods are overridden by an explicit \`FLOX\_SHELL\` variable.
