vite-plugin-svelte icon indicating copy to clipboard operation
vite-plugin-svelte copied to clipboard

Could not open +page.svelte in the editor

Open Loizzus opened this issue 1 year ago • 15 comments

Describe the bug

Randomly started getting this error on my Svelte projects recently when using the code inspector to open up files. Have no idea how to resolve. It only affects files with special characters in the name.

Could not open +page.svelte in the editor.

When running on Windows, file names are checked against a safe file name pattern to protect against remote code execution attacks. File names may consist only of alphanumeric characters (all languages), periods, dashes, slashes, and underscores.

Reproduction URL

https://github.com/sveltejs/vite-plugin-svelte/issues/new

Reproduction

Sorry, do not know how to replicate. Looking for advice on how to fix.

Logs

No response

System Info

Windows 11, VS Code, Tested with Brave and Edge

Loizzus avatar Jul 14 '24 20:07 Loizzus

caused by https://github.com/yyx990803/launch-editor/commit/5366f3ee3addc9ea014088c254db6398f788fbff

launch-editor tries to protect from malicious filenames, not sure if + is a dangerous char on windoes or just too rigid check

dominikg avatar Jul 14 '24 23:07 dominikg

fix could take a bit as launch-editor is bundled in vite

dominikg avatar Jul 14 '24 23:07 dominikg

The linked change was included in vite 5.3.2

dominikg avatar Jul 15 '24 08:07 dominikg

and how to fix this now? I got most recent versions and still get this error.

Haukez avatar Jul 29 '24 14:07 Haukez

this needs a change in launch-editor first and then vite has to update the bundled version and release that.

dominikg avatar Jul 29 '24 14:07 dominikg

As a temporary fix force vite to be version 5.3.1 in your package.json: "devDependencies": { "vite": "5.3.1" }, "overrides": { "@sveltejs/vite-plugin-svelte": { "vite": "5.3.1" } }

Loizzus avatar Jul 29 '24 20:07 Loizzus

please don't use partial overrides. If svelte-inspector on +page.svelte files is that important to you, go back to vite 5.3.1 entirely to ensure that you are using one consistent version.

dominikg avatar Jul 29 '24 20:07 dominikg

the fix for this is going to be included in the next release of vite

dominikg avatar Aug 06 '24 11:08 dominikg

Still doesn't work for me with "vite": "^5.4.0",

Wizzel1 avatar Aug 07 '24 16:08 Wizzel1

Still doesn't work for me with "vite": "^5.4.0",

can you provide more info here? the fix was pretty straight forward and another windows user just reported it working with 5.4.

can you open files that do not contain a + in their name? Which windows shell and ide versions?

dominikg avatar Aug 07 '24 19:08 dominikg

Yes, I sometimes can open files that don't contain a + but it's hit and miss.

Sometimes even navigating to a component fails:

app:dev: Could not open BulkReplaceSheet.svelte in the editor.
app:dev: 
app:dev: When running on Windows, file names are checked against a safe file name pattern to protect against remote code execution attacks. File names may consist only of alphanumeric 
characters (all languages), periods, dashes, slashes, and underscores.

My vscode version is 1.92.0 and I am running powershell

Wizzel1 avatar Aug 08 '24 07:08 Wizzel1

Does your username or the project directory contain any other special characters?

dominikg avatar Aug 08 '24 10:08 dominikg

This is the path to one of my pages. Closest character to a special character is the underscore. Unbenannt

Wizzel1 avatar Aug 08 '24 15:08 Wizzel1

oof, [] and () are problems tooo i guess

dominikg avatar Aug 08 '24 16:08 dominikg

can confirm this is still an issue with vite 5.4.2

Could not open Title.svelte in the editor.

When running on Windows, file names are checked against a safe file name pattern 
to protect against remote code execution attacks. File names may consist only of 
alphanumeric characters (all languages), periods, dashes, slashes, and underscores.

image


Referencing

issue: https://github.com/yyx990803/launch-editor/issues/50 pull: https://github.com/yyx990803/launch-editor/issues/50 commit: https://github.com/yyx990803/launch-editor/commit/5366f3ee3addc9ea014088c254db6398f788fbff

oneezy avatar Aug 24 '24 23:08 oneezy

Happening for me on Win10 as well, after update to latest version of SvelteKit 2.

Only seems to happen when inspecting elements on routes (+page.svelte), or on components not inside of routes with params. I'm guessing '+' and '[]' are not on the aforementioned safe file name pattern. Components living anywhere else seem to work fine.

image

rogueyoshi avatar Sep 20 '24 17:09 rogueyoshi

Any updates on this?

Wizzel1 avatar Oct 05 '24 07:10 Wizzel1

latest version of launch-editor and vite should have this fixed. if you still experience files that do not open please share their full path (skip your user dir for privacy if you prefer but mention if it has any special chars)

dominikg avatar Oct 05 '24 07:10 dominikg

latest version of launch-editor and vite should have this fixed. if you still experience files that do not open please share their full path (skip your user dir for privacy if you prefer but mention if it has any special chars)

So I am running VSCode 1.94.0 and vite 5.4.8. Maybe its the underscore in my repo name? Unbenannt

Wizzel1 avatar Oct 05 '24 10:10 Wizzel1

Can confirm, issue has not been fixed for Svelte 4. image

Also the plugin does not work at all in Svelte 5.

Loizzus avatar Oct 08 '24 01:10 Loizzus

Actually a simple test project does work. However I tested this path from an actual production project and it fails: C:\Users\loic.joachim\Documents\GitHub\nodejs-external\src\routes\portal\(orders)\ordermanagement\+page.svelte Presumably because of the -

Loizzus avatar Oct 08 '24 02:10 Loizzus

The fix is in launch-editor 2.9.1 which has been merged into vite main branch (6.0 beta) but not backported to 5.4 branch yet, sorry. still needs to wait a bit

dominikg avatar Oct 13 '24 15:10 dominikg

please try again with vite 5.4.9

dominikg avatar Oct 14 '24 13:10 dominikg

please try again with vite 5.4.9

Yes it works now, thanks

Wizzel1 avatar Oct 14 '24 17:10 Wizzel1

I still have this issue using WSL2 (Ubuntu) on Windows. Happens with every component. The file paths are fairly simple, e.g.: ~/apps/omat/my-app/src/lib/ui/img.svelte

Vite 7.1.5 and vite-plugin-svelte 6.2.0.

SpeedoPasanen avatar Sep 17 '25 07:09 SpeedoPasanen

launch-editor still does not support WSL, see https://github.com/yyx990803/launch-editor/issues/16

dominikg avatar Sep 17 '25 08:09 dominikg