devbox icon indicating copy to clipboard operation
devbox copied to clipboard

Devbox: Reopen in Devbox shell environment fails for VS Code on MacOS

Open BeyondEvil opened this issue 1 year ago • 7 comments

What happened?

Running the Devbox: Reopen in Devbox shell environment palette-command fails with an error.

Screenshot 2024-09-24 at 23 00 40 Screenshot 2024-09-24 at 23 00 58

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

  1. Install the Devbox VS Code extension.
  2. Run the palette-command Devbox: Reopen in Devbox shell environment
  3. 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

BeyondEvil avatar Sep 24 '24 21:09 BeyondEvil

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.

mohsenari avatar Sep 27 '24 21:09 mohsenari

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 avatar Sep 28 '24 00:09 BeyondEvil

@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.

rafales avatar Oct 25 '24 12:10 rafales

I think it's more likely related to #2297

BeyondEvil avatar Oct 25 '24 14:10 BeyondEvil

It's also failing in WSL2. It simply closes VS Code and never reopen

nahharris avatar Nov 30 '24 16:11 nahharris

same issue here

mskonovalov avatar Jan 07 '25 21:01 mskonovalov

Any updates?

kkhnifes avatar May 16 '25 12:05 kkhnifes