Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Emit shell warning if running outside of all roots
To help make it clear why Cargo may not load all ancestor configs or
find workspace manifests in ancestor directories, Cargo emits a warning:

```
warning: Cargo is running outside of any root directory, limiting
loading of ancestor configs and manifest
```
  • Loading branch information
rib committed Jun 6, 2025
commit d3167edb974e86f0af5395d67d2e7bb070e5e17f
5 changes: 5 additions & 0 deletions src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::collections::HashMap;
use std::ffi::OsStr;
use std::ffi::OsString;
use std::fmt::Write;
use tracing::warn;

use super::commands;
use super::list_commands;
Expand Down Expand Up @@ -132,6 +133,10 @@ pub fn main(gctx: &mut GlobalContext) -> CliResult {
// Reload now that we have established the cwd and root
gctx.reload_cwd()?;

if gctx.find_nearest_root(gctx.cwd())?.is_none() {
gctx.shell().warn("Cargo is running outside of any root directory, limiting loading of ancestor configs and manifest")?;
}

let (expanded_args, global_args) = expand_aliases(gctx, args, vec![])?;

let is_verbose = expanded_args.verbose() > 0;
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ impl GlobalContext {
}
}

fn find_nearest_root<P: AsRef<Path>>(
pub fn find_nearest_root<P: AsRef<Path>>(
&self,
start: P,
) -> CargoResult<Option<(PathBuf, PathBuf)>> {
Expand Down
Loading