bazelbuild / bazelbuild/rules_rust

inconsistent isolation protection: global Cargo config file interpreted as directory-local config on Windows

Open
#2,285 0 comments 0 reactions 0 assignees View on GitHub
bug crate-universe needs-triage
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

A trivial bazel rules_rust setup, with a non-empty ~/.cargo/config.toml is handled differently on Windows and Linux.

On Windows we have the following structure:
~/.cargo/config.toml = C:/Users/\
~/src/bazelworkspace = C:/Users/\/src/bazelworkspace
TMP/TEMP = C:/Users//AppData/Local/Temp

On Linux the following structure:
~/.cargo/config.toml = /home/\
~/src/bazelworkspace = /home/\/src/bazelworkspace
TMP/TEMP = /tmp

This error https://github.com/bazelbuild/rules_rust/blob/b96e37ecf435d032435ad66f547a6599a16467d2/crate_universe/src/splicing/splicer.rs#L393-L395

is generated when running `CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index` on Windows, but not on Linux.

But the setup, and the leaking of global configuration, is identical.

I'm not sure which way the project would like to take this - but right now on Linux isolation violation in this way is not detected, and doesn't generate errors... to me that its on rules_rust to ensure isolation rather than pushing it back onto the user. Perhaps using https://doc.rust-lang.org/cargo/reference/environment-variables.html#configuration-environment-variables to increase isolation.

As a user, I'd like to be able to work on Cargo only projects, and Bazel ones, without having to switch my global configuration on and off. I'd be ok with occasional mistakes that CI has to catch for me, as a tradeoff. That is, downgrading this to a warning would be ok for me.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.