-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Ability to specify CARGO_HOME via file #6452
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
Comments
One can use |
@lukaslueg Docker images has no |
I suppose the tricky part here is that by changing # ~/.cargo/config
home = "/path/to/a"
[build]
target = "foo" Now imagine you invoke One way to get around this is to have cargo home no be set in the normal configuration files, but instead with a different file under |
This patch allows users to set the Cargo home directory through the file system using a pointer file in `.cargo/home`. As with `.cargo/config`, the file is searched for recursively up the tree from the current working directory. Unlike with `.cargo/config`, the search terminates when a matching file is found. The search for `.cargo/home` happens before any `.cargo/config` files are read, as that may be affected by the choice of Cargo home directory. The `CARGO_HOME` environment variable is preferred over `.cargo/home`. Fixes rust-lang#6452.
I filed a PR that implements the |
In light of https://internals.rust-lang.org/t/pre-rfc-split-cargo-home/19747, I assume what would be wanted is |
Describe the problem you are trying to solve
Currently, the
$CARGO_HOME
env var may be set to specify the location of cargo "caches" (fetched crates, binaries installed, etc). When we do not want to use the global one, we can override this for local project by providing directly tocargo
commands:While this works OK, it's still not ergonomic enough for certain situations. For example:
I'm developing HTTP daemon and using Docker. I want
$CARGO_HOME
being reused both for normal builds in terminal or IDE (viacargo build
) and for those ones insideDockerfile
. This makes me:CARGO_HOME=.cache/cargo
for every command (not very handy);export CARGO_HOME=.cache/cargo
each time I'm opening terminal for this project (as I cannot set it globally);docker build
.The problem with
docker build
that I cannot pass arbitrary directory to the build context, only those dirs which are inside cwd. So, I should persist$CARGO_HOME
inside my project root and do it only when using this project specifically. I want no bothering and just runcargo build
ordocker build
without any crates refetches.Describe the solution you'd like
Simply allow to override the
$CARGO_HOME
for the current directory with some sort of configuration file: either.cargo/config
, orCargo.toml
. It will allow to declare the desired value once and just don't bother, while playing well with bothcargo build
/docker build
experiences at the same time.The feature is not new and already exists in package managers for other languages. For example, I can specify the packages cache folder in:
.yarnrc
/.npmrc
file for Yarn/NPM;composer.json
for Composer.The text was updated successfully, but these errors were encountered: