Closed mindreframer closed 1 year ago
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:
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.
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
Hey @Lagoja !
Thanks for the super-quick response and the proposed plan sounds solid! Will be waiting for the fixes. 👍
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:
$PATH
fish
)~/.config/fish/config.fish
file, which seems to be manipulating the PATH and prepending (and post-pending) more stuffThis 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.
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
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": [
"postgresql"
],
"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/openssl@3/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/openssl@3/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
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
else
set -p non_nix_paths $path
end
end
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
end
end
end
fix_nix_paths_order
Thanks for the workaround @amok !
Btw, I have a PR out (#669) that should fix this issue.
@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. ;)
Working for me w/ new version! Thank you :D
Great, thanks for confirming!
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
after entering shell
I am using Fish shell.
Wish you good holidays and merry Christmas! 🌟