denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
94.89k stars 5.26k forks source link

Scripts installed by `deno install` on Windows does not work in WSL paths #10135

Open felipecrs opened 3 years ago

felipecrs commented 3 years ago
> deno install --allow-net --allow-read https://deno.land/std@0.92.0/http/file_server.ts
Download https://deno.land/std@0.92.0/http/file_server.ts
Download https://deno.land/std@0.92.0/path/mod.ts
Download https://deno.land/std@0.92.0/flags/mod.ts
Download https://deno.land/std@0.92.0/_util/assert.ts
Download https://deno.land/std@0.92.0/http/server.ts
Download https://deno.land/std@0.92.0/async/mod.ts
Download https://deno.land/std@0.92.0/http/_io.ts
Download https://deno.land/std@0.92.0/io/bufio.ts
Download https://deno.land/std@0.92.0/path/posix.ts
Download https://deno.land/std@0.92.0/path/common.ts
Download https://deno.land/std@0.92.0/path/glob.ts
Download https://deno.land/std@0.92.0/path/separator.ts
Download https://deno.land/std@0.92.0/path/win32.ts
Download https://deno.land/std@0.92.0/_util/os.ts
Download https://deno.land/std@0.92.0/path/_interface.ts
Download https://deno.land/std@0.92.0/path/_constants.ts
Download https://deno.land/std@0.92.0/path/_util.ts
Download https://deno.land/std@0.92.0/textproto/mod.ts
Download https://deno.land/std@0.92.0/http/http_status.ts
Download https://deno.land/std@0.92.0/async/deferred.ts
Download https://deno.land/std@0.92.0/async/delay.ts
Download https://deno.land/std@0.92.0/async/pool.ts
Download https://deno.land/std@0.92.0/async/mux_async_iterator.ts
Download https://deno.land/std@0.92.0/io/buffer.ts
Download https://deno.land/std@0.92.0/bytes/mod.ts
Download https://deno.land/std@0.92.0/io/util.ts
Check https://deno.land/std@0.92.0/http/file_server.ts
✅ Successfully installed file_server
C:\Users\felip\.deno\bin\file_server.cmd
C:\Users\felip\.deno\bin\file_server (shell)
ℹ️  Add C:\Users\felip\.deno\bin to PATH
    set PATH=%PATH%;C:\Users\felip\.deno\bin
> cd '\\wsl$\ubuntu\home\felipecrs\repos\megatar\'
> C:\Users\felip\.deno\bin\file_server.cmd
'\\wsl$\ubuntu\home\felipecrs\repos\megatar'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
HTTP server listening on http://0.0.0.0:4507/

References https://github.com/npm/cli/issues/1189 References https://github.com/volta-cli/volta/issues/966

felipecrs commented 3 years ago

One approach that would solve this issue and #10136 would be by using https://github.com/kiennq/scoop-better-shimexe, as demonstrated here: https://github.com/npm/cli/issues/1189#issuecomment-817209410.

The contents of the file_server.shim would be:

path = deno.exe
args = run --allow-read --allow-net https://deno.land/std@0.92.0/http/file_server.ts

To use it, we would need to bundle the shim.exe in the deno.exe binary (only for Windows). It is probably a reasonable approach as the shim.exe binary itself has 123.5KB and it's MIT licensed.

nayeemrmn commented 3 years ago

Do powershell scripts support UNC paths? This seems like a cut-and-dry limitation of cmd, so offering something other than cmd is the only solution we should explore here IMO. cc @piscisaureus

felipecrs commented 3 years ago

Do powershell scripts support UNC paths?

Yes

piscisaureus commented 3 years ago
> cd '\\wsl$\ubuntu\home\felipecrs\repos\megatar\'

Using pushd instead of cd should work.

felipecrs commented 3 years ago

Using pushd instead of cd should work.

@piscisaureus There isn't any problem with the cd.

nayeemrmn commented 3 years ago

Using pushd instead of cd should work.

@piscisaureus It seems pushd when used in powershell doesn't map a network drive and effectively aliases cd: image I would suggest calling it from within our generated cmd file but I don't see a way of recovering the original UNC path.

@felipecrs You can tediously work around it by replacing:

> cd '\\wsl$\ubuntu\home\felipecrs\repos\megatar\'
> C:\Users\felip\.deno\bin\file_server.cmd

with:

> cmd.exe
  > pushd '\\wsl$\ubuntu\home\felipecrs\repos\megatar\'
  > C:\Users\felip\.deno\bin\file_server.cmd
felipecrs commented 3 months ago

@nayeemrmn I have no idea what you are talking about. Replace cd with pushd where?!

BTW this issue is still valid with Deno 1.44.4. Also worth mentioning that any UNC path is enough to trigger this issue, like browsing network directories.

felipecrs commented 3 months ago

Oh, I see now. Sorry. Yeah, that's very tedious indeed lol.

felipecrs commented 3 months ago

Note bun created a solution for this issue, they call it .bunx:

https://bun.sh/blog/bun-v1.1#bun-run-on-windows

It would be awesome if Deno could leverage it.