jetify-com / devbox

Instant, easy, and predictable development environments
https://www.jetify.com/devbox/
Apache License 2.0
8.56k stars 197 forks source link

[Bug]: VS Code extension: "Reopen in Devbox shell environment" command does not work in WSL #1319

Open apgrucza opened 1 year ago

apgrucza commented 1 year ago

Current Behavior (bug) The "Reopen in Devbox shell environment" command does not work in a VS Code WSL window. The VS Code window closes without a new one being opened. There is no error message stating that WSL is not supported. (The error message added in #1277 only appears when in a normal VS Code window, not a WSL one).

Expected Behavior (fix) After the VS Code window closes, a new VS Code window should open that is set up with the project's Devbox environment.

Additional context Output of devbox version -v:

Version:     0.5.7
Platform:    linux_amd64
Commit:      95ee45715bd2d5a7e60cd58093f2a87a88a4564d
Commit Time: 2023-07-12T22:28:00Z
Go Version:  go1.20.5
Launcher:    0.2.0
apgrucza commented 1 year ago

(comment copied from #1029)

I had a poke around myself in internal/boxcli/integrate.go and made these observations:

If HOME is set, the Windows executable can be run instead, and environment variables do get passed through. So I'm not sure if this is the best way, but the below changes to integrate.go do work as a proof-of-concept under WSL:

    cmnd := exec.Command(os.Getenv("VSCODE_CWD")+"/bin/code", message.ConfigDir)
    cmnd.Env = append(cmnd.Env, envVars...)
    cmnd.Env = append(cmnd.Env, "HOME="+os.Getenv("HOME")) // Prevent error: mkdir: cannot create directory ‘/.vscode-server’: Permission denied
    cmnd.Env = append(cmnd.Env, "ELECTRON_RUN_AS_NODE=")   // Prevent error: Remote Extension host terminated unexpectedly 3 times within the last 5 minutes.
Abdullah-AlAttar commented 1 week ago

any updates on this? or a workaround