-
-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Paths on Windows are invalid #78
Comments
I can't test on windows so I'll need your help for that (you already wrote a beautiful bug report). Do you think we could just solve the problem by issuing our own canonicalization at broot launch? Something like this: #[cfg(not(windows))]
fn canonicalize_root(root: &Path) -> io::Result<PathBuf> {
root.canonicalize()
}
#[cfg(windows)]
fn canonicalize_root(root: &Path) -> io::Result<PathBuf> {
Ok(
if root.is_relative() {
env::current_dir()?.join(root)
} else {
root.to_path_buf()
}
)
} (maybe also solving links but there's probably not much more to do) |
On windows, the standard root normalization use UNC which isn't understood by most programs. Related to #78
note: the referenced commit isn't on master right now (it's in a "no-unce" branch) |
I'd be happy to help testing/adding docs. But I can't get started: I defined the
(that last error is from the br function, I assume broot didn't return non-zero exit code making the function continue) Any hints? |
@stinos I just published a new version fixing the 'n' answer being ignored (a problem I discovered yesterday). |
Can confirm that works. Just get a black screen upon launching though, @71 did you do anything special to get this working? If I get some time I'll install a Rust environment for building from source. |
@71 on my system your function crashes if broot doesn't emit a cd command, i.e the temp file is empty -- function br {
$outcmd = new-temporaryfile
broot.exe --outcmd $outcmd $args
if (!$?) {
remove-item -force $outcmd
return $lastexitcode
}
$command = get-content $outcmd
if ($command) {
# workaround - paths have some garbage at the start
$command = $command.replace("\\?\", "", 1)
invoke-expression $command
}
remove-item -force $outcmd
} (sorry about the renaming, i just really don't like PS's |
@stinos I did have to manually create the file @lubieowoce Arh I forgot PowerShell likes to implicitly convert everything... Good catch! |
@71 I already got the file
@Canop this is going off topic, make a new issue for this or reopen e.g. the 'Windws compatibility' one? |
I don't want to reopen a too wide issue. I'd like clear separate issues, with reproduction steps and description of the problems, so that they can be addressed. |
how about a separate issue for powershell support? that does seem kind of off-topic here, and it'd be easier to find for people looking for a suitable |
Which PS version? I cannot reproduce this, i.e. running Windows 10 version 1803 with PSVersion 5.1.17134.590 the command |
@stinos I'm on PS Core (v6.2.2, Windows 10 version 1903), which is a little less Windows-focused than regular PowerShell. |
Describe the bug
On Windows, the extended path with UNC prefix are used to canonicalize paths (e.g in the root directory at the top, or in output of commands). This causes issues
To Reproduce
Using the following Powershell Core function, try to
:cd
into a directory.An error will be shown, indicating that the path
\\?\A:\Foo
does not exist (even thoughA:\Foo
does exist).Expected behavior
Normal (usable) links with no UNC prefix should be used, since most commands do not support those prefixes.
Configuration
Additional context
As first reported here, the problem is that Broot calls
std::fs::canonicalize
, which returns a path like\\?\C:\Users\71
, instead ofC:\Users\71
. Therefore using:cd
inside Broot will write a commandcd '\\?\A:\foo'
, which will confuse PowerShell (and most commands in general).A workaround is to execute
$Command.Replace('\\?\', '')
instead of$Command
.In the end, the script I ended up using is:
However, it looks like this does not work in all cases. This crate attempts to make the transformation in a smart way, but I wonder what should happen when it judges that the UNC prefix cannot be stripped.
The text was updated successfully, but these errors were encountered: