Windows escape handling is not accurate
jeiea opened this issue · comments
Steps to reproduce
velociraptor.json
{
"scripts": {
"bundle": "deno run --unstable --allow-read --allow-write --allow-env --allow-net https://deno.land/x/denopack@0.10.0/cli.ts --config denopack_config.ts --dir dist --input"
}
}
PS> &vr run bundle source.ts
Expected behavior
Normal execution like the following.
PS> deno.exe "run" "--allow-read" "--allow-write" "--allow-net" "--allow-env" "--unstable" "https://deno.land/x/denopack@0.10.0/cli.ts" --config denopack_config.ts --dir dist --input source.ts
denopack completed in 1037ms
Actual behavior
PS> &vr run bundle source.ts
error: Uncaught Error: Could not load "source.ts": Cannot access the file system (via "fs.readFile") when using the browser build of Rollup. Make sure you supply a plugin with custom resolveId and load hooks to Rollup.
at https://unpkg.com/rollup@2.26.11/dist/es/rollup.browser.js:11:317808
at Ua.addModuleSource (https://unpkg.com/rollup@2.26.11/dist/es/rollup.browser.js:11:323588)
at async Ua.fetchModule (https://unpkg.com/rollup@2.26.11/dist/es/rollup.browser.js:11:325400)
at async Promise.all (index 0)
error: Failed at the bundle script
Additional context
The followings is the command lines of the executed processes.
"C:\ProgramData\chocolatey\lib\deno\deno.exe" "run" "--allow-read" "--allow-write" "--allow-net" "--allow-env" "--allow-run" "--allow-plugin" "--allow-hrtime" "--quiet" "https://deno.land/x/velociraptor@1.0.0-beta.14/cli.ts" run bundle source.ts
"C:\Windows\system32\cmd.exe" /d /s /c "deno run --unstable --allow-read --allow-write --allow-env --allow-net https://deno.land/x/denopack@0.10.0/cli.ts --config denopack_config.ts --dir dist --input \"source.ts\""
deno run --unstable --allow-read --allow-write --allow-env --allow-net https://deno.land/x/denopack@0.10.0/cli.ts --config denopack_config.ts --dir dist --input \"source.ts\"
In buildShellArgs
shell command is passed as single string, and it seems that cmd cannot process doubly escaped command according to the line 2.
Hi @jeiea, thanks for reporting this.
There is a known limitation with cmd.exe
's way of handling quotes that will probably cause troubles with additional arguments, however I get your same error when trying to run denopack
, independently from Velociraptor or Windows/cmd so it's probably an issue on their side?
Re cmd and quotes what I can suggest for now is to follow the recommended workaround in the README.
I found that absolute path is required in the position of test.ts
. But velociraptor still results the error despite of the usage of absolute path. It seems a known issue according to what you say, so I close this. Thanks for fast reply.
@jeiea does it work if you change vr's shell to PowerShell?
$ VR_SHELL="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" vr bundle source.ts
It worked well with absolute path.
PS D:\some-path> $env:VR_SHELL="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
PS D:\some-path> vr bundle D:\some-path\source.ts
denopack completed in 1403ms