Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Reopen in Devbox shell doesn't work #1619

Closed
mikenikles opened this issue Nov 11, 2023 · 28 comments
Closed

[Bug]: Reopen in Devbox shell doesn't work #1619

mikenikles opened this issue Nov 11, 2023 · 28 comments
Assignees
Labels
bug Something isn't working

Comments

@mikenikles
Copy link
Contributor

mikenikles commented Nov 11, 2023

Current Behavior (bug)
I use Cursor (cursor.sh) as my editor (update: I have the same issue with VS Code), with the Devbox extension installed. When I use the "Devbox: Reopen in Devbox shell environment" command, Cursor closes, but doesn't reopen again.

Expected Behavior (fix)
Cursor closes and reopens.

Additional context

devbox version -v

devbox version -v
Version:     0.8.1
Platform:    darwin_arm64
Commit:      a0bdff918b3dde5ebcfc488f72df5efdf3426253
Commit Time: 2023-11-07T21:43:27Z
Go Version:  go1.21.3
Launcher:    0.2.0

devbox.json

{
  "packages": [
    "rustup@latest",
    "libiconv@latest"
  ],
  "env": {
    "PROJECT_DIR": "$PWD"
  },
  "shell": {
    "init_hook": [
      "rustup default stable"
    ],
    "scripts": {
      "test": [
        "echo \"Error: no test specified\" && exit 1"
      ]
    }
  }
}
@mikenikles mikenikles added the bug Something isn't working label Nov 11, 2023
@mikenikles
Copy link
Contributor Author

mikenikles commented Nov 11, 2023

I tried that command in VS Code Insider and VS Code, but it didn't work there either. Both editors are on their latest versions.

@mikenikles mikenikles changed the title [Bug]: Reopen in Devbox shell doesn't work with Cursor [Bug]: Reopen in Devbox shell doesn't work Nov 11, 2023
@Lagoja
Copy link
Contributor

Lagoja commented Nov 14, 2023

@mikenikles Can you share what OS you are encountering this issue on? We've seen some issues with macOS Sonoma, but haven't found a reliable repro

@mikenikles
Copy link
Contributor Author

I recently upgraded to Sonoma 14.1.1, but I also saw it on whichever the previous OS version was. Now that I'm on Sonoma though and given it's a known issue, I'll accept that it doesn't work :)

@aacebedo
Copy link

I have the same problem on NixOS 23.11

@mohsenari
Copy link
Collaborator

@mikenikles @aacebedo 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
Copy link
Collaborator

for reference:

Screenshot 2024-01-29 at 5 04 38 PM

@aacebedo
Copy link

aacebedo commented Jan 30, 2024

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

Go this on code-insiders 1.86 and devbox 0.8.2 on NixOS, not sure it is very useful:

[Tue, 30 Jan 2024 13:58:14 GMT] Installing devbox packages
[Tue, 30 Jan 2024 13:58:14 GMT] Updating VSCode configurations
[Tue, 30 Jan 2024 13:58:14 GMT] Calling "devbox integrate" to setup environment
[Tue, 30 Jan 2024 13:58:14 GMT] child process closed with exit code: 1
[Tue, 30 Jan 2024 14:44:11 GMT] Installing devbox packages
[Tue, 30 Jan 2024 14:44:11 GMT] Updating VSCode configurations
[Tue, 30 Jan 2024 14:44:11 GMT] Calling "devbox integrate" to setup environment
[Tue, 30 Jan 2024 14:44:11 GMT] child process closed with exit code: 1
[Tue, 30 Jan 2024 16:19:59 GMT] Installing devbox packages
[Tue, 30 Jan 2024 16:19:59 GMT] Updating VSCode configurations
[Tue, 30 Jan 2024 16:19:59 GMT] Calling "devbox integrate" to setup environment
[Tue, 30 Jan 2024 16:19:59 GMT] child process closed with exit code: 1

@mikenikles
Copy link
Contributor Author

I see the same output.

I also see the following when I select the Output tab, then "Extension Host":

2024-01-30 14:28:51.824 [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-ssh, startup: false, activationEvent: 'onStartupFinished', root cause: jetpack-io.devbox
2024-01-30 14:28:51.867 [info] ExtensionService#_doActivateExtension jetpack-io.devbox, startup: false, activationEvent: 'onStartupFinished'
2024-01-30 14:28:51.878 [info] ExtensionService#_doActivateExtension ms-vscode.remote-explorer, startup: false, activationEvent: 'onCommand:remote-internal.setActiveFolders'
2024-01-30 14:29:16.560 [info] ExtensionService#_doActivateExtension vscode.json-language-features, startup: false, activationEvent: 'onLanguage:jsonc'
2024-01-30 14:29:56.720 [error] undefined devbox.reopen {"value":"jetpack-io.devbox","_lower":"jetpack-io.devbox"}

@aacebedo
Copy link

I see the same output.

I also see the following when I select the Output tab, then "Extension Host":

2024-01-30 14:28:51.824 [info] ExtensionService#_doActivateExtension ms-vscode-remote.remote-ssh, startup: false, activationEvent: 'onStartupFinished', root cause: jetpack-io.devbox
2024-01-30 14:28:51.867 [info] ExtensionService#_doActivateExtension jetpack-io.devbox, startup: false, activationEvent: 'onStartupFinished'
2024-01-30 14:28:51.878 [info] ExtensionService#_doActivateExtension ms-vscode.remote-explorer, startup: false, activationEvent: 'onCommand:remote-internal.setActiveFolders'
2024-01-30 14:29:16.560 [info] ExtensionService#_doActivateExtension vscode.json-language-features, startup: false, activationEvent: 'onLanguage:jsonc'
2024-01-30 14:29:56.720 [error] undefined devbox.reopen {"value":"jetpack-io.devbox","_lower":"jetpack-io.devbox"}

@mikenikles On nixos ?

@mohsenari dld you check the extension on insiders build ?

@mikenikles
Copy link
Contributor Author

I use Mac OS Sonoma

@mohsenari
Copy link
Collaborator

@aacebedo @mikenikles the changes I made to enable debug logs relied on a feature in devbox cli that wasn't released yet (my apologies). We now have released devbox version 0.9.0. Would you please update your devbox to newest version and retry this?

@mikenikles
Copy link
Contributor Author

With devbox 0.9.0:

[Thu, 01 Feb 2024 17:20:16 GMT] Installing devbox packages
[Thu, 01 Feb 2024 17:20:16 GMT] Updating VSCode configurations
[Thu, 01 Feb 2024 17:20:16 GMT] Calling "devbox integrate" to setup environment
[Thu, 01 Feb 2024 17:20:16 UTC] Devbox process initiated. Setting up communication channel with VSCode process
[Thu, 01 Feb 2024 17:20:16 UTC] Computing devbox environment
[Thu, 01 Feb 2024 17:20:16 UTC] Signaling VSCode to close
[Thu, 01 Feb 2024 17:20:16 UTC] Re-opening VSCode in computed devbox environment
[Thu, 01 Feb 2024 17:20:16 UTC] stdout:  
 stderr: 
[Thu, 01 Feb 2024 17:20:16 UTC] exec: "code": executable file not found in $PATH
[Thu, 01 Feb 2024 17:20:16 GMT] child process closed with exit code: 1

That makes sense since Cursor doesn't have a code binary. I tried with alias code=/Applications/Cursor.app/Contents/MacOS/Cursor in my bash profile, but that didn't work.

I'll have to look into it in more detail later, but posting this for now in case anyone has ideas.

@mikenikles
Copy link
Contributor Author

Fixed it with sudo ln -s /Applications/Cursor.app/Contents/MacOS/Cursor /usr/local/bin/code.

However, it gets weirder now 😕:

[Thu, 01 Feb 2024 17:37:18 GMT] Installing devbox packages
[Thu, 01 Feb 2024 17:37:18 GMT] Updating VSCode configurations
[Thu, 01 Feb 2024 17:37:18 GMT] Calling "devbox integrate" to setup environment
[Thu, 01 Feb 2024 17:37:18 UTC] Devbox process initiated. Setting up communication channel with VSCode process
[Thu, 01 Feb 2024 17:37:18 UTC] Computing devbox environment
[Thu, 01 Feb 2024 17:37:19 UTC] Signaling VSCode to close
[Thu, 01 Feb 2024 17:37:19 UTC] Re-opening VSCode in computed devbox environment
[Thu, 01 Feb 2024 17:37:19 UTC] stdout:  
 stderr: node:internal/modules/cjs/loader:1085
  throw err;
  ^

Error: Cannot find module '/Users/m/projects/x/y/z'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1082:15)
    at Module._load (node:internal/modules/cjs/loader:927:27)
    at f._load (node:electron/js2c/asar_bundle:2:13377)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:96:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.15.0

[Thu, 01 Feb 2024 17:37:19 UTC] exit status 1

Possibly no longer Devbox related 🤔?!

@mikenikles
Copy link
Contributor Author

mikenikles commented Feb 1, 2024

If I add an empty index.js to the repo root and a "main": "index.js", entry to the package.json file, I end up with this:

[Thu, 01 Feb 2024 17:42:51 GMT] Installing devbox packages
[Thu, 01 Feb 2024 17:42:51 GMT] Updating VSCode configurations
[Thu, 01 Feb 2024 17:42:51 GMT] Calling "devbox integrate" to setup environment
[Thu, 01 Feb 2024 17:42:51 UTC] Devbox process initiated. Setting up communication channel with VSCode process
[Thu, 01 Feb 2024 17:42:51 UTC] Computing devbox environment
[Thu, 01 Feb 2024 17:42:51 UTC] Signaling VSCode to close
[Thu, 01 Feb 2024 17:42:51 UTC] Re-opening VSCode in computed devbox environment

Cursor closes the current window and stays like that – no open window.

@mohsenari
Copy link
Collaborator

mohsenari commented Feb 1, 2024

@mikenikles
I just installed cursor. And during first setup it asks you if you want to setup cursor to open with command line "code" or "cursor" I ignore that prompt on purpose. Then once cursor is opened, I did cmd + shift + p and ran "Shell Command: Install 'Code' command" .
After that I tried reopen in devbox and it worked correctly. Can you try that instead of sudo ln -s /Applications/Cursor.app/Contents/MacOS/Cursor /usr/local/bin/code?

When you see this line in the log: Re-opening VSCode in computed devbox environment, it basically means devbox cli is running the command code <path to workspace when IDE was closed>. So if cursor doesn't open, it's equivalent to running devbox shell in a terminal then inside devbox shell running code . not working properly.

@mikenikles
Copy link
Contributor Author

Excellent!! That does the trick, I'm all set. Thank you 🙏!

Funny enough, running that "Shell Command: Install 'Code' command" does the following:

ll `which code`
lrwxr-xr-x 1 root wheel 56 Feb  1 14:29 /usr/local/bin/code -> /Applications/Cursor.app/Contents/Resources/app/bin/code

Looks like my symlink pointed to the wrong file :)

Leaving this open until @aacebedo confirmed it works for him too.

@aacebedo
Copy link

aacebedo commented Feb 2, 2024

I saw the same issue because the binary for the insiders build is code-insiders and not code. I think devbox shall add the support of code-insiders or refactor the way the IDE are handled (like providers for instance).

@mohsenari
Copy link
Collaborator

@aacebedo that's a good suggestion. I can add in settings the path to binary that opens vscode so that it can be configurable.
For the time being making a symlink seems to be the workaround.

@tmeckel
Copy link

tmeckel commented Feb 28, 2024

@mohsenari I'm experiencing a similar (or identical?) error. Host is Windows target is an Ubuntu 20.04 VM connected via SSH remote. When executing "Devbox: Reopen in Devbox shell environment", the following error is displayed.

image

The contents of the .devbox/extension.log file isn't helpful

[Wed, 28 Feb 2024 15:40:04 GMT] Installing devbox packages
[Wed, 28 Feb 2024 15:40:04 GMT] Updating VSCode configurations
[Wed, 28 Feb 2024 15:40:04 GMT] Calling "devbox integrate" to setup environment
[Wed, 28 Feb 2024 15:40:04 UTC] Devbox process initiated. Setting up communication channel with VSCode process
[Wed, 28 Feb 2024 15:40:04 UTC] Computing devbox environment
[Wed, 28 Feb 2024 15:40:04 GMT] child process closed with exit code: 0
[Wed, 28 Feb 2024 15:43:10 GMT] Installing devbox packages
[Wed, 28 Feb 2024 15:43:10 GMT] Updating VSCode configurations
[Wed, 28 Feb 2024 15:43:10 GMT] Calling "devbox integrate" to setup environment
[Wed, 28 Feb 2024 15:43:10 UTC] Devbox process initiated. Setting up communication channel with VSCode process
[Wed, 28 Feb 2024 15:43:10 UTC] Computing devbox environment
[Wed, 28 Feb 2024 15:43:10 GMT] child process closed with exit code: 0
[Wed, 28 Feb 2024 15:45:52 GMT] Installing devbox packages
[Wed, 28 Feb 2024 15:45:52 GMT] Updating VSCode configurations
[Wed, 28 Feb 2024 15:45:52 GMT] Calling "devbox integrate" to setup environment
[Wed, 28 Feb 2024 15:45:52 UTC] Devbox process initiated. Setting up communication channel with VSCode process
[Wed, 28 Feb 2024 15:45:52 UTC] Computing devbox environment
[Wed, 28 Feb 2024 15:45:52 GMT] child process closed with exit code: 0
[Wed, 28 Feb 2024 16:20:45 GMT] Installing devbox packages
[Wed, 28 Feb 2024 16:20:45 GMT] Updating VSCode configurations
[Wed, 28 Feb 2024 16:20:45 GMT] Calling "devbox integrate" to setup environment
[Wed, 28 Feb 2024 16:20:45 UTC] Devbox process initiated. Setting up communication channel with VSCode process
[Wed, 28 Feb 2024 16:20:45 UTC] Computing devbox environment
[Wed, 28 Feb 2024 16:20:45 GMT] child process closed with exit code: 0
[Wed, 28 Feb 2024 16:22:38 GMT] Installing devbox packages
[Wed, 28 Feb 2024 16:22:38 GMT] Updating VSCode configurations
[Wed, 28 Feb 2024 16:22:38 GMT] Calling "devbox integrate" to setup environment
[Wed, 28 Feb 2024 16:22:38 UTC] Devbox process initiated. Setting up communication channel with VSCode process
[Wed, 28 Feb 2024 16:22:38 UTC] Computing devbox environment
[Wed, 28 Feb 2024 16:22:38 GMT] child process closed with exit code: 0

What error log (as mentioned in the error dialog) is relevant here to pin the error?

Digged a bit into the source code. I suspect the error occurs at line 98 in integrate.go. But hard to tell which called function creates that error. Perhaps a call to nix?

image

@mohsenari
Copy link
Collaborator

@tmeckel the functionality of Reopen in devbox shell environment doesn't work when you're connected to a remote env and also when called from Windows connected to WSL as a remote env. I explained the reason for it, with a bit more details here:
#1781 (comment)

@tmeckel
Copy link

tmeckel commented Apr 5, 2024

@mohsenari sadly to say, then devbox is not an option for me. Stick to DevContainers then.

@tmeckel
Copy link

tmeckel commented May 3, 2024

@mohsenari does this might change anything?
https://github.com/microsoft/vscode-docs/blob/main/remote-release-notes/v1_89.md#wsl

I know they're talking about connecting to a WSL instance when you're connected to a Windows machine via SSH. But I think they might have changed the inner workings of WSL remote support for that.

@mohsenari
Copy link
Collaborator

@tmeckel I need to do some testing to see if there is a way to connect to WSL from VSCode's extension. Then spawn a subprocess, compute devbox env and lastly, reopen vscode from within WSL instance.
I'll play around on my windows machine and let you know if it's possible. It would be nice to have reopen in devbox shell work in Windows.

@tmeckel
Copy link

tmeckel commented Jun 17, 2024

Can't wait about your results 👍🏼👍🏼 would be awesome to be able to use devbox in WSL

@andr-ec
Copy link

andr-ec commented Jul 6, 2024

It would be amazing if at the same time it could be resolved on remove servers as well. as mentioned here: #1781 (comment)

mohsenari added a commit that referenced this issue Sep 27, 2024
…vscodium (#2309)

## Summary
Title plus, removed remote-ssh dependency to allow publishing the
extension in open-vsx marketplace.

Addresses #1619

I've been wanting to get this fixed for a while but with recent traction
on vscode alternatives it makes sense to finally get this fix in.

## How was it tested?
steps:
1. compile devbox binary (devbox run build)
2. update line 56 in `vscode-extension/src/devbox.ts` to the absolute
path to compiled devbox binary
3. have all 3 of cursor, vscodium and vscode installed
4. have `vsce` installed globally (npm install -g vsce)
5. in devbox/vscode-extension folder run: `vsce package && code
--install-extension devbox-0.1.6.vsix && cursor --install-extension
devbox-0.1.6.vsix && codium --install-extension devbox-0.1.6.vsix`
6. quit any already open code editor, open it to refresh the editor with
new installed extension
7. cmd + shift + p and type `devbox: reopen in devbox` and hit enter in
vscode, cursor, and vscodium
@mohsenari
Copy link
Collaborator

@mikenikles vscode extension version 0.1.6 was published. With this version, reopen in devbox should work fine with Cursor. Closing this issue but reopen if the issue is not resolved.

@tmeckel
Copy link

tmeckel commented Oct 6, 2024

@mohsenari still no luck with a devbox environment located on remote VM using SSH.

Debug log is not very helpful

[Sun, 06 Oct 2024 14:22:15 GMT] Installing devbox packages
[Sun, 06 Oct 2024 14:22:15 GMT] Updating editor configurations
[Sun, 06 Oct 2024 14:22:15 GMT] Calling "devbox integrate" to setup environment
[Sun, 06 Oct 2024 14:22:15 UTC] Devbox process initiated. Setting up communication channel with the code editor process
[Sun, 06 Oct 2024 14:22:15 UTC] Computing devbox environment
[Sun, 06 Oct 2024 14:22:15 GMT] child process closed with exit code: 0

@andr-ec
Copy link

andr-ec commented Oct 6, 2024

Work around on remote environments:

#1781 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

6 participants