You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resolve separate roots for config and manifest searches
It's no longer assumed that we can resolve a single stop_at_root path
for both finding config files and manifests.
GlobalContext now maintains a sorted list of user-configured roots and
caches two resolved SearchRoutes; one for loading config files, the
other for manifests (both automatically invalidated if roots are added
or start paths change).
A `SearchRoute` represents a starting directory and the closest
root directory, where parent traversal will stop.
If searching starts from outside of all configured roots then no
ancestor traversal is allowed.
- This is a safety measure to reduce the risk of loading unsafe config
files that aren't owned by the user (e.g. under `c:/.cargo` on
Windows or `/tmp` on Linux)
By default the user's home directory is added as a root if CARGO_ROOTS
is not set.
- Combined with the rule above, this means that Cargo has safe defaults
and will not load configs outside of your home directory, unless you
explicitly set CARGO_ROOTS.
- This is also a measure to avoid triggering home directory
automounters
TODO: there still needs to be a special case for loading a project
manifest, before searching for a workspace. Cargo should be allowed to
walk ancestors outside of all configured roots, when loading the first
Cargo.toml. In this case the directory of the manifest should
immediately be set as a root. This would be a safety / ergonomics
trade-off to allow building of crates under `/tmp/package/nested/dir`
but still disallow attempts to load `/tmp/Cargo.toml` as a workspace.
TODO: Cargo should log a warning when searching for files outside of
any root, so it's easy to see why ancestor config files or manifests
are not being loaded.
0 commit comments