Devbox: Reopen in Devbox shell environment fails for VS Code on MacOS
What happened?
Running the Devbox: Reopen in Devbox shell environment palette-command fails with an error.
VS Code log says:
2024-09-24 22:00:26.034 [error] undefined devbox.reopen {"value":"jetpack-io.devbox","_lower":"jetpack-io.devbox"}
The devbox extension debug mode logs says:
[Tue, 24 Sep 2024 21:08:46 GMT] Installing devbox packages [Tue, 24 Sep 2024 21:08:46 GMT] Updating VSCode configurations [Tue, 24 Sep 2024 21:08:46 GMT] Calling "devbox integrate" to setup environment [Tue, 24 Sep 2024 21:08:46 UTC] Devbox process initiated. Setting up communication channel with VSCode process [Tue, 24 Sep 2024 21:08:46 UTC] Computing devbox environment [Tue, 24 Sep 2024 21:08:46 GMT] child process closed with exit code: 0
VS Code version:
Version: 1.93.1 Commit: 38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40 Date: 2024-09-11T17:20:05.685Z Electron: 30.4.0 ElectronBuildId: 10073054 Chromium: 124.0.6367.243 Node.js: 20.15.1 V8: 12.4.254.20-electron.0 OS: Darwin arm64 23.6.0
Note: VS Code is installed via homebrew:
❯ whence code
/opt/homebrew/bin/code
Steps to reproduce
- Install the Devbox VS Code extension.
- Run the palette-command
Devbox: Reopen in Devbox shell environment - Observe error
Apologies for the lack of information, but I'm happy to follow other troubleshooting suggestions.
Command
shell
devbox.json
{
"$schema": "https://raw.githubusercontent.com/jetify-com/devbox/0.13.0/.schema/devbox.schema.json",
"packages": ["dotnet-sdk_8@latest"],
"shell": {
"init_hook": [
"echo 'Welcome to devbox!' > /dev/null"
],
"scripts": {
"test": [
"echo \"Error: no test specified\" && exit 1"
]
}
}
}
Devbox version
0.13.0
Nix version
nix (Nix) 2.18.1
What system does this bug occur on?
macOS (Apple Silicon)
Debug logs
No response
Hey @BeyondEvil thanks for reporting this. From the logs it seems like VSCode sets up the communication with devbox process successfully and devbox process computes the environment. What fails is the reopening of the VSCode window.
For that, can you make sure that code is in your $PATH and also in a VSCode window run the palette command (cmd + shift + p) install code in command PATH ? See if that resolves the issue.
Another suggestion is to run devbox shell in VSCode's integrated terminal and see if it succeeds. If not, that might be the cause.
Essentially, after we compute the devbox environment, the devbox process runs code <path to your working directory> to open VSCode in the newly computed environment. But seems like in your case that step fails.
As far as I can tell, code is in the path:
Cosafe-backend on develop [!?] via 🐳 desktop-linux
❯ devbox shell
Info: New devbox available: 0.13.0 -> v0.13.1. Please run `devbox version update`.
Starting a devbox shell...
ZDOTDIR from .zshrc: /var/folders/jc/xz2fbyhn087d19yt4bcdhfvw0000gn/T/devbox3005844820
whence code:
/opt/homebrew/bin/code
done
ZDOTDIR from init_hook: /Users/jimbrannlund/.config/zsh
/opt/homebrew/bin/code
(devbox)
Cosafe-backend on develop [!?] via 🐳 desktop-linux via ❄️ impure (nix-shell-env)
But I'm wondering if this is linked with this issue: https://github.com/jetify-com/devbox/issues/2297
Also, restarting VS Code doesn't enter the devbox shell.
@BeyondEvil not sure why, but it's starship's fault. I've seen it timing out for a bit with nodejs when switching to a new devbox shell. So it's probably that. Disabling starship setup fixes the problem.
I think it's more likely related to #2297
It's also failing in WSL2. It simply closes VS Code and never reopen
same issue here
Any updates?