Skip to content
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

Can't use modules with a custom path with .. [windows only] #3603

Closed
eminence opened this issue Jun 6, 2019 · 2 comments
Closed

Can't use modules with a custom path with .. [windows only] #3603

eminence opened this issue Jun 6, 2019 · 2 comments
Labels
bug Panic, non-idempotency, invalid code, etc. duplicate os-windows

Comments

@eminence
Copy link

eminence commented Jun 6, 2019

Error message:

d:\temp\LXD\85\foo>cargo fmt
error: couldn't read \\?\D:\temp\LXD\85\foo\src\..\foo.rs: The filename, directory name, or volume label syntax is incorrect. (os error 123)
 --> \\?\D:\temp\LXD\85\foo\src\main.rs:2:5
  |
2 | mod foo;
  |     ^^^

Source code:

src\main.rs:

#[path = "../foo.rs"]
mod foo;

fn main() {
    foo::hello();
}

foo.rs:

pub fn hello() {}

Notes:

  • The code is valid (cargo build is happy).
  • This only shows up on Windows (my system is Windows 7). This does not reproduce on Linux
  • This only happens if there is a .. in the path.

After poking about some MSDN docs, I found this:

For file I/O, the "\\?\" prefix to a path string tells the Windows APIs to disable all string parsing and to send the string that follows it straight to the file system. For example, if the file system supports large paths and file names, you can exceed the MAX_PATH limits that are otherwise enforced by the Windows APIs.

The part about "disable all string parsing" makes me think that we need to canonicalize the path to remove the .. before passing it on to Windows.

Versions

  • rustc 1.35.0 (3c235d560 2019-05-20)
  • cargo 1.35.0 (6f3e9c367 2019-04-04)
  • rustfmt 1.2.0-stable (09940a7 2019-03-27)
@scampi
Copy link
Contributor

scampi commented Jun 6, 2019

PRs #3324 and follow-up #3590 attempt to fix. Altough the proposed fix worked for me, it didn't for another user, so you might want to try out those branches too.

@scampi scampi added bug Panic, non-idempotency, invalid code, etc. duplicate os-windows labels Jun 6, 2019
@topecongiro
Copy link
Contributor

Fixed by #4131.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc. duplicate os-windows
Projects
None yet
Development

No branches or pull requests

3 participants