On Mac ASDF shims path still has precedence

This issue has been tracked since 2022-12-23.

Hello, this is not high prio, I was just testing devbox to see if it fits my workflow. It seem ASDF is causing troubles in the paths...

Before entering shell

$ echo $PATH
/Users/roman/.asdf/shims /Users/roman/.asdf/bin /opt/homebrew/bin /opt/homebrew/sbin /Users/roman/.nix-profile/bin /nix/var/nix/profiles/default/bin /opt/homebrew/opt/bison/bin /opt/homebrew/opt/flex/bin /Users/roman/.yarn/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/Apple/usr/bin /Library/Frameworks/EdgeDB.framework/bin /Applications/Wireshark.app/Contents/MacOS /Users/roman/.deno/bin /Users/roman/bin/yt-dlp_macos /Applications/calibre.app/Contents/MacOS /Users/roman/.pub-cache/bin /Users/roman/.asdf/installs/flutter/3.0.0-stable/.pub-cache/bin /Users/roman/.asdf/installs/golang/1.18.1/packages/bin

after entering shell

$ echo $PATH
/Users/roman/.asdf/shims /Users/roman/.asdf/bin /opt/homebrew/bin /opt/homebrew/sbin /opt/homebrew/opt/bison/bin /opt/homebrew/opt/flex/bin /Users/roman/.yarn/bin /nix/store/kvrd49dfkadaw6iik004pdyrjrvy9fm7-bash-interactive-5.1-p16/bin /nix/store/ns32408gw33gfjvkgnrfbv2h3l0vnzd6-python3-3.10.8/bin /nix/store/2wsfz0sp2w0z28b2pz76218s52rkwwaj-elixir-1.14.2/bin /nix/store/49wn01k9yikhjlxc1ym5b6civ29zz3gv-bash-5.1-p16/bin /nix/store/lqiqj6s5jx196bpx0mr53d232b57y768-clang-wrapper-11.1.0/bin /nix/store/kn8ahinf4kbh9zwnw44a0hhps6ia1swy-clang-11.1.0/bin /nix/store/v8y9sd43ygc27x4808asaymbk5nn4ild-coreutils-9.1/bin /nix/store/33yb640sh8ac5ky9ak7fjnrb3mw559q1-cctools-binutils-darwin-wrapper-973.0.1/bin /nix/store/x0b1kda81p0w0qqp7abvsprcf7s7qp64-cctools-binutils-darwin-973.0.1/bin /nix/store/v8y9sd43ygc27x4808asaymbk5nn4ild-coreutils-9.1/bin /nix/store/kcg2s3q8fqslprb4567v4zmd9l7jxclb-findutils-4.9.0/bin /nix/store/v9rpags3ciy01rxpslxpq0qcvaxy2gf6-diffutils-3.8/bin /nix/store/v6ihvpa7b1mj58sbimfqyrg205mrd7xv-gnused-4.8/bin /nix/store/nran2s5ihfjmpvhf832dqz3msr73hbhc-gnugrep-3.7/bin /nix/store/bxcw00s9cn6amc77g7jsciiyidmd74ip-gawk-5.1.1/bin /nix/store/l7rgxzafcscmnd7j1cc3rzz5iia7b91a-gnutar-1.34/bin /nix/store/ahzz1clw7sf1lxa83m4n4zfisx4ahxp9-gzip-1.12/bin /nix/store/hldrf5kdydn658lgr07iv6sajbnbpza0-bzip2-1.0.8-bin/bin /nix/store/j5lfwqj55ssxk02jhmi9hf0wib1ig4la-gnumake-4.3/bin /nix/store/49wn01k9yikhjlxc1ym5b6civ29zz3gv-bash-5.1-p16/bin /nix/store/4qqdkpdzkj3y3vsjjs3f170xy5rdjjwh-patch-2.7.6/bin /nix/store/502ln1c4zr5r0xr457jf4igrc36i1scm-xz-5.2.7-bin/bin /nix/store/0fvf2dkgw2clm0zgj0g6arr4mm3l9h3k-file-5.43/bin /opt/homebrew/bin /opt/homebrew/sbin /nix/var/nix/profiles/default/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/Apple/usr/bin /Library/Frameworks/EdgeDB.framework/bin /Applications/Wireshark.app/Contents/MacOS /Users/roman/.deno/bin /Users/roman/bin/yt-dlp_macos /Applications/calibre.app/Contents/MacOS /Users/roman/.pub-cache/bin /Users/roman/.asdf/installs/flutter/3.0.0-stable/.pub-cache/bin /Users/roman/.asdf/installs/golang/1.18.1/packages/bin /Users/roman/.deno/bin /Users/roman/bin/yt-dlp_macos /Applications/calibre.app/Contents/MacOS /Users/roman/.pub-cache/bin /Users/roman/.asdf/installs/flutter/3.0.0-stable/.pub-cache/bin /Users/roman/.asdf/installs/golang/1.18.1/packages/bin

I am using Fish shell.

$ fish --version
fish, version 3.5.1
$ devbox version
$ nix --version
nix (Nix) 2.11.1

Wish you good holidays and merry Christmas! 🌟

Lagoja wrote this answer on 2022-12-23

Hey @mindreframer, hope you're having a great holiday as well!

I think this may relate to a known issue where a few shells (including Fish) fail to correctly configure the PATH and init_hooks when running devbox shell. We're working on a few fixes:

  1. For Fish, we are investigating a way to add support by setting the path + hooks in Bash, and then starting Fish. This should allow Fish to inherit the environment from Bash.

  2. For other non-supported shells, we will default to Bash when starting devbox shell

I'll make sure to test with asdf after we implement these fixes to verify that it works

mindreframer wrote this answer on 2022-12-23

Hey @Lagoja !

Thanks for the super-quick response and the proposed plan sounds solid! Will be waiting for the fixes. 👍

ipince wrote this answer on 2023-01-13

Hi @mindreframer

Is there a specific problem that you're seeing with the given paths, or something that you expected to work differently?

My understanding is that this is working as expected. What's happening is the following:

  • devbox prepends all the nix paths to your original $PATH
  • devbox starts a new shell for you (in this case fish)
  • fish will source whatever is in your ~/.config/fish/config.fish file, which seems to be manipulating the PATH and prepending (and post-pending) more stuff

This results in (1) seeing pre-pended stuff in the front, and (2) seeing repeated paths, from the last run of your init file (config.fish), and from what was in your original $PATH.

Now, your particular case is somewhat weird, because some paths are duplicated and some aren't (the asdf ones in front). I suspect that the logic in config.fish that adds those paths is smart enough to not repeat them if they already exist in PATH, but rather just bring them to the front. That's just a guess though; it's hard to tell what's going on without seeing what's in config.fish.

Anyway, all of this results in an ugly-looking path, but ultimately everything defined your devbox.json should be in path, and you should also have access to other things from your machine to make developing easy, which is the way devbox shell is intended to work. Please let me know if I'm misunderstanding or missing something.

derekr wrote this answer on 2023-02-03

I think I'm having a similar issue using fish. Specifically testing out postgresql and the initdb command prefers my original homebrew installation of postgresql.

devbox init
devbox add postgresql
devbox shell
initdb: error: The program "postgres" is needed by initdb but was not found in the
same directory as "/opt/homebrew/Cellar/libpq/14.5/bin/initdb".
Check your installation.
  "packages": [
  "shell": {
    "init_hook": null
  "nixpkgs": {
    "commit": "f80ac848e3d6f0c12c52758c0f25c10c97ca3b62"

regular shell

/Users/drk/.turso /Users/drk/Downloads/google-cloud-sdk 3/bin /Users/drk/Library/pnpm /Users/drk/.nix-profile/bin /nix/var/nix/profiles/default/bin /Users/drk/go/bin /Users/drk/Library/Caches/fnm_multishells/37016_1675466726029/bin /opt/homebrew/opt/openjdk/bin /Users/drk/.local/bin /Users/drk/.cargo/bin /opt/homebrew/opt/[email protected]/bin /opt/homebrew/opt/libpq/bin /opt/homebrew/bin /usr/local/bin /System/Cryptexes/App/usr/bin /usr/bin /bin /usr/sbin /sbin /Library/Apple/usr/bin /usr/local/go/bin /Users/drk/.deno/bin

devbox shell

/Users/drk/.turso /Users/drk/Library/pnpm /Users/drk/go/bin /Users/drk/Library/Caches/fnm_multishells/40548_1675467213183/bin /opt/homebrew/opt/openjdk/bin /Users/drk/.local/bin /Users/drk/.cargo/bin /opt/homebrew/opt/[email protected]/bin /opt/homebrew/opt/libpq/bin /opt/homebrew/bin /nix/store/yigicnz7r2znh1fq2l184svkb3h4v90g-bash-interactive-5.1-p16/bin /nix/store/y2dfv0jf61pgwgkc9rfq7kjabshpwqra-postgresql-14.6/bin /nix/store/bwscr98440mhhlg556fqhp5ll2fxnfic-clang-wrapper-11.1.0/bin /nix/store/ssfpjhrysqf6ywz5sqi8gpz28zc23kiy-clang-11.1.0/bin /nix/store/gvl9w6c5q83nd4svz5v5hqhgfzlcpl3y-coreutils-9.1/bin /nix/store/xh503dqb1yb5w9mjziclp81gi4cqmwf6-cctools-binutils-darwin-wrapper-973.0.1/bin /nix/store/a17dwfwqj5ry734zfv3k1f5n37s4wxns-cctools-binutils-darwin-973.0.1/bin /nix/store/gvl9w6c5q83nd4svz5v5hqhgfzlcpl3y-coreutils-9.1/bin /nix/store/x080znwmkginz9xb1qchm5dd188m59hg-findutils-4.9.0/bin /nix/store/pnp0lkyjhrhl7vj0fgrpx80zzzmnkqi6-diffutils-3.8/bin /nix/store/vjnvxrpi26aigy96fvcfwjx5y5j18h7r-gnused-4.9/bin /nix/store/8j799mid9ai29hg4s4xifx3yn1x1qply-gnugrep-3.7/bin /nix/store/40sbwcrzl80vrlz9wwdml69b6y224kbs-gawk-5.2.1/bin /nix/store/wmybxxsdc4h640xgzijmqi1yic3fvs6x-gnutar-1.34/bin /nix/store/3x74r0m2833bqr7krjf4q8q2wpb5l3v7-gzip-1.12/bin /nix/store/8wdl82qvvd6hkq361vq8cmi110g3pbvg-bzip2-1.0.8-bin/bin /nix/store/6lkc7zwfkr21si1g85mq39mmlpf6mn35-gnumake-4.4/bin /nix/store/n0k8njvgg6yjapkl81rm821s9vx0qrwb-bash-5.2-p15/bin /nix/store/m5dhzr6yzq199ahyiv3xqpiy4japhr9f-patch-2.7.6/bin /nix/store/dd4776lwwki6dxrjn2cli3sc9mwmdxp5-xz-5.4.0-bin/bin /nix/store/4zhg5g546pa5gprszifqz1lx9vg8h8nv-file-5.43/bin /Users/drk/.turso /Users/drk/Downloads/google-cloud-sdk 3/bin /Users/drk/Library/pnpm /nix/var/nix/profiles/default/bin /Users/drk/go/bin /Users/drk/Library/Caches/fnm_multishells/37016_1675466726029/bin /usr/local/bin /System/Cryptexes/App/usr/bin /usr/bin /bin /usr/sbin /sbin /Library/Apple/usr/bin /usr/local/go/bin /Users/drk/.deno/bin /Users/drk/.deno/bin
amok wrote this answer on 2023-02-22

Hi, @mindreframer
I was also having a similar issue with nix+fish, so far I managed to fix it with a dirty hack, by adding the following into my config.fish

# When `nix shell` / `nix develop` is called then asdf or ~/.nix-profile binaries
# takes precedence over the "nix-shell" binaries. This function fixes the order of
# the PATH variable so that the "nix-shell" binaries are first in the PATH.
function fix_nix_paths_order
    set -l non_nix_paths ''
    set -l nix_user_paths ''
    set -l nix_shell_paths ''

    for path in (echo $PATH | string split ' ')
        if string match -q "/nix/store/*" $path
            set -p nix_shell_paths $path
        else if string match -q "*/.nix-profile/bin" $path
            set -p nix_user_paths $path
            set -p non_nix_paths $path

    set -l non_nix_paths (string trim "$non_nix_paths")
    set -l nix_user_paths (string trim "$nix_user_paths")
    set -l nix_shell_paths (string trim "$nix_shell_paths")

    for p in (echo "$non_nix_paths $nix_user_paths $nix_shell_paths" | string split ' ')
        set -l path (string trim $p)
        if test -n "$path"
            fish_add_path -m $path

ipince wrote this answer on 2023-02-22

Thanks for the workaround @amok !

Btw, I have a PR out (#669) that should fix this issue.

mindreframer wrote this answer on 2023-02-24

@mindreframer thanks, this looks interesting! I will let the dust settle on this, since for now I manage my local setup the old fashioned way. ;)

derekr wrote this answer on 2023-02-24

Working for me w/ new version! Thank you :D

ipince wrote this answer on 2023-02-24

Great, thanks for confirming!

More Details About Repo
Owner Name jetpack-io
Repo Name devbox
Full Name jetpack-io/devbox
Language Go
Created Date 2022-08-18
Updated Date 2023-03-31
Star Count 4960
Watcher Count 19
Fork Count 68
Issue Count 42


Issue Title Created Date Updated Date