crate2nix icon indicating copy to clipboard operation
crate2nix copied to clipboard

error: attribute 'cargo_web' missing

Open bbigras opened this issue 4 years ago • 13 comments

I was able to use crate2nix on this project. I think I just did a cargo update.

crate2nix 0.8.0 rustc 1.45.0-nightly (a08c47310 2020-05-07)

❯ nix-build
trace: root_crate is deprecated since crate2nix 0.4. Please use rootCrate instead.
trace: workspace_members is deprecated in crate2nix 0.4. Please use workspaceMembers instead.
error: attribute 'cargo_web' missing, at /home/bbigras/dev/test/Cargo.nix:5861:44
(use '--show-trace' to show detailed location information)
      "time 0.2.15" = rec {
        crateName = "time";
        version = "0.2.15";
        edition = "2018";
        sha256 = "1hg6zn71c9xb66j1i9wwwasrxapi5zhnnixfxrqngh76s8lhhcz1";
        authors = [
          "Jacob Pratt <[email protected]>"
        ];
        dependencies = [
          {
            name = "cfg-if";
            packageId = "cfg-if";
          }
          {
            name = "libc";
            packageId = "libc";
            optional = true;
            target = { target, features }: target."unix";
          }
          {
            name = "standback";
            packageId = "standback";
            usesDefaultFeatures = false;
          }
          {
            name = "stdweb";
            packageId = "stdweb";
            optional = true;
            usesDefaultFeatures = false;
            target = { target, features }: target."cargo_web";
          }
          {
            name = "time-macros";
            packageId = "time-macros";
          }
          {
            name = "winapi";
            packageId = "winapi 0.3.8";
            optional = true;
            target = { target, features }: target."windows";
            features = [ "minwinbase" "minwindef" "timezoneapi" ];
          }
        ];
        buildDependencies = [
          {
            name = "version_check";
            packageId = "version_check 0.9.1";
          }
        ];
        features = {
          "default" = [ "deprecated" "std" ];
          "std" = [ "libc" "winapi" "stdweb" "standback/std" ];
        };
        resolvedDefaultFeatures = [ "default" "deprecated" "libc" "std" "stdweb" "winapi" ];
      };

bbigras avatar May 08 '20 14:05 bbigras

Any progress on this?

bbigras avatar Jul 13 '20 14:07 bbigras

Same here. All of v0.7.0. v0.8.0. master fails to build because of missing cargo_web. In my case, cargo_web is required by stdweb.

           {
             name = "stdweb";
             packageId = "stdweb 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)";
             optional = true;
             usesDefaultFeatures = false;
             target = { target, features }: target."cargo_web";
           }

pandaman64 avatar Aug 04 '20 12:08 pandaman64

Can you publish an example project that reproduces the issue? It doesn't have to be very minimal nor small. As long as it reproduces the issue that would be sufficient to have a shot at understanding the nature of the issue.

andir avatar Aug 04 '20 13:08 andir

I'll make one.

bbigras avatar Aug 04 '20 13:08 bbigras

I'm able to reproduce with an empty project with only:

[dependencies]
time = "0.2.16"
error: attribute 'cargo_web' missing, at /home/bbigras/dev/lab/crate2nix/issue-133/Cargo.nix:620:44
(use '--show-trace' to show detailed location information)

bbigras avatar Aug 04 '20 13:08 bbigras

As a temporary workaround I manually add cargo_web = false to my projects that suffer from this, with a note to myself so I catch it on the git diffs before committing. I'm not an informed-enough developer to offer a sustainable solution or upstream fix, sorry!

shanesveller avatar Aug 04 '20 18:08 shanesveller

complete reproducer: https://github.com/pandaman64/crate2nix-cargoweb

pandaman64 avatar Aug 04 '20 18:08 pandaman64

As a temporary workaround I manually add cargo_web = false to my projects

Thanks @shanesveller . I wish I knew that 3 months ago.

bbigras avatar Aug 04 '20 18:08 bbigras

It seems that time crate detects cargo-web by checking cfg(cargo_web): https://github.com/time-rs/time/blob/main/Cargo.toml#L46

Probably generating cargo_web = false by default is a good idea as time is widely used.

pandaman64 avatar Aug 05 '20 02:08 pandaman64

#141 is a dupe

pandaman64 avatar Aug 05 '20 07:08 pandaman64

As a temporary workaround I manually add cargo_web = false to my projects that suffer from this, with a note to myself so I catch it on the git diffs before committing. I'm not an informed-enough developer to offer a sustainable solution or upstream fix, sorry!

Trying to build a project of mine with crate2nix and running into this. Where do I put cargo_web = false?

mikeplus64 avatar Aug 13 '20 08:08 mikeplus64

You can modify defaultTarget in Cargo.nix. I'm using this patch: https://github.com/pandaman64/oekaki/blob/master/backend/Cargo.nix.patch feature = "" is a workarond for #136. This might disable some SIMD optimizations.

pandaman64 avatar Aug 13 '20 11:08 pandaman64

It looks like the latest version fixed this issue. Thanks!

pandaman64 avatar Jan 25 '21 09:01 pandaman64