cargo icon indicating copy to clipboard operation
cargo copied to clipboard

```cargo doc --open``` doesn't work on WSL if any of the folders in the path have a space in the name

Open ChrisChoi314 opened this issue 2 years ago • 3 comments

Problem

Running cargo doc --open in a rust project if the path has any spaces causes it to not open the rust docs in the browser. Instead, we get an error that says command 'wslview' did not execute successfully; exit status: 1 and the stderr is, assuming your path of is "your\ path/your_proj/target/doc/your_proj/index.html",

Start-Process : A positional parameter cannot be found that accepts argument 'path\your_proj\target\doc\your_proj\index.html'.
At line:1 char:1
+ Start your path/your_proj/target/doc/your_proj/index.html
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: :)) [Start-Process], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand

I expected cargo doc --open to have already replaced all of the spaces with "\ " so that it wouldn't think each space causes the path to be split up into different arguments.

Steps

  1. Use WSL for the following steps.
  2. Create a directory with a space in the name.
  3. Go in that directory from the terminal and make a new Rust project, using cargo add
  4. Go into that directory and run cargo doc --open.

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.65.0
release: 1.65.0
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.58.0 (sys:0.4.59+curl-7.86.0 system ssl:GnuTLS/3.5.18)
os: Ubuntu 18.04 (bionic) [64-bit]

ChrisChoi314 avatar Mar 31 '23 18:03 ChrisChoi314

Which version of wslview do you have? You can view it with: wslview --version. I can't seem to reproduce it myself, so I suspect that it may be due to using a relatively old distribution (Ubuntu 18). You may want to try updating the version of wslview or try a newer distribution.

ehuss avatar Mar 31 '23 20:03 ehuss

It is the version wslu v2.0.0; wslview v05. lsb_release -r seems to show that is ubuntu version 18.04. I will update my ubuntu version to the 22 version now.

ChrisChoi314 avatar Apr 01 '23 00:04 ChrisChoi314

@ChrisChoi314. Does it still happen with Ubuntu 22?

weihanglo avatar Apr 13 '23 10:04 weihanglo