Some flox activate issues

Hi, here is a zsh session using flox activate:

○ echo $PATH
/Users/etorreborre/.local/share/flox/environments/etorreborre/default/bin:/opt/homebrew/bin:...

○ flox environments
etorreborre/default
    Alias     default
    System    x86_64-darwin
    Path      /Users/etorreborre/.local/share/flox/environments/etorreborre/default
    Curr Gen  50 (remote 4)
    Commit    ee67fcf (remote 277089a)

etorreborre/haskell
    Alias     haskell
    System    x86_64-darwin
    Path      /Users/etorreborre/.local/share/flox/environments/etorreborre/haskell
    Curr Gen  1

○ echo $PATH
/Users/etorreborre/.local/share/flox/environments/etorreborre/default/bin:/opt/homebrew/bin:...

○ flox activate -e haskell
[flox]
~
○ echo $PATH
/Users/etorreborre/.local/share/flox/environments/etorreborre/default/bin:/Users/etorreborre/.local/share/flox/environments/etorreborre/default/bin:/opt/homebrew/bin:...
[flox]

○ . <(flox activate -e haskell)
[flox]
~
○ echo $PATH
/Users/etorreborre/.local/share/flox/environments/etorreborre/haskell/bin:/Users/etorreborre/.local/share/flox/environments/etorreborre/default/bin:/Users/etorreborre/.local/share/flox/environments/etorreborre/default/bin:/Users/etorreborre/.local/share/flox/environments/etorreborre/default/bin:/opt/homebrew/bin:...

You can notice 2 things:

  • flox activate ends up doing adding default more than once on the path (not a big deal but maybe worth cleaning up)
  • flox activate -e haskell does not change the PATH to add haskell first but . <(flox activate - haskell) does

I don’t know if that can be fixed so that flox activate -e does the right thing or if the documentation needs to fix (or if it depends on something that’s shell-specific).

Thanks @etorreborre for the bug report. Regarding #1 you’re absolutely correct that flox will activate the same environment multiple times and we’ll be fixing that shortly. As for #2 I’ve not seen that bug before - the latest available for download is 0.0.6-r52 and I’m not able to reproduce the issue with that version.

I’ll keep looking at the code and try to reproduce the issue but in the meantime can you send:

  1. the exact flox version that you used to create that example
  2. the output of flox --debug activate -e haskell
  3. the contents of /Users/etorreborre/.cache/flox/profilemeta/etorreborre/manifest.toml immediately after running the above command

Many thanks!

Here you go:

cat /Users/etorreborre/.cache/flox/profilemeta/etorreborre/manifest.toml
# This is a prototype profile declarative manifest in TOML format,
# supporting comments and the ability to invoke "shellHook" commands
# upon profile activation. See the flox(1) man page for more details.

# [environment]
#   LANG = "en_US.UTF-8"
#   LC_ALL = "$LANG"
#
# [aliases]
#   gg = "git grep"
#
# [hooks]
#   sayhi = """
#     echo "Supercharged by flox!" 1>&2
#   """
#
# Edit below the "--- >8 ---" delimiter to define the list of packages to
# be installed, but note that comments and the ordering of packages will
# *not* be preserved with updates.

# ------------------------ >8 ------------------------

# ------------------------ >8 ------------------------
[packages]
  [packages."cabal2nix"]
  channel = "nixpkgs-flox"
  stability = "stable"


~
○ flox --version
Version: 0.0.6-r49

~
○ flox --debug activate -e haskell
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:135 hash_commands( ansifilter awk basename bash cat chmod cmp column cp curl cut dasel date dirname id jq getent gh git gum grep ln man mkdir mktemp mv nix nix-store parallel pwd readlink realpath rm rmdir sed sh sleep sort stat tail touch tr uuid xargs zgrep )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:154 first_in_PATH( vim vi nano emacs ed )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/bootstrap.sh:65 registry( /Users/etorreborre/.config/flox/floxUserMeta.json 1 get floxClientUUID )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:482 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -n -e -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/registry.jq --arg version 1 --slurpfile registry /Users/etorreborre/.config/flox/floxUserMeta.json --args -- get floxClientUUID )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/bootstrap.sh:67 registry( /Users/etorreborre/.config/flox/floxUserMeta.json 1 get floxClientUUID )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:482 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -n -e -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/registry.jq --arg version 1 --slurpfile registry /Users/etorreborre/.config/flox/floxUserMeta.json --args -- get floxClientUUID )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/bootstrap.sh:70 registry( /Users/etorreborre/.config/flox/floxUserMeta.json 1 get gitBaseURL )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:482 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -n -e -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/registry.jq --arg version 1 --slurpfile registry /Users/etorreborre/.config/flox/floxUserMeta.json --args -- get gitBaseURL )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/bootstrap.sh:74 registry( /Users/etorreborre/.config/flox/floxUserMeta.json 1 get organization )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:482 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -n -e -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/registry.jq --arg version 1 --slurpfile registry /Users/etorreborre/.config/flox/floxUserMeta.json --args -- get organization )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/bootstrap.sh:78 registry( /Users/etorreborre/.config/flox/floxUserMeta.json 1 get defaultFlake )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:482 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -n -e -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/registry.jq --arg version 1 --slurpfile registry /Users/etorreborre/.config/flox/floxUserMeta.json --args -- get defaultFlake )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/bootstrap.sh:88 registry( /Users/etorreborre/.config/flox/floxUserMeta.json 1 set defaultFlake github:flox/floxpkgs/master )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:468 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -n -e -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/registry.jq --arg version 1 --slurpfile registry /Users/etorreborre/.config/flox/floxUserMeta.json --args -- set defaultFlake github:flox/floxpkgs/master )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/bootstrap.sh:96 registry( /Users/etorreborre/.config/flox/floxUserMeta.json 1 get defaultSubstituter )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:482 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -n -e -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/registry.jq --arg version 1 --slurpfile registry /Users/etorreborre/.config/flox/floxUserMeta.json --args -- get defaultSubstituter )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/bootstrap.sh:107 registry( /Users/etorreborre/.config/flox/floxUserMeta.json 1 get floxMetricsConsent )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:482 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -n -e -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/registry.jq --arg version 1 --slurpfile registry /Users/etorreborre/.config/flox/floxUserMeta.json --args -- get floxMetricsConsent )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:887 registry( /Users/etorreborre/.config/flox/floxUserMeta.json 1 set channels flox github:flox/floxpkgs/master )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:468 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -n -e -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/registry.jq --arg version 1 --slurpfile registry /Users/etorreborre/.config/flox/floxUserMeta.json --args -- set channels flox github:flox/floxpkgs/master )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:888 registry( /Users/etorreborre/.config/flox/floxUserMeta.json 1 set channels nixpkgs github:flox/nixpkgs/stable )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:468 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -n -e -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/registry.jq --arg version 1 --slurpfile registry /Users/etorreborre/.config/flox/floxUserMeta.json --args -- set channels nixpkgs github:flox/nixpkgs/stable )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:889 registry( /Users/etorreborre/.config/flox/floxUserMeta.json 1 set channels nixpkgs-flox github:flox/nixpkgs-flox/master )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:468 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -n -e -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/registry.jq --arg version 1 --slurpfile registry /Users/etorreborre/.config/flox/floxUserMeta.json --args -- set channels nixpkgs-flox github:flox/nixpkgs-flox/master )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:898 registry( /Users/etorreborre/.config/flox/floxUserMeta.json 1 get channels )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:482 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -n -e -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/registry.jq --arg version 1 --slurpfile registry /Users/etorreborre/.config/flox/floxUserMeta.json --args -- get channels )
trace:/dev/fd/63:1 invoke( /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/nix registry add --registry /Users/etorreborre/.config/flox/tmp.fwippPr809 etorreborre github:etorreborre/floxpkgs/main )
trace:/dev/fd/63:2 invoke( /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/nix registry add --registry /Users/etorreborre/.config/flox/tmp.fwippPr809 flox github:flox/floxpkgs/master )
trace:/dev/fd/63:3 invoke( /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/nix registry add --registry /Users/etorreborre/.config/flox/tmp.fwippPr809 nixpkgs github:flox/nixpkgs/stable )
trace:/dev/fd/63:4 invoke( /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/nix registry add --registry /Users/etorreborre/.config/flox/tmp.fwippPr809 nixpkgs-flox github:flox/nixpkgs-flox/master )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:903 invoke( /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/nix registry add --registry /Users/etorreborre/.config/flox/tmp.fwippPr809 nixpkgs-stable github:flox/nixpkgs/stable )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:904 invoke( /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/nix registry add --registry /Users/etorreborre/.config/flox/tmp.fwippPr809 nixpkgs-staging github:flox/nixpkgs/staging )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:905 invoke( /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/nix registry add --registry /Users/etorreborre/.config/flox/tmp.fwippPr809 nixpkgs-unstable github:flox/nixpkgs/unstable )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/flox:124 submitMetric( activate )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/flox:139 profileArg( haskell )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/flox:161 profileGen( /Users/etorreborre/.local/share/flox/environments/etorreborre/haskell )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/flox:180 profileArg( default )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/flox:184 removePathDups( _flox_path_prepend )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/flox:226 manifestTOML( /Users/etorreborre/.cache/flox/profilemeta/etorreborre/manifest.toml bashInit )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:344 invoke( /nix/store/v0m53hajvqyl4dklc0v63dizq5b2jl9x-dasel-1.26.1/bin/dasel -f /Users/etorreborre/.cache/flox/profilemeta/etorreborre/manifest.toml -r toml -w json )
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/utils.sh:344 invoke( /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/manifestTOML.jq -s --arg system x86_64-darwin --argjson verbose 1 --arg profileOwner etorreborre --arg profileName haskell --arg FLOX_PATH_PREPEND /Users/etorreborre/.local/share/flox/environments/etorreborre/haskell/bin:/Users/etorreborre/.local/share/flox/environments/etorreborre/default/bin --args -- bashInit )
+ /nix/store/qlqdagcza6n8xwndzz0wkhgai1bhzq4x-jq-1.6-bin/bin/jq -r -f /nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/lib/manifestTOML.jq -s --arg system x86_64-darwin --argjson verbose 1 --arg profileOwner etorreborre --arg profileName haskell --arg FLOX_PATH_PREPEND /Users/etorreborre/.local/share/flox/environments/etorreborre/haskell/bin:/Users/etorreborre/.local/share/flox/environments/etorreborre/default/bin --args -- bashInit
trace:/nix/store/vhawj9dbnvlqj5b2dw3masyq603ay7ym-flox-prerelease-0.0.6-r49/libexec/flox/flox:668 invoke( /bin/zsh )
+ /bin/zsh
[flox]

I tried the updated installer but unfortunately I got an error with no additional explanation (on mac/intel)

Did you originally use the installer to install Nix & flox or did you install flox on top of an existing installation of Nix? If the former then can you please send me the recent lines from /var/log/install.log by email or Discord? We’ll get the upgrade working before returning back to the flox activate issue. Thanks as ever for your patience!

Progress - I’ve been able to reproduce the problem. Currently contemplating the correct way to fix it but hope to get something out for you by the end of the day. As an added bonus the bugfixed version will add these additional features:

  • doesn’t warn about missing environment when activating default
  • makes flox activate verbose with -v flag
  • avoids leaking FLOX_PATH_PREPEND variable to subshells
  • adds activated environments to PS1 prompt in subshells
  • throws an error when attempting to activate the same environment twice
  • in verbose mode is more verbose about setting of ZDOTDIR for zsh
1 Like

Alas I didn’t quite get it to you yesterday but I’ve now got a new version I think you’ll find works much better. It’s available for installation from the flox channel with the command flox install flox.flox-prerelease, or if you’ve installed this package before (I think you have) then flox upgrade flox.flox-prerelease will upgrade it to the latest version:

[flox] λ flox upgrade flox.flox-prerelease
upgrading 'evalCatalog.x86_64-linux.stable.flox-prerelease' from flake 'github:flox/floxpkgs/31debf7003dbf261548fb2adfb53e1f364b1d78a' to 'github:flox/floxpkgs/bc9047d4e629f21270010d8b03de8b84ef19487a'
this derivation will be built:
  /nix/store/w4551d4xa2gg7nl1ykqiyhfmaypavr5b-flox-prerelease-0.0.6-r54.drv
building '/nix/store/w4551d4xa2gg7nl1ykqiyhfmaypavr5b-flox-prerelease-0.0.6-r54.drv'...
[flox] λ flox --version
Version: 0.0.6-r54
[flox] λ 

Also, my apologies for providing the wrong upgrade instructions earlier; I forgot that you had moved over to the flox-prerelease package installation. When installing flox over an existing Nix installation you have to install flox to a profile or run it in a nix-shell, after which you can install and maintain flox with flox. :slight_smile:

I am trying to upgrade but now, when I start a shell, I don’t even have a flox version to start with (possibly that’s the result of the failed mac installer execution?).

You wrote that I need to install flox to a profile. I tried to follow the nix instructions on “Install flox” but flox is still not available when I start a shell session. What should I do?

Making sure there was no nix-daemon in the background and re-running the mac installer eventually did it for me. Back on track!

1 Like

excellent. Please let us know if you run across any issues with r54. Michael plans to release it later this week and announce it in our new “announcements” discourse category :slight_smile:

1 Like