Skip to content

warn when cargo subcommand backing binary is not part of the criticalup installation#176

Merged
bors-ferrocene[bot] merged 3 commits into
mainfrom
fix/clippy-not-installed-fallback-to-rustup
May 28, 2026
Merged

warn when cargo subcommand backing binary is not part of the criticalup installation#176
bors-ferrocene[bot] merged 3 commits into
mainfrom
fix/clippy-not-installed-fallback-to-rustup

Conversation

@emig
Copy link
Copy Markdown
Collaborator

@emig emig commented May 21, 2026

Emits a warning if:

  • criticalup run (--strict) cargo clippy is run but cargo-clippy is not installed via criticalup.
  • criticalup run (--strict) cargo fmt is run but rustfmt is not installed via criticalup.

Problem

When clippy is available via rustup, but not installed via Ferrocene, running
criticalup run cargo clippy will fallback to using rustup's installed clippy , potentially resulting in crates compiled with an incompatible version of rustc (compared to the version clippy was compiled with).

Replication steps

  1. Install rustup stable
  2. install Ferrocene packages via criticalup, with the following configuration, which doesn't include clippy
manifest-version = 1

[products.ferrocene]
release = "stable-25.08.0"
packages = [
    "cargo-${rustc-host}",
    "rustc-${rustc-host}",
    "rustfmt-${rustc-host}",
    "rust-std-${rustc-host}",
]  
  1. Run criticalup run (--strict) cargo clippy

The compiler complains of having libraries compiled with an incompatible rustc version

error[E0514]: found crate `elliptic_curve` compiled by an incompatible version of rustc                                        
 --> crates/criticaltrust/src/keys/algorithms/ecdsa_p256_sha256_asn1_spki_der.rs:7:5                                           
  |                                                                                                                                                                                                                                                           
7 | use elliptic_curve::pkcs8::{DecodePrivateKey, DecodePublicKey, EncodePrivateKey, EncodePublicKey};
  |     ^^^^^^^^^^^^^^                                                                                                         
  |                                                                                                                                                                                                                                                           
  = note: the following crate versions were found:                                                                                                                                                                                                            
          crate `elliptic_curve` compiled by rustc 1.88.0 (4a1d753a8 2025-09-29) (Ferrocene by Ferrous Systems): /home/emir/Github/ferrocene/public/criticalup/target/debug/deps/libelliptic_curve-a7d5321835367b5b.rmeta                                     
  = help: please recompile that crate using this compiler (rustc 1.93.1 (01f6ddf75 2026-02-11)) (consider running `cargo clean` first)  

How to test this PR

  1. Follow the mentioned replication steps
  2. With this PR changes the following warning is expected:

WARN 'cargo-clippy' is not installed for this project, and may run from binaries outside the criticalup installation.
To prevent this, please make sure that the correct package for 'cargo-clippy' is listed in the packages section of your
project's criticalup.toml and run 'criticalup install' command again.

Note: In this example, if criticalup is linked as a rustup toolchain and used (is active), both a warning and an actual error will be returned. The later is due to the cargo-clippy binary missing in the path

Fixes the test by passing the path to the configuration in the temporary
folder.

Remove ignore flag.

Other tests will be added later based on this test.
@emig emig force-pushed the fix/clippy-not-installed-fallback-to-rustup branch 3 times, most recently from 968b2c6 to 0e83243 Compare May 22, 2026 12:07
Backing binary is a binary used by a cargo subcommand. It is resolved
from PATH.

If ARG is `clippy` or `fmt` and is called via the `criticalup run cargo (--strict) <ARG>` and
its backing binary is not present in the criticalup installation
emits an warning indicating the package is missing from the
criticalup installation.
@emig emig changed the title fix/clippy not installed fallback to rustup warn when cargo subcommand backing binary is not part of the criticalup installation May 22, 2026
@emig emig force-pushed the fix/clippy-not-installed-fallback-to-rustup branch from 0e83243 to 2887714 Compare May 22, 2026 12:44
@emig emig requested review from Hoverbear and dotcarmen May 22, 2026 12:45
@emig emig marked this pull request as ready for review May 22, 2026 12:48
@emig emig requested a review from Xylakant May 22, 2026 12:48
Hoverbear
Hoverbear previously approved these changes May 22, 2026
@emig
Copy link
Copy Markdown
Collaborator Author

emig commented May 26, 2026

bors try

bors-ferrocene Bot added a commit that referenced this pull request May 26, 2026
@bors-ferrocene
Copy link
Copy Markdown
Contributor

try

Build failed:

@emig
Copy link
Copy Markdown
Collaborator Author

emig commented May 26, 2026

bors try

bors-ferrocene Bot added a commit that referenced this pull request May 26, 2026
@bors-ferrocene
Copy link
Copy Markdown
Contributor

try

Build failed:

@emig
Copy link
Copy Markdown
Collaborator Author

emig commented May 26, 2026

bors try

bors-ferrocene Bot added a commit that referenced this pull request May 26, 2026
@emig
Copy link
Copy Markdown
Collaborator Author

emig commented May 26, 2026

bors try

@bors-ferrocene
Copy link
Copy Markdown
Contributor

try

Already running a review

@emig
Copy link
Copy Markdown
Collaborator Author

emig commented May 26, 2026

bors cancel

@emig
Copy link
Copy Markdown
Collaborator Author

emig commented May 26, 2026

bors try

@bors-ferrocene
Copy link
Copy Markdown
Contributor

try

Already running a review

@bors-ferrocene
Copy link
Copy Markdown
Contributor

try

Timed out.

@emig
Copy link
Copy Markdown
Collaborator Author

emig commented May 26, 2026

bors try

bors-ferrocene Bot added a commit that referenced this pull request May 26, 2026
@bors-ferrocene
Copy link
Copy Markdown
Contributor

try

Build failed:

@emig
Copy link
Copy Markdown
Collaborator Author

emig commented May 26, 2026

bors try

bors-ferrocene Bot added a commit that referenced this pull request May 26, 2026
@bors-ferrocene
Copy link
Copy Markdown
Contributor

try

Build failed:

@emig
Copy link
Copy Markdown
Collaborator Author

emig commented May 26, 2026

bors try

bors-ferrocene Bot added a commit that referenced this pull request May 26, 2026
@bors-ferrocene
Copy link
Copy Markdown
Contributor

try

Build failed:

Comment on lines +128 to +134
if let Some(backing_binary) = cargo_subcommand_map.get(arg.as_str()) {
if !bin_paths.iter().any(|x| x.join(backing_binary).exists()) {
tracing::warn!("'{0}' is not installed for this project, and may run from binaries outside the criticalup installation.\n \
To prevent this, please make sure that the correct package for '{0}' is listed in the packages section of your \n\
project's criticalup.toml and run 'criticalup install' command again.\n", backing_binary);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry if this has already been discussed

  1. do we instruct users to always use criticalup run cargo ...? if not, then maybe the better solution is shimming cargo to detect this problem, which would allow cargo fmt in a ferrocene project to raise this warning
  2. another approach is to install shims for these tools unless requested. the shims will print this message and run the fallback component (is there a tool we can ask to resolve this?). when the user specifically requests the component, then we can provide our installation of the tool

Copy link
Copy Markdown
Collaborator Author

@emig emig May 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We document 3 ways of running Ferrocene packages . Only if you run criticalup run cargo subcommand it is possible to use inadvertently a non Ferrocene distributed binary called by the sub-command. The current set of sub-commands affected are clippy and fmt. The current solution has small footprint, and we can revisit it in case we need to manage an increasing number of cases

@emig
Copy link
Copy Markdown
Collaborator Author

emig commented May 26, 2026

bors try

bors-ferrocene Bot added a commit that referenced this pull request May 26, 2026
@bors-ferrocene
Copy link
Copy Markdown
Contributor

try

Build failed:

@emig emig force-pushed the fix/clippy-not-installed-fallback-to-rustup branch from bd07850 to 5b01659 Compare May 26, 2026 13:21
@emig
Copy link
Copy Markdown
Collaborator Author

emig commented May 26, 2026

bors try

bors-ferrocene Bot added a commit that referenced this pull request May 26, 2026
@bors-ferrocene
Copy link
Copy Markdown
Contributor

try

Build succeeded:

@emig emig requested a review from Hoverbear May 27, 2026 07:57
Copy link
Copy Markdown

@dotcarmen dotcarmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@emig
Copy link
Copy Markdown
Collaborator Author

emig commented May 28, 2026

bors merge

@bors-ferrocene
Copy link
Copy Markdown
Contributor

Build succeeded:

  • CI build successful

@bors-ferrocene bors-ferrocene Bot merged commit a5a9994 into main May 28, 2026
1 check passed
@bors-ferrocene bors-ferrocene Bot deleted the fix/clippy-not-installed-fallback-to-rustup branch May 28, 2026 06:56
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

Successfully merging this pull request may close these issues.

3 participants