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

rust_doc_test failing with "Failed to load argument file" #1233

Closed
UebelAndre opened this issue Mar 29, 2022 · 5 comments · Fixed by #1418
Closed

rust_doc_test failing with "Failed to load argument file" #1233

UebelAndre opened this issue Mar 29, 2022 · 5 comments · Fixed by #1418

Comments

@UebelAndre
Copy link
Collaborator

UebelAndre commented Mar 29, 2022

I'm not entirely sure when this started occurring but I'm seeing the following error in some rust_doc_test targets

==================== Test output for //:rustdoc_test:
error: Failed to load argument file: IO Error: rustdoc_test.rustdoc_test.sh-0.params: No such file or directory (os error 2)

================================================================================

Through some bisecting I found the change in behavior to happen between bbccf77 and c435cf4 but that delta doesn't make much sense to me since neither of these commits look like they'd impact this behavior. Perhaps the error message is not deterministic. This also no longer seems to happen for hosts other than windows. More info is needed.

@tp-woven
Copy link

tp-woven commented Apr 8, 2022

In case it helps, we're also seeing this error, on both Linux and MacOS.

@UebelAndre
Copy link
Collaborator Author

In case it helps, we're also seeing this error, on both Linux and MacOS.

Could you share what commit of rules_rust you started seeing this on?

@UebelAndre
Copy link
Collaborator Author

I also hit this error in #1252. Since the //crates_universe:rustdoc_test target worked before that change on MacOS, it can hopefully reveal the root cause of this issue.

@tp-woven
Copy link

In case it helps, we're also seeing this error, on both Linux and MacOS.

Could you share what commit of rules_rust you started seeing this on?

We're on ea22478f6dac4604b4ef38fb8e713cd1c0880084. This is the first time we're trying to use this rule in our repo, so we don't have "good" commits where this is working.

@fmorency
Copy link
Contributor

I'm also noticing the issue on the project I'm porting to Bazel

error: Failed to load argument file: IO Error: src/many/many_doc_test.rustdoc_test.sh-0.params: No such file or directory (os error 2)

I'm using rules_rust git e83d5f3 on Linux.

illicitonion pushed a commit that referenced this issue Aug 1, 2022
**Context**
Today `rust_doc_test` fails when Bazel [Args](https://docs.bazel.build/versions/main/skylark/lib/Args.html) "spill" over to a file. To a user this failure is seemingly random because Bazel will auto-magically spill `Args` onto a file when there are too many args for the command line, or when it can improve performance. The generated test script, e.g. `hellolib.rustdoc_test.sh`, is then run from runfiles, which is separate from the Arg file Bazel created.

It's especially tricky because the amount of command line args Windows supports is < macOS < Linux, so there's a "silent" OS dependency here too.

**Solution**
This PR fixes the issue by manually declaring a params file, e.g. `hellolib.rustdoc_opt_params`, that is a sibling file to our test runner, `hellolib.rustdoc_test.sh`. We then pass the path of this optional params file to our test writer. The test writer checks for the presence of the Bazel Args file, and if it finds one, copies the content into our manually declared params file. 

Our manually declared params file then gets moved into runfiles with our test script. The test script can then find the file, and `rustdoc` picks up the args.

Note: Today we detect the params file by matching a prefix of `@` and suffix of `.rustdoc_test.sh-0.params`. I'm not sure if this is accurate for all systems, or all versions of bazel. I tried the [`use_param_file`](https://docs.bazel.build/versions/main/skylark/lib/Args.html#use_param_file) option on `Args` to make it easier to detect a params file, but that seem to overwrite (or just generally effect) the other arguments we'd pass to `rustdoc_test_writer.rs`.

Fixes #1233
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants