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

Xargo does not work with rust-src #51

Closed
joepie91 opened this issue Jul 26, 2017 · 3 comments
Closed

Xargo does not work with rust-src #51

joepie91 opened this issue Jul 26, 2017 · 3 comments

Comments

@joepie91
Copy link

joepie91 commented Jul 26, 2017

When installing both rust and rust-src from the rust-overlay (specifically, from the nightly channel), after installing Xargo (cargo install xargo), it will fail to run:

$ xargo --help
error: `rust-src` component not found. Run `rustup component add rust-src`.
note: run with `RUST_BACKTRACE=1` for a backtrace

An strace -f suggests that Xargo is incorrectly looking for the src in the main rust derivation output, not the rust-src output:

stat("/nix/store/i9yr504pkw2q7l80mp51pri89pyq50rf-rust-1.20.0-nightly-2017-07-24-598eddf4f/lib/rustlib/src/rust/src/libstd/Cargo.toml", 0x7fffb2fa9c30) = -1 ENOENT (No such file or directory)
stat("/nix/store/i9yr504pkw2q7l80mp51pri89pyq50rf-rust-1.20.0-nightly-2017-07-24-598eddf4f/lib/rustlib/src", 0x7fffb2fa9c30) = -1 ENOENT (No such file or directory)
write(2, "error: ", 7error: )                  = 7
write(2, "`rust-src` component not found. "..., 68`rust-src` component not found. Run `rustup component add rust-src`.) = 68

I don't know if this is strictly speaking a problem with the rust-overlay, but I'd imagine that more tools might be making the same assumption as to where to find the sources.

Workaround

The full process to get it working:

  1. Install the nixpkgs.rustChannels.nightly.rust-src package (or a rust-src from your channel of choice) from the Mozilla overlay.
  2. Add the following to your system configuration: environment.pathsToLink = [ "/lib/rustlib/src" ];
  3. Add the following to your .bashrc: export XARGO_RUST_SRC="/run/current-system/sw/lib/rustlib/src/rust/src"

This probably is more impure than it should be, but at least it makes Xargo work. Alternative suggestions are very welcome, a 'proper' fix even moreso :)

@jameysharp
Copy link
Contributor

I've been using this expression:

(rustChannels.nightly.rust.override { extensions = [ "rust-src" ]; })

More broadly, here's the shell.nix I'm using to also get a GCC toolchain for ARM microcontrollers:

with import <nixos> {};
runCommand "dummy" {
  buildInputs = [
    (rustChannels.nightly.rust.override { extensions = [ "rust-src" ]; })
    gcc-arm-embedded
  ];
} ""

@nbp
Copy link
Collaborator

nbp commented Aug 16, 2017

@joepie91 Can you confirm if the solution proposed by @jameysharp works for you?

@crawford
Copy link

crawford commented May 2, 2018

I've successfully used the above solution for a while. It's worth noting that Xargo is no longer required, so now I use the following (installing rust-std for thumbv7m-none-eabi instead of rust-src):

let
  moz_overlay = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
  nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
in
  with nixpkgs;
  stdenv.mkDerivation {
    name = "project";
    buildInputs = [
      (rustChannels.nightly.rust.override {
        targets = [ "thumbv7m-none-eabi" ];
        extensions = [ "rust-std" "rustfmt-preview" ];
      })
      gcc-arm-embedded
    ];
  }

This can probably be closed.

@garbas garbas closed this as completed May 18, 2018
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