Giter Club home page Giter Club logo

Comments (4)

kolloch avatar kolloch commented on July 19, 2024 2

I filed this bug:

NixOS/nixpkgs#74071

Feel free to fix ;)

from crate2nix.

kolloch avatar kolloch commented on July 19, 2024 1

This is a fun one. This is the build output:

these derivations will be built:
  /nix/store/9dccznnszigsnlyqdjcdqk4xyizz6wjx-rust_anyhow-1.0.23.drv
  /nix/store/kggvrg6lmzjw41gxr9hbxb56dnqa6km2-rust_with_anyhow-0.1.0.drv
building '/nix/store/9dccznnszigsnlyqdjcdqk4xyizz6wjx-rust_anyhow-1.0.23.drv'...
unpacking sources
unpacking source archive /nix/store/43ca92c955jib0gpxvdfwswsd5ppzivw-anyhow-1.0.23.tar.gz
source root is anyhow-1.0.23.tar.gz
patching sources
configuring
Building build.rs (anyhow)
Running rustc --crate-name build_script_build build.rs --crate-type bin -C opt-level=3 -C codegen-units=8 --edition 2018 --cfg feature="default" --cfg feature="std" --out-dir target/build/anyhow --emit=dep-info,link -L dependency=target/buildDeps --cap-lints allow --color always
error[E0432]: unresolved import `std::backtrace`
 --> /build/anyhow-1.0.23.tar.gz/target/build/anyhow.out/lib.rs:5:14
  |
5 |     use std::backtrace::{Backtrace, BacktraceStatus};
  |              ^^^^^^^^^ could not find `backtrace` in `std`

error[E0407]: method `backtrace` is not a member of trait `Error`
  --> /build/anyhow-1.0.23.tar.gz/target/build/anyhow.out/lib.rs:19:9
   |
19 | /         fn backtrace(&self) -> Option<&Backtrace> {
20 | |             let backtrace = Backtrace::capture();
21 | |             match backtrace.status() {
22 | |                 BacktraceStatus::Captured | BacktraceStatus::Disabled | _ => {}
23 | |             }
24 | |             unimplemented!()
25 | |         }
   | |_________^ not a member of trait `Error`

error[E0554]: #![feature] may not be used on the stable release channel
 --> /build/anyhow-1.0.23.tar.gz/target/build/anyhow.out/lib.rs:2:5
  |
2 |     #![feature(backtrace)]
  |     ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0407, E0432, E0554.
For more information about an error, try `rustc --explain E0407`.

The build detection actually works well and fails.

building
Building src/lib.rs (anyhow)
Running rustc --crate-name anyhow src/lib.rs --crate-type lib -C opt-level=3 -C codegen-units=8 --edition 2018 -C metadata=5e47fda77d -C extra-filename=-5e47fda77d --cfg feature="default" --cfg feature="std" --out-dir target/lib --emit=dep-info,link -L dependency=target/deps --cap-lints allow -L /build/anyhow-1.0.23.tar.gz/target/build/anyhow.out --color always
error[E0432]: unresolved import `std::backtrace`
 --> src/lib.rs:5:14
  |
5 |     use std::backtrace::{Backtrace, BacktraceStatus};
  |              ^^^^^^^^^ could not find `backtrace` in `std`

error[E0407]: method `backtrace` is not a member of trait `Error`
  --> src/lib.rs:19:9
   |
19 | /         fn backtrace(&self) -> Option<&Backtrace> {
20 | |             let backtrace = Backtrace::capture();
21 | |             match backtrace.status() {
22 | |                 BacktraceStatus::Captured | BacktraceStatus::Disabled | _ => {}
23 | |             }
24 | |             unimplemented!()
25 | |         }
   | |_________^ not a member of trait `Error`

error[E0554]: #![feature] may not be used on the stable release channel
 --> src/lib.rs:2:5
  |
2 |     #![feature(backtrace)]
  |     ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0407, E0432, E0554.
For more information about an error, try `rustc --explain E0407`.
builder for '/nix/store/9dccznnszigsnlyqdjcdqk4xyizz6wjx-rust_anyhow-1.0.23.drv' failed with exit code 1
cannot build derivation '/nix/store/kggvrg6lmzjw41gxr9hbxb56dnqa6km2-rust_with_anyhow-0.1.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/kggvrg6lmzjw41gxr9hbxb56dnqa6km2-rust_with_anyhow-0.1.0.drv' failed

This is actually NOT line 2 of the lib.rs of anyhow.

https://github.com/dtolnay/anyhow/blob/1.0.23/src/lib.rs#L2

So why does the ultimate build fail?

Well, the output files of the build script are copied over the existing sources. So the rustc compiles the lib.rs from the build check:

https://github.com/NixOS/nixpkgs/blame/master/pkgs/build-support/rust/build-rust-crate/configure-crate.nix#L142-L149

Why does this code exist? I have no clue. Did an older version of cargo do the same?

from crate2nix.

kolloch avatar kolloch commented on July 19, 2024 1

Also created a quickfix: dtolnay/anyhow#49

from crate2nix.

kolloch avatar kolloch commented on July 19, 2024 1

NixOS/nixpkgs#74071 was fixed by @andir!

from crate2nix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.