launch-editor icon indicating copy to clipboard operation
launch-editor copied to clipboard

WSL Support

Open MarcelloTheArcane opened this issue 5 years ago • 11 comments

It doesn't appear to work when serving from Windows Subsystem for Linux.

Is this a possibility?

MarcelloTheArcane avatar Aug 28 '19 13:08 MarcelloTheArcane

+1

aixfox avatar Sep 23 '19 10:09 aixfox

Just want to confirm that it does not work on WSL2. Tried everything, like setting the LAUNCH_EDITOR=code variable in a .env file etc.

Not sure, but the problem might be related to the fact, that while WSL2 is Linux, so the development code runs on Linux, the editor and the browser themselves still run on the Windows OS.

codepainting avatar Nov 01 '22 10:11 codepainting

Just stumbled upon this issue and toyed with it for a bit and found a solution. Open your VS Code settings, either Remote [WSL] for every project or Workspace for each individual project you wish to configure, and find Terminal > Integrated > Env: Linux and after opening the settings JSON add the key-value pair "EDITOR": "code" to the terminal.integrated.env.linux configuration object.

This causes it the inspector to open files correctly either when running the dev server manually or when using the Vite extensions Open Vite App command server.

Example settings.json:

{
    // other config...

    "terminal.integrated.env.linux": {
        "EDITOR": "code"
    }
}

gtdrakeley avatar Feb 18 '23 21:02 gtdrakeley

The solution proposed by @gtdrakeley works perfectly for anything in the project scope (routes, lib, and even custom paths (via path.resolve)). It's a great time saver already!

Unfortunately, components outside that scope show the correct component path highlighted on the page, but a click does not open the component in the editor. This makes it impossible to use the inspector for monorepos on WSL with local packages (like Design Systems) etc.

I suspected that it might have had something to do with the Vite config — in particular server.fs.allow — but providing the paths outside my root did not solve the problem.

codepainting avatar Apr 20 '23 20:04 codepainting

~~I was excited to use svelte inspector with WSL2 but @gtdrakeley's solution isn't working for me and I still get this error with no further explanation:~~

~~Could not open .svelte in the editor.~~

~~@codepainting I saw from sveltejs/vite-plugin-svelte/#481 that you had similar issue did you only used "terminal.integrated.env.linux" to make it work?~~

It only works when you launch the vite dev server using VS code's integrated terminal. I usually use just to launch everything with one command like just dev so hope it can work when vite server and vscode is launched via windows terminal.

silenceofthewans avatar May 16 '23 09:05 silenceofthewans

I was excited to use svelte inspector with WSL2 but @gtdrakeley's solution isn't working for me and I still get this error with no further explanation:

Could not open <filename>.svelte in the editor.

@codepainting I saw from sveltejs/vite-plugin-svelte/#481 that you had similar issue did you only used "terminal.integrated.env.linux" to make it work?

@silenceofthewans Yes, I only used that, and it worked for me. But unfortunately not for everything, as stated in my prior reply. It worked for files in src, $lib, but not for files outside the project scope, like our design system or other packages which are co-located in a common monorepo. This makes the inspector only semi-useful in my case, which is sad, because it's such a great feature.

codepainting avatar May 16 '23 09:05 codepainting

@codepainting I edited my comment but I think you might also be using the integrated terminal to launch your dev server because I tested and svelte inspector only opens the file in vscode if you used the same vscode instance to launch your dev server. This comment mentions same.

silenceofthewans avatar May 16 '23 10:05 silenceofthewans

the CMD+CLICK does not open the file, when I am using turborepo and the component is from an internal package.

AxeloLabs avatar Jun 19 '23 13:06 AxeloLabs

For some reason setting only EDITOR did not help, it was still opening in vim, needed to set VISUAL to code too on WSL2.

jkbz64 avatar Jun 26 '23 12:06 jkbz64

It works perfectly for me by adding

export EDITOR="code"

to your favorite shell config (~/.zshrc for me)

You may also want to add

export VISUAL="code" if we consider @jkbz64 answer as well and that the first one couldn't do the trick for you.

kevinmarrec avatar Oct 17 '23 12:10 kevinmarrec

It only works when you launch the vite dev server using VS code's integrated terminal. I usually use just to launch everything with one command like just dev so hope it can work when vite server and vscode is launched via windows terminal.

Hello @silenceofthewans do you find any solution for this? I'm using Windows Terminal with WSL 2 and Laravel Sail. I tried everything from the comments here with no result. When I click "open in editor" in vue-dev-tool-next in the console I get this error

Could not open Dashboard.vue in the editor.
The editor process exited with an error: spawn code ENOENT.

mreduar avatar May 16 '24 00:05 mreduar