devbox icon indicating copy to clipboard operation
devbox copied to clipboard

[Bug]: Mac OS vscode Devbox: `Reopen in Devbox shell environment` doesn't work

Open tateexon opened this issue 2 years ago • 14 comments

Current Behavior (bug) I install vscode devbox plugin and then the go plugin. Then in a shell I do this to init devbox:

% cd /path/to/go/project
% devbox version
0.7.1
% devbox init
% devbox add [email protected]
Info: Adding package "[email protected]" to devbox.json
Installing package: [email protected].
[1/1] [email protected]
[1/1] [email protected]: Success
% code ./

vscode opens in the project. I then press Command+Shift+P to open the command palette and choose Devbox: Reopen in Devbox shell environment. This results in a popup with the text:

Command 'Devbox: Reopen in Devbox shell environment' resulted in an error
An unknown error occurred. Please consult the log for more details.

I click ok since that is the only options to close the dialogue and in the bottom right corner of vscode I get an error:

Failed to setup devbox environment.
Source: devbox by jetpack.io (Extension)

I am uncertain where to find the logs for this extension. If you can point me where to look I will gladly provide them. There are no issues showing up in the PROBLEMS or OUTPUT tabs in vscode.

Expected Behavior (fix) I would expect the reopen in devbox shell environment to reopen vscode with the devbox shell as it states.

Additional context Mac OS: Sonoma 14.0 vscode: Version: 1.83.1 (Universal) devbox: 0.7.1 devbox.json

{
  "packages": [
    "[email protected]"
  ],
  "shell": {
    "init_hook": [
      "echo 'Welcome to devbox!' > /dev/null"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}

tateexon avatar Nov 01 '23 18:11 tateexon

hey @tateexon thanks for reporting this. If you want to see more details of logs in vscode from the top menu bar you can open Help -> Toggle Developer Tools which opens an "inspect element" type window similar to Chrome. Then in the console tab you can see any logs that it may show.

Does this issue happen consistently? what happens if you try reopen in devbox shell environment command again after it fails?

mohsenari avatar Nov 01 '23 19:11 mohsenari

@mohsenari Yes it happens consistently. I opened the developer tools console and now I can see this error:

console.ts:137 [Extension Host] child process closed with exit code: 0
notificationsAlerts.ts:42 Failed to setup devbox environment.
c @ notificationsAlerts.ts:42
(anonymous) @ notificationsAlerts.ts:28
z @ event.ts:1138
A @ event.ts:1149
fire @ event.ts:1173
addNotification @ notifications.ts:204
notify @ notificationService.ts:175
(anonymous) @ mainThreadMessageService.ts:77
d @ mainThreadMessageService.ts:42
$showMessage @ mainThreadMessageService.ts:36
S @ rpcProtocol.ts:456
Q @ rpcProtocol.ts:441
M @ rpcProtocol.ts:371
L @ rpcProtocol.ts:297
(anonymous) @ rpcProtocol.ts:161
z @ event.ts:1138
fire @ event.ts:1169
fire @ ipc.net.ts:650
Y.onmessage @ localProcessExtensionHost.ts:581
localProcessExtensionHost.ts:281 Extension Host
localProcessExtensionHost.ts:282 Error: System called before being initialized by ComputeSystem

On a second try right after the first I get a similar (probably identical) error:

console.ts:137 [Extension Host] child process closed with exit code: 0
notificationsAlerts.ts:42 Failed to setup devbox environment.
c @ notificationsAlerts.ts:42
(anonymous) @ notificationsAlerts.ts:28
z @ event.ts:1138
A @ event.ts:1149
fire @ event.ts:1173
addNotification @ notifications.ts:204
notify @ notificationService.ts:175
(anonymous) @ mainThreadMessageService.ts:77
d @ mainThreadMessageService.ts:42
$showMessage @ mainThreadMessageService.ts:36
S @ rpcProtocol.ts:456
Q @ rpcProtocol.ts:441
M @ rpcProtocol.ts:371
L @ rpcProtocol.ts:297
(anonymous) @ rpcProtocol.ts:161
z @ event.ts:1138
fire @ event.ts:1169
fire @ ipc.net.ts:650
Y.onmessage @ localProcessExtensionHost.ts:581
localProcessExtensionHost.ts:281 Extension Host
localProcessExtensionHost.ts:282 Error: System called before being initialized by ComputeSystem

tateexon avatar Nov 01 '23 19:11 tateexon

@tateexon I'm going to try to recreate this issue and ping you here once it is fixed

mohsenari avatar Nov 02 '23 17:11 mohsenari

That last error message looks familiar to me: "System called before being initialized by ComputeSystem" I believe I saw it recently when running devbox direnv generate on 0.8.2

pkordel avatar Nov 27 '23 00:11 pkordel

Back with some updates since I would really like this to work. Still getting the same errors but now I am using version 0.8.4. For reference the terminal works fine, in conjunction with direnv my golang and other tools can load just fine, just no luck with the vscode extension. devbox 0.8.4 vscode 1.85.0 direnv 2.32.3 devbox by jepack.io vscode extension v0.1.3 Note: removed all other extensions before installing so it is a clean vscode macos 14.1.2

tateexon avatar Dec 12 '23 16:12 tateexon

@tateexon Thanks for the update. I'm trying to recreate this on my end. Initially, I thought it might be macos version but even after updating my macos I still couldn't recreate it. I'm planning to add logging in a logfile for the extension when Reopen in Devbox is called to see what's going on. I'll ping you once that update is in so that you can retry and send the log here.

mohsenari avatar Dec 14 '23 17:12 mohsenari

@tateexon We just released version 0.1.4 of the extension. It adds a setting called "Debug Mode" that if you enable, it will keep a log of events for "Reopen in Devbox Shell" feature. The log file is in ./devbox/extension.log. If your problem is still persisting, update the extension and enable debug mode and send me the content of this log file. This will help troubleshooting the issue significantly.

mohsenari avatar Jan 29 '24 22:01 mohsenari

for reference:

Screenshot 2024-01-29 at 5 04 38 PM

mohsenari avatar Jan 29 '24 22:01 mohsenari

Hi! I get the same error.

VSCode details:

Version: 1.85.2
Commit: 8b3775030ed1a69b13e4f4c628c612102e30a681
Date: 2024-01-18T06:40:19.222Z
Electron: 25.9.7
ElectronBuildId: 26354273
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Linux x64 6.6.11-100.fc38.x86_64

Screenshot:

image

Logs:

[Tue, 30 Jan 2024 00:06:25 GMT] Installing devbox packages
[Tue, 30 Jan 2024 00:06:25 GMT] Updating VSCode configurations
[Tue, 30 Jan 2024 00:06:25 GMT] Calling "devbox integrate" to setup environment
[Tue, 30 Jan 2024 00:06:26 GMT] child process closed with exit code: 1

devbox.json:

{
  "packages": ["[email protected]", "[email protected]"],
  "shell": {}
}

adjsky avatar Jan 30 '24 00:01 adjsky

@adjsky I think this is because the new version of the vscode extension relies on a change in devbox CLI that is not released yet. Working with the team to release the update for the CLI in the next couple of days. Apologies for that. Meanwhile, to simulate this feature, you can run devbox shell in your project directory in the terminal and then once in the shell, run code . to open vscode in devbox shell environment. Alternatively, you can re-install an older version of the extension (0.1.3) in vscode:

Screenshot 2024-01-29 at 7 23 48 PM

mohsenari avatar Jan 30 '24 00:01 mohsenari

Yes, both methods work. Thank you!

adjsky avatar Jan 30 '24 00:01 adjsky

@tateexon The changes I made on vscode extension relied on a feature in devbox cli which at the time when I pinged you wasn't released yet (my apologies). We now have released a new version of Devbox cli (v 0.9.0) would you please update your devbox version and retry this? I'm sure the log file content will be different.

mohsenari avatar Feb 01 '24 15:02 mohsenari

@mohsenari Just saw your post. Will try today and get back to you.

tateexon avatar Feb 16 '24 15:02 tateexon

Enabled debug mode. Still getting failures for the normal path:

  1. open vscode.
  2. command+shift+P and select Devbox: Reopen in Devbox shell environment
  3. failed the same as before, here is the logs in the .devbox/extension.log:
[Fri, 16 Feb 2024 16:04:39 GMT] Installing devbox packages
[Fri, 16 Feb 2024 16:04:39 GMT] Updating VSCode configurations
[Fri, 16 Feb 2024 16:04:39 GMT] Calling "devbox integrate" to setup environment
[Fri, 16 Feb 2024 16:04:39 UTC] Devbox process initiated. Setting up communication channel with VSCode process
[Fri, 16 Feb 2024 16:04:39 UTC] Computing devbox environment
[Fri, 16 Feb 2024 16:04:39 GMT] child process closed with exit code: 0

However if I cd into the repository in my shell and run devbox shell and then inside that shell code . then it boots up and I can use golang correctly for development and testing. This is great because it actually works but also sucks because most of the normal workflows don't follow that pattern. Using direnv reduces the steps by 1 since I don't need to open a devbox shell. Would still be nice to actually have the Reopen command work before I can make an argument for using this for my devs.

tateexon avatar Feb 16 '24 16:02 tateexon

Having the same issue with 0.1.6. Reinstalling 0.1.5 makes the "Reopen with Devbox" work. Confirmed on two different macOS Sequoia 15.1.1, different architectures, same synced VSCode settings.

blacksd avatar Dec 16 '24 16:12 blacksd

Is there any update on this one? For me this does not work with either version of extension :( Error in the log is exactly the same child process closed with exit code: 0. Any ideas how to troubleshoot this?

mskonovalov avatar Jan 06 '25 04:01 mskonovalov