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

[replace] doesn't replace in rustBuildPackage #22177

Open
P-E-Meunier opened this issue Jan 26, 2017 · 7 comments
Open

[replace] doesn't replace in rustBuildPackage #22177

P-E-Meunier opened this issue Jan 26, 2017 · 7 comments

Comments

@P-E-Meunier
Copy link
Contributor

Issue description

The [replace] section of Cargo.toml is not handled by buildRustPackage, which issues the following warning (in my case, when replacing package ring:0.6.2 with a local version):

warning: package replacement is not used: https://github.com/rust-lang/crates.io-index#ring:0.6.2

That section can be used to override a package with some locally fixed package.

This is not a big problem until one tries to quickly fix a bug in a dependency and nixops it into production.

Steps to reproduce

Create a crate with the following src/main.rs:

extern crate ring;
fn main() {}

Clone http://github.com/briansmith/ring at the root of the crate.
And the following lines in Cargo.toml:

ring = "0.6.2"

[replace]
ring:0.6.2 = { path = "ring" }

Now package it with rustBuildPackage. The replacement is ignored.

Technical details

  • System: (NixOS: nixos-version, Ubuntu/Fedora: lsb_release -a, ...)
    16.09.1515.89c567c (Flounder)

  • Nix version: (run nix-env --version)
    nix-env (Nix) 1.11.6

  • Nixpkgs version: (run nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion)
    17.03pre-git

@P-E-Meunier P-E-Meunier changed the title [replace] doesn't replace [replace] doesn't replace in rustBuildPackage Jan 26, 2017
@wizeman
Copy link
Member

wizeman commented Jan 27, 2017

I think this is not a bug in rustBuildPackage, but rather in your Cargo.toml or in cargo.

Are you sure you are specifying the version inside the [replace] section correctly?

You can check if the version is correct with cargo pkgid ring.

If you specified the version correctly, you can try instead to put the output of cargo pkgid ring as the package version to replace inside the [replace] section (as an https:// link). This should work and get rid of the warning, according to servo/servo#14688.

Alternatively, and this may require a lot more work, you can try to either switch to the unstable branch of nixpkgs/NixOS, or to backport all the Rust-related changes in the unstable branch to your own local git checkout of the stable branch.

I have done the latter some time ago and I was able to successfully build the package as you specified in your "steps to reproduce" section (although, I had to add a default.nix file, add quotes around ring:0.6.2, and I also had to bump ring to version 0.6.3, because cargo insisted I use that version, for some reason).

@wizeman
Copy link
Member

wizeman commented Jan 27, 2017

It occurred to me that you could check a couple of additional issues:

  1. Verify whether Nix is actually picking up any changes you have made to Cargo.toml, or the git checkout in $project_dir/ring - sometimes it's easy to forget to do a git commit, generate a tarball or whatever is necessary for Nix to pick up the changes.
  2. From your description, it wasn't clear to me whether you tried to verify that you could build the package successfully without rustBuildPackage. If you can build it by manually doing cargo fetch and/or cargo build, that is another indication that the problem is not in rustBuildPackage.

@P-E-Meunier
Copy link
Contributor Author

Are you sure you are specifying the version inside the [replace] section correctly?

Yes, because cargo build is able to handle it correctly, in a nix-shell with the same versions of everything as my rustBuildPackage.

you can try to either switch to the unstable branch of nixpkgs/NixOS, or to backport all the Rust-related changes in the unstable branch to your own local git checkout of the stable branch.

I'm working on a modified local checkout of nixpkgs, and I tried this both with my own rustup nightly fetcher, and the one in NixOS unstable.

My problem is, my project requires Rust nightly, and ring 0.6.2 stopped building on nightly this week (I could build it with rustup from January 22nd).

@aakropotkin
Copy link
Contributor

I am having the same issue trying to make a package for "spotifyd"
Cargo fails as a result of multiple "rust-crypto" sources.
Did you ever find a solution?

@stale
Copy link

stale bot commented Jun 4, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 4, 2020
@dmadisetti
Copy link
Contributor

replace now crashes the build with a bad symlink

error: builder for '/nix/store/g5k2iq1gn2bw7c967dx2g6hjj2ahdil4-cargo-vendor-dir.drv' failed with exit code 1;
       last 1 log lines:
       > ln: failed to create symbolic link '/nix/store/dshpabbp5irzg2001fg5kj1spngb0260-cargo-vendor-dir/rnix-0.10.1/y4xbapipnj4vpp7b24srw43scnl5k62m-rnix-0.10.1': Permission denied
       For full logs, run 'nix log /nix/store/g5k2iq1gn2bw7c967dx2g6hjj2ahdil4-cargo-vendor-dir.drv'.

Full log is just the same line

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 24, 2022
ghost pushed a commit to rivosinc/hubris that referenced this issue Nov 3, 2022
While a theoretically awesome tool, Nix has demonstrated a pair of
extremely deleterious shortcomings that appear to be not considered
important by the Nix Community.

Specifically:
- Nix relies on the manual entry of input hashes for Cargo
  dependencies. This is extraordinarily cumbersome, and causes
  build failures on any dependency change. There was a suggestion
  to get this information automatically, but this has been stalled
  since 2019 (over 3 years, at the time of this commit):
  NixOS/nixpkgs#63653

- Nix appears to be unable to handle multiple versions of Rust
  packages gracefully. The result is unexpected and uncommunicative
  failures, such as a failure to generate a symlink. This class of
  failure was first reported in 2017 (over 5 years ago, at the time
  of this commit):
  NixOS/nixpkgs#22177

As a result, I do not believe that Nix can offer us a reliable
platform for CI of Hubris at this time. As observed on #46,
attempting to appease Nix can result in significant crate changes
to facilitate single revision jumps - consuming days of effort to
validate a change that is essentially operational.
ghost pushed a commit to rivosinc/hubris that referenced this issue Nov 4, 2022
While a theoretically awesome tool, Nix has demonstrated a pair of
extremely deleterious shortcomings that appear to be not considered
important by the Nix Community.

Specifically:
- Nix relies on the manual entry of input hashes for Cargo
  dependencies. This is extraordinarily cumbersome, and causes
  build failures on any dependency change. There was a suggestion
  to get this information automatically, but this has been stalled
  since 2019 (over 3 years, at the time of this commit):
  NixOS/nixpkgs#63653

- Nix appears to be unable to handle multiple versions of Rust
  packages gracefully. The result is unexpected and uncommunicative
  failures, such as a failure to generate a symlink. This class of
  failure was first reported in 2017 (over 5 years ago, at the time
  of this commit):
  NixOS/nixpkgs#22177

As a result, I do not believe that Nix can offer us a reliable
platform for CI of Hubris at this time. As observed on #46,
attempting to appease Nix can result in significant crate changes
to facilitate single revision jumps - consuming days of effort to
validate a change that is essentially operational.
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/rust-with-git-deps-symbolic-link-error-to-cargo-vendor-dep/28841/1

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

5 participants