Skip to content

Pass CARGO_HOME on more invocations of cargo#61194

Closed
glasserc wants to merge 1 commit into
NixOS:masterfrom
glasserc:cargo-nightly
Closed

Pass CARGO_HOME on more invocations of cargo#61194
glasserc wants to merge 1 commit into
NixOS:masterfrom
glasserc:cargo-nightly

Conversation

@glasserc

@glasserc glasserc commented May 9, 2019

Copy link
Copy Markdown
Contributor

Fixes #61192.

Motivation for this change

Although this failure only occurs when using Cargo nightly, which isn't actually packaged here yet, this will eventually become a problem when nightly becomes stable.

I'm not really sure that this is the right place for this change. Is the existing absence of CARGO_HOME meant to flush out reproducibility failures when cargo tries to download a package? Or was it just because previously cargo didn't need to do anything in the build or test phases so it wasn't necessary?

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@ofborg ofborg Bot added 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. labels May 9, 2019
@samlich

samlich commented May 31, 2019

Copy link
Copy Markdown
Contributor

I lost the log, but I had an issue compiling cargo with it set to $(pwd) as it used two different directories at different times, using $TMPDIR worked.
It also needs to be set for the rustc compilation.

--- a/pkgs/development/compilers/rust/rustc.nix
+++ b/pkgs/development/compilers/rust/rustc.nix
@@ -54,6 +54,8 @@ in stdenv.mkDerivation rec {
   # Increase codegen units to introduce parallelism within the compiler.
   RUSTFLAGS = "-Ccodegen-units=10";

+  # Cargo creates locks in `$CARGO_HOME/.cargo/.package-cache`, which must be writeable
+  CARGO_HOME = "$TMPDIR";
+
   # We need rust to build rust. If we don't provide it, configure will try to download it.

@FRidh

FRidh commented Jun 18, 2019

Copy link
Copy Markdown
Member

Please cc the Nixpkgs maintainers of cargo/rust in order to get this further.

@glasserc

glasserc commented Aug 2, 2019

Copy link
Copy Markdown
Contributor Author

I'm not sure who that is, but based on commit history, maybe it's @Mic92 or @Ericson2314 ?

@samlich

samlich commented Aug 2, 2019

Copy link
Copy Markdown
Contributor

btw this may be fixed by rust-lang/cargo#7149
If it doesn't, I think they do want to fix it upstream.

checkPhase = args.checkPhase or ''
runHook preCheck
echo "Running cargo test"
export CARGO_HOME=$(pwd)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would rather set it to $TMPDIR though. And it only needs to be set once - maybe in the configurePhase?

@samlich

samlich commented Aug 8, 2019

Copy link
Copy Markdown
Contributor

With nightly 2019-08-06 built with beta 2019-08-06, I no longer have this issue.

@Mic92 Mic92 mentioned this pull request Aug 14, 2019
10 tasks
@Mic92

Mic92 commented Aug 16, 2019

Copy link
Copy Markdown
Member

This should be covered by the following commit: 3372343

@glasserc

Copy link
Copy Markdown
Contributor Author

I think so too!

@glasserc glasserc closed this Dec 25, 2019
@glasserc
glasserc deleted the cargo-nightly branch December 25, 2019 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failing to build packages with Cargo nightly

4 participants