Windows 10 Error copying files to folder

Hi all, I've been trying to contribute to cargo but ran into some weird Error issues.

Here is a minimal example I can muster. GitHub - Ygg01/minimal_copy_problem: Minimal folder problem with std:fs::copy

When running on Windows 10 and 11, I've encountered this bug, and I'm stumped.

Running 3 tests
test test_file_to_folder_with_backslash ... FAILED
test test_file_to_folder ... FAILED
test test_file_to_file ... ok

failures:

---- test_file_to_folder_with_backslash stdout ----
dest: "C:\\Users\\~~~~~\\RustroverProjects\\minimal_copy_problem\\target\\test2\\"
thread 'test_file_to_folder_with_backslash' panicked at src/main.rs:62:10:
Failed to copy from "C:\\Users\\~~~~~\\RustroverProjects\\minimal_copy_problem\\README.md" to "C:\\Users\\~~~~~\\RustroverProjects\\minimal_copy_problem\\target\\test2\\": Os { code: 3, kind: NotFound, message: "The system cannot find the path specified." }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- test_file_to_folder stdout ----
thread 'test_file_to_folder' panicked at src/main.rs:40:10:
Failed to copy from "C:\\Users\\~~~~~\\RustroverProjects\\minimal_copy_problem\\README.md" to "C:\\Users\\~~~~~\\RustroverProjects\\minimal_copy_problem\\target\\test2": Os { code: 5, kind: PermissionDenied, message: "Access is denied." }


failures:
    test_file_to_folder
    test_file_to_folder_with_backslash

test result: FAILED. 1 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass `--bin minimal_copy_problem`

Steps I did take:

  • Enable developer mode
  • Turned on symlinks for git using git config --global core.symlinks true
  • Checked that long paths are enabled in the Registry (although I didn't check the app manifest, if that even exists for cargo)

So my questions are as follows:

  1. Can some of people on Windows with Rust and msvc backend reproduce these issues?
  2. Am I missing some obvious setting that would make it work on my Windows box?

Which bug? I see a reasonable background description but I cannot find a description of the symptom or the error message(s).

1 Like

This one, I forgot to include it, but will update first post.

Running 3 tests
test test_file_to_folder_with_backslash ... FAILED
test test_file_to_folder ... FAILED
test test_file_to_file ... ok

failures:

---- test_file_to_folder_with_backslash stdout ----
dest: "C:\\Users\\~~~~~\\RustroverProjects\\minimal_copy_problem\\target\\test2\\"
thread 'test_file_to_folder_with_backslash' panicked at src/main.rs:62:10:
Failed to copy from "C:\\Users\\~~~~~\\RustroverProjects\\minimal_copy_problem\\README.md" to "C:\\Users\\~~~~~\\RustroverProjects\\minimal_copy_problem\\target\\test2\\": Os { code: 3, kind: NotFound, message: "The system cannot find the path specified." }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- test_file_to_folder stdout ----
thread 'test_file_to_folder' panicked at src/main.rs:40:10:
Failed to copy from "C:\\Users\\~~~~~\\RustroverProjects\\minimal_copy_problem\\README.md" to "C:\\Users\\~~~~~\\RustroverProjects\\minimal_copy_problem\\target\\test2": Os { code: 5, kind: PermissionDenied, message: "Access is denied." }


failures:
    test_file_to_folder
    test_file_to_folder_with_backslash

test result: FAILED. 1 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass `--bin minimal_copy_problem`

If you mean the test failing it seems expected to me, you're trying to create a file at a path that already exists (because you just created a directory there!). If you give std:fs::copy the path to a directory it won't copy the file to inside it.

As for why adding a backslash gives a different error, I don't know.

1 Like