Skip to content

Why I got error 102 in makefile when running nextest. #2246

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

Closed
BraveY opened this issue Mar 21, 2025 · 14 comments
Closed

Why I got error 102 in makefile when running nextest. #2246

BraveY opened this issue Mar 21, 2025 · 14 comments

Comments

@BraveY
Copy link

BraveY commented Mar 21, 2025

This action works successfully on Wed, 12 Mar 2025 03:14:50 GMT.
But it failed on 13 Mar, in this aciton workflow, I got following error:

TEST_WORKDIR_PREFIX="/tmp" RUST_BACKTRACE=1 /home/runner/.cargo/bin/cargo nextest run --no-fail-fast --filter-expr 'test(test) - test(integration)' --workspace  --features=virtiofs --release --test-threads 8
make: *** [Makefile:[11](https://github.com/dragonflyoss/nydus/actions/runs/13826281977/job/38681749367#step:6:12)1: ut-nextest] Error 102
Error: Process completed with exit code 2.

I am wondering why I got Error 102? Is there any updates on 13 Mar caused the error? Since there is no update in our program between 12 Mar and 13 Mar.

This docs say Error 102 is Running cargo metadata produced an error. But it is ok, when i add command cargo metadata in smoke test.

And when i run the test command TEST_WORKDIR_PREFIX="/tmp" RUST_BACKTRACE=1 /home/runner/.cargo/bin/cargo nextest run --no-fail-fast --filter-expr 'test(test) - test(integration)' --workspace --features=virtiofs --release --test-threads 8 in smoke directly, i got the output as expected.

The makefile is here. And the related part is fllowing:

# you need install cargo nextest first from: https://nexte.st/book/pre-built-binaries.html
ut-nextest: .release_version
	TEST_WORKDIR_PREFIX=$(TEST_WORKDIR_PREFIX) RUST_BACKTRACE=1 ${CARGO} nextest run --no-fail-fast --filter-expr 'test(test) - test(integration)' --workspace $(EXCLUDE_PACKAGES) $(CARGO_COMMON) $(CARGO_BUILD_FLAGS) --test-threads 8

Originally posted by @BraveY in #2245

@sunshowers
Copy link
Member

sunshowers commented Mar 24, 2025

Thanks. That's strange. Do you have any other output (stdout/stderr) available? Generally nextest will produce output to stderr if something goes wrong -- are you squelching it?

Looking at

Self::CargoMetadataExecFailed { .. }
| Self::CargoMetadataFailed { .. }
| Self::CargoLocateProjectExecFailed { .. }
| Self::CargoLocateProjectFailed { .. } => NextestExitCode::CARGO_METADATA_FAILED,
, it looks like we also produce 102 if cargo locate-project failed. But we should print something to stderr no matter what. An example with a nextest patched so cargo metadata fails:

% cargo nextest r --workspace
error: no such command: `metadata2`

	Did you mean `metadata`?

	View all installed commands with `cargo --list`
	Find a package to install `metadata2` with `cargo search cargo-metadata2`

Also -- can you reproduce this locally? If not, can you ssh into the runner and try it out? You can use something like https://github.com/marketplace/actions/debugging-with-ssh.

@sunshowers
Copy link
Member

sunshowers commented Mar 24, 2025

Ahhh so it turns out nextest doesn't produce any output of its own, instead delegating to Cargo. If your Cargo is broken, nextest won't produce anything. That's misleading (nextest should print something). But I think the issue is with your installation of cargo.

sunshowers added a commit that referenced this issue Mar 24, 2025
Sometimes, `cargo` doesn't produce any output whatsoever (e.g. #2246). Always show something to indicate what command's at fault.
sunshowers added a commit that referenced this issue Mar 24, 2025
Sometimes, `cargo` doesn't produce any output whatsoever (e.g. #2246).
Always show something to indicate what command's at fault.
@sunshowers
Copy link
Member

I've just released cargo-nextest 0.9.93 which improves reporting here, and will tell you which command failed to run. This won't fix your issue but it will hopefully help you diagnose it.

Thanks again for reporting the issue!

@BraveY
Copy link
Author

BraveY commented Mar 25, 2025

I've just released cargo-nextest 0.9.93 which improves reporting here, and will tell you which command failed to run. This won't fix your issue but it will hopefully help you diagnose it.

Thanks again for reporting the issue!

Thanks a lot !!! Now i got the failed command after runing /home/runner/.cargo/bin/cargo nextest list -v --cargo-verbose

error: command `/home/runner/.cargo/bin/rustup metadata '--format-version=1' --all-features --filter-platform x86_64-unknown-linux-gnu` failed with exit status: 1

I'm still working on it to figure out why this command failed run after running make.

It should be cargo metadata instead of rustup metadata.

@BraveY
Copy link
Author

BraveY commented Mar 25, 2025

I think the new release of rustup v1.28's PR rust-lang/rustup#4022 where cargo-home/bin/cargo is symlinked to cargo-home/bin/rustup caused this problem. Please see the detail in rust-lang/rustwide#94 and rust-lang/rustup#4224.

@BraveY
Copy link
Author

BraveY commented Mar 25, 2025

BTW, I fixed the broken CI in our acitons by running ${RUSTUP} run stable cargo nextest run instead of ${CARGO} nextest run.

@ChrisDenton
Copy link

Sorry, I've only briefly investigated this. However I don't believe nextest is at fault.

I think the issue is that if you set the CARGO environment variable then cargo may replace it with the canonicalized version in some circumstances (i.e. with the symlinks resolved).

BTW, I fixed the broken CI in our acitons by running ${RUSTUP} run stable cargo nextest run instead of ${CARGO} nextest run.

Another possible workaround is to try setting CARGO to the output of rustup which cargo. This will point to the real cargo's location instead of the rustup shim.

@ChrisDenton
Copy link

Ultimately the fix will need to come from cargo and rustup. I don't think there's much nextest can do. Well, I guess one hack would be to check if the CARGO environment variable ends with rustup[.exe] and replacing it with cargo[.exe] if so. But that doesn't exactly fill me with joy.

@BraveY
Copy link
Author

BraveY commented Mar 27, 2025

Sorry, I've only briefly investigated this. However I don't believe nextest is at fault.

I think the issue is that if you set the CARGO environment variable then cargo may replace it with the canonicalized version in some circumstances (i.e. with the symlinks resolved).

BTW, I fixed the broken CI in our acitons by running ${RUSTUP} run stable cargo nextest run instead of ${CARGO} nextest run.

Another possible workaround is to try setting CARGO to the output of rustup which cargo. This will point to the real cargo's location instead of the rustup shim.

I have tried rustup which cargo before, but i got another error about rustc.

@BraveY
Copy link
Author

BraveY commented Mar 27, 2025

If there is nothing nextest can do, feel free to close this issue. And let's wait rustup to fix it.

@ChrisDenton
Copy link

I've done a bit more investigating today and I'm pretty confident the reason for this I gave above is accurate. If the CARGO environment is set (and only if) then cargo will it with the canonicalized path when calling sub-processes (this is a bug). nextest very reasonably assumes the CARGO environment variable contains a path to cargo. However, if the path CARGO was initially set to is a symlink to rustup then it will be canonicalised to rustup instead.

Other than the workaround you implemented, some possible workarounds I tried:

nextest could treat the CARGO variable as being "cargo or rustup". But that's trickier to handle. And the environment variable is used is a fair few places: https://github.com/search?q=repo%3Anextest-rs%2Fnextest%20%2F(%3F-i)%22CARGO%22%2F&type=code

@sunshowers
Copy link
Member

sunshowers commented Mar 27, 2025

Thanks for the investigation! Is the issue that nextest is canonicalizing the Cargo path and dereferencing symlinks (which wouldn't quite work with a multicall binary like rustup, I think)? I don't think it did but maybe it does.

@ChrisDenton
Copy link

No, nextest isn't doing anything wrong here. It's a Cargo bug that happens in specific circumstances.

@sunshowers
Copy link
Member

Thanks. Closing this out then.

@sunshowers sunshowers closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants