Skip to content
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

buildRustPackage fails with cargo 0.10.0 #15767

Closed
the-kenny opened this issue May 28, 2016 · 6 comments
Closed

buildRustPackage fails with cargo 0.10.0 #15767

the-kenny opened this issue May 28, 2016 · 6 comments
Assignees

Comments

@the-kenny
Copy link
Contributor

the-kenny commented May 28, 2016

Issue description

buildRustPackage fails with cargo-0.10.0. I located two issues:

  • Cargo tries to create a lockfile in $CARGO_HOME/registry/index/$indexHash/.cargo-index.lock

This is easily fixed by creating a symlink-tree instead of linking $indexHash to the nix-store directly.

  • Cargo tries to fetch the registry from file:///dev/null

I don't seem to be able to track this one down. See the following output (with RUST_LOG=debug set):

these derivations will be built:
  /nix/store/xmhh0dypjnhcd49ykss8c3x4bxjvp9xi-rustfmt-0.4.drv
building path(s) ‘/nix/store/dlch40w9lvia203zyk8qnqn8mh97m7lf-rustfmt-0.4’
unpacking sources
unpacking source archive /nix/store/i0q0g2fg3xhhzcyv4y95gh74zkn9j2gc-rustfmt-19768da5c97c108a05e6f545b73ba4b76d1b1788-src
source root is rustfmt-19768da5c97c108a05e6f545b73ba4b76d1b1788-src
Using cargo deps from /nix/store/k3mxzp6n0sp4bszhklp02y8g2vrrb2zs-rustfmt-0.4-fetch
Using indexHash '-2304f9dd481834b8'
DEBUG:cargo::core::registry: load/missing  file:///tmp/nix-build-rustfmt-0.4.drv-0/rustfmt-19768da5c97c108a05e6f545b73ba4b76d1b1788-src
DEBUG:cargo::core::registry: load/missing  registry file:///dev/null
    Updating registry `file:///dev/null`
DEBUG:cargo: handle_error; err=CliError { error: ChainedError { error: failed to fetch `file:///dev/null`, cause: Error { code: -1, klass: 6, message: "Could not find repository from \'/dev/null\'" } }, unknown:
true, exit_code: 101 }
error: An unknown error occurred

The source for rustfmt is at /tmp/nix-build-rustfmt-0.4.drv-0/rustfmt-19768da5c97c108a05e6f545b73ba4b76d1b1788-src - I don't know why cargo thinks it's missing. Looking at the implementation of cargo (registry.rs:93) doesn't really help.

Steps to reproduce

git clone git@github.com:the-kenny/nixpkgs.git --branch rust-cargo-0.10.0
cd nixpkgs
nix-build . -A rustfmt
@the-kenny the-kenny self-assigned this May 28, 2016
@dvc94ch
Copy link
Contributor

dvc94ch commented May 28, 2016

This worked for me:

runCommand "rustRegistry-${version}-${builtins.substring 0 7 rev}" { inherit src; } ''
  # For some reason, cargo doesn't like fetchgit's git repositories, not even
  # if we set leaveDotGit to true, set the fetchgit branch to 'master' and clone
  # the repository (tested with registry rev
  # 965b634156cc5c6f10c7a458392bfd6f27436e7e), failing with the message:
  #
  # "Target OID for the reference doesn't exist on the repository"
  #
  # So we'll just have to create a new git repository from scratch with the
  # contents downloaded with fetchgit...

  mkdir -p $out

  cp -r ${src}/* $out/

  cd $out

  git="${git}/bin/git"

  $git init
  $git config --local user.email "example@example.com"
  $git config --local user.name "example"
  $git add .
  $git commit -m 'Rust registry commit'

  touch $out/touch . "$out/.cargo-index-lock"
''

@the-kenny
Copy link
Contributor Author

@dvc94ch I'll give it a try, thanks.

@the-kenny
Copy link
Contributor Author

Looks good - I'll test a bit more and push it if everything works.

@the-kenny
Copy link
Contributor Author

Just a note: Before merging I'd like to give rust-lang/cargo#2361 a try and see if we can use it. Might be a cleaner and upstream-supported solution.

@the-kenny
Copy link
Contributor Author

Pushed the updates with the workaround shown above. They seem to work fine with the packages rust tools and my personal packages.

@dvc94ch
Copy link
Contributor

dvc94ch commented May 28, 2016

unrelated question, if you're not too busy, do you mind merging my PR #15606? :) It would be greatly appreciated...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants