Skip to content

Commit de300c3

Browse files
authored
[extension] Added handling for windows/WSL in vscode extension (#1277)
## Summary Reopen in devbox shell command doesn't work in Windows or WSL cases. This PR shows an error with link to docs on how to properly setup integration in those cases. ## How was it tested? 1. `cd vscode-extension` 1. `vsce package` 1. `code --install-extension devbox0.1.1.vsix` 1. open a devbox project in vscode in windows 1. ctrl + shift + p and choose devbox: reopen in devbox shell environment
1 parent 8c617c3 commit de300c3

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

devbox.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"version": "1.52.2"
1313
}
1414
}
15-
}
15+
}

docs/app/docs/ide_configuration/vscode.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ Once Direnv is installed and setup with Devbox, its [VSCode extension](vscode:ex
4444
4. Open your Devbox project in VSCode. Direnv extension should show a prompt notification to reload your environment.
4545
5. Click on reload.
4646

47+
## Windows Setup
48+
___
49+
Devbox CLI is not supported on Windows, but you can still use it with VSCode by using Windows Subsystem for Linux ([WSL](https://learn.microsoft.com/en-us/windows/wsl/install)). If you've set up WSL, follow these steps to integrate your Devbox shell environment with VSCode:
4750

51+
1. [Install](https://www.jetpack.io/devbox/docs/installing_devbox/) Devbox in WSL.
52+
2. Navigate to your project directory. (`C:\Users` is `/mnt/c/Users/` in WSL).
53+
3. Run `devbox init` if you don't have a devbox.json file.
54+
4. Run `devbox shell`
55+
5. Run `code .` to open VSCode in Windows and connect it remotely to your Devbox shell in WSL.
4856
## Manual Setup
4957
___
5058
VS Code is a popular editor that supports many different programming languages. This section covers how to configure VS Code to work with a devbox Java environment as an example.

vscode-extension/src/devbox.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { window, workspace, commands, ProgressLocation, Uri, ConfigurationTarget } from 'vscode';
1+
import { window, workspace, commands, ProgressLocation, Uri, ConfigurationTarget, env } from 'vscode';
22
import { spawn, spawnSync } from 'node:child_process';
33

44

@@ -7,6 +7,18 @@ interface Message {
77
}
88

99
export async function devboxReopen() {
10+
11+
if (process.platform === 'win32') {
12+
const seeDocs = 'See Devbox docs';
13+
const result = await window.showErrorMessage(
14+
'This feature is not supported on your platform. \
15+
Please open VSCode from inside devbox shell in WSL using the CLI.', seeDocs
16+
);
17+
if (result === seeDocs) {
18+
env.openExternal(Uri.parse('https://www.jetpack.io/devbox/docs/ide_configuration/vscode/#windows-setup'));
19+
return;
20+
}
21+
}
1022
await window.withProgress({
1123
location: ProgressLocation.Notification,
1224
title: "Setting up your Devbox environment. Please don't close vscode.",
@@ -64,6 +76,8 @@ export async function devboxReopen() {
6476
return p;
6577
}
6678
);
79+
80+
6781
}
6882

6983
async function setupDotDevbox(workingDir: Uri, dotdevbox: Uri) {

0 commit comments

Comments
 (0)