Nix installed to WSL2 doesn't source `.profile`

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

When Devbox detects a user doesn't have Nix installed, it will offer to install it for the user. If a user allows this action, then terminates their shell and opens a new one, the Nix binary is still unavailable. Nix's install script adds its path to .profile but no shell startup scripts are run when VS Code Remote is started in WSL:

As a result, the auto shell feature of the VS Code Devbox extension also doesn't work giving Error: We found a /nix directory but nix binary is not in your PATH. Try restarting your terminal and running devbox again. If after restarting you still get this message it's possible nix setup is missing from your shell rc file. See for more details.

Workaround is to manually source a user's .profile first. This is not with Fish 🙂 it's my work machine running Windows 11 and a brand new WSL2 distro launched otherwise untouched (shell is bash) apart from installing Devbox with the curl method and adding its VS Code extension.

Lagoja wrote this answer on 2022-12-26

Thanks for reporting! Just to check how the environment loading works -- does Devbox work correctly if the correct lines are added to your [bash|zsh|*sh]rc file?

Lagoja wrote this answer on 2023-01-09

@worldofgeese we've dug into this and a few related problems -- we think the best option is for Devbox to call and use the nix binaries directly, instead of expecting to find them in $PATH. We have some work on this and we're expecting it for the 0.2.1 milestone. Will update once it's finished!

Lagoja wrote this answer on 2023-01-13

Tested and validated this improvement with 0.2.1, which we just released today! This version no longer relies on $PATH to locate the nix binaries, so it should work much better on WSL. Please let me know if this fixes the issue!

mikeland86 wrote this answer on 2023-01-13

@Lagoja safe to close?

worldofgeese wrote this answer on 2023-01-22

Apologies for the long delay, I confirm this is now fixed in my WSL2 distro of choice 🎊

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