Stream: git-wasmtime

Topic: wasmtime / issue #10424 Build fails with " can't find cra...


view this post on Zulip Wasmtime GitHub notifications bot (Mar 19 2025 at 19:34):

pinkoboio added the bug label to Issue #10424.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 19 2025 at 19:34):

pinkoboio opened issue #10424:

Steps to Reproduce

I am using nix to manage some C-library dependencies, so rustup is installed from the nixpkgs-unstable repo using this flake.

{
    description = "Minimal Reproducible Flake";
    inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
    };
    outputs = { self, nixpkgs }:
    let
        pkgs = nixpkgs.legacyPackages.x86_64-linux;
    in
    {
        devShell.x86_64-linux = pkgs.mkShell {
            shellHook = "$SHELL; exit"; # I use zsh, nix-shell won't use zsh by default
            nativeBuildInputs = with pkgs; [
                rustup
            ];
        };
    };
}

To recreate the issue:

  1. Start in a directory where the only file is the flake above.
  2. Run nix develop to add rustup to path. (install stable toolchain if not done already)
  3. cargo init . to create a new crate and cargo add wasmtime to add wasmtime as a dependency.
  4. Either cargo build the whole crate or just cargo build -p wasmtime.

Expected Results

I expect the crate to build successfully without any errors.

Actual Results

The build fails with this output

   Compiling wasmtime v30.0.2
error[E0463]: can't find crate for `wasmtime_component_macro`
   --> /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/mod.rs:408:9
    |
408 | pub use wasmtime_component_macro::bindgen;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `wasmtime_component_macro`
   --> /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/mod.rs:550:9
    |
550 | pub use wasmtime_component_macro::ComponentType;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `wasmtime_component_macro`
   --> /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/mod.rs:578:9
    |
578 | pub use wasmtime_component_macro::Lift;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `wasmtime_component_macro`
   --> /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/mod.rs:606:9
    |
606 | pub use wasmtime_component_macro::Lower;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `wasmtime_component_macro`
   --> /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/mod.rs:665:9
    |
665 | pub use wasmtime_component_macro::flags;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0432]: unresolved imports `crate::component::ComponentType`, `crate::component::Lift`, `crate::component::Lower`, `crate::component::Lift`, `crate::component::Lower`, `crate::component::Lift`, `crate::component::Lower`, `crate::component::ComponentType`, `crate::component::Lift`, `crate::component::Lower`
 --> /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/func/host.rs:4:44
  |
4 | use crate::component::{ComponentNamedList, ComponentType, Lift, Lower, Val};
  |                                            ^^^^^^^^^^^^^  ^^^^  ^^^^^
  |
 ::: /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/instance.rs:4:64
  |
4 |     Component, ComponentExportIndex, ComponentNamedList, Func, Lift, Lower, ResourceType, TypedFunc,
  |                                                                ^^^^  ^^^^^
  |
 ::: /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/linker.rs:6:59
  |
6 |     Component, ComponentNamedList, Instance, InstancePre, Lift, Lower, ResourceType, Val,
  |                                                           ^^^^  ^^^^^
  |
 ::: /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/resources.rs:3:24
  |
3 | use crate::component::{ComponentType, Lift, Lower};
  |                        ^^^^^^^^^^^^^  ^^^^  ^^^^^

Some errors have detailed explanations: E0432, E0463.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `wasmtime` (lib) due to 6 previous errors

I have tried this on an Arch machine using the rustup from pacman and the build completed successfully. So I'm tempted to blame this on nix but I'm not really sure how or why my choice of package manager should make a difference; especially since cargo is supposed to be managing all rust dependencies.

Versions and Environment

wasmtime v30.0.2
rustup v1.27.1
rustc v1.83.0
cargo v1.83.0

Operating system: NixOS 23.11

Architecture: x86_64

view this post on Zulip Wasmtime GitHub notifications bot (Mar 19 2025 at 20:55):

alexcrichton commented on issue #10424:

Would you be able to phrase your problem without nix in the mix? I've attempted to reproduce without nix and I am unable to. I'm not sure what nix is doing, if anything, behind the scenes, so I think it'd be best to set that aside when reproducing if possible.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 19 2025 at 21:23):

pinkoboio commented on issue #10424:

I've already tried to reproduce this issue without using nix and the build completed successfully. I wasn't sure if this was an issue with nix or cargo or wasmtime but now I'm quite sure it's an issue with nix. Problem is my project already uses nix for a lot of C dependencies and I don't want to (and shouldn't have to) migrate to some other containerization/package management system like docker. Now that I know that nix is the problem though, I'll just request help from the nix community I think.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 19 2025 at 21:40):

cfallin commented on issue #10424:

I'm not really sure how or why my choice of package manager should make a difference; especially since cargo is supposed to be managing all rust dependencies.

For what it's worth, I used Nix for about a year to manage my whole development environment, and ultimately gave up because the integration with Rust tooling is just not good. (For example, the version of rustup that nixpkgs distributes is patched so that when it downloads a toolchain, it edits the ELF binaries to refer to specific nix paths, but those nix paths aren't rooted because it's in ~/.rustup, so a later upgrade could leave a broken toolchain behind. This is a known issue that simply has no solution.) In general I find the compiler patching to be the most error-prone part of Nix's approach. If you're able to run an unmodified toolchain with vanilla rustup etc using nix-ld, that might be a way to debug this.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 19 2025 at 21:40):

cfallin edited a comment on issue #10424:

I'm not really sure how or why my choice of package manager should make a difference; especially since cargo is supposed to be managing all rust dependencies.

For what it's worth, I used Nix for about a year to manage my whole development environment, and ultimately gave up because the integration with Rust tooling is just not good. (For example, the version of rustup that nixpkgs distributes is patched so that when it downloads a toolchain, it edits the ELF binaries to refer to specific nix paths, but those nix paths aren't rooted because it's in ~/.rustup, so a later upgrade + nix-collect-garbage could leave a broken toolchain behind. This is a known issue that simply has no solution.) In general I find the compiler patching to be the most error-prone part of Nix's approach. If you're able to run an unmodified toolchain with vanilla rustup etc using nix-ld, that might be a way to debug this.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 20 2025 at 17:49):

pinkoboio commented on issue #10424:

I've found nix-ld troublesome in the past. In my experience it works well until it doesn't, and when it doesn't work there's no indicator of why or how it failed or what along the chain failed. But, I just tried to build wasmtime using the devenv version rustup and it built fine. On their website, devenv claims to base their own packages off of a slightly older version of nixpkgs with some 'extra fixes'. So this was most definitely an issue with the nix version of rustup/cargo and not with wasmtime.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 20 2025 at 18:19):

alexcrichton closed issue #10424:

Steps to Reproduce

I am using nix to manage some C-library dependencies, so rustup is installed from the nixpkgs-unstable repo using this flake.

{
    description = "Minimal Reproducible Flake";
    inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
    };
    outputs = { self, nixpkgs }:
    let
        pkgs = nixpkgs.legacyPackages.x86_64-linux;
    in
    {
        devShell.x86_64-linux = pkgs.mkShell {
            shellHook = "$SHELL; exit"; # I use zsh, nix-shell won't use zsh by default
            nativeBuildInputs = with pkgs; [
                rustup
            ];
        };
    };
}

To recreate the issue:

  1. Start in a directory where the only file is the flake above.
  2. Run nix develop to add rustup to path. (install stable toolchain if not done already)
  3. cargo init . to create a new crate and cargo add wasmtime to add wasmtime as a dependency.
  4. Either cargo build the whole crate or just cargo build -p wasmtime.

Expected Results

I expect the crate to build successfully without any errors.

Actual Results

The build fails with this output

   Compiling wasmtime v30.0.2
error[E0463]: can't find crate for `wasmtime_component_macro`
   --> /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/mod.rs:408:9
    |
408 | pub use wasmtime_component_macro::bindgen;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `wasmtime_component_macro`
   --> /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/mod.rs:550:9
    |
550 | pub use wasmtime_component_macro::ComponentType;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `wasmtime_component_macro`
   --> /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/mod.rs:578:9
    |
578 | pub use wasmtime_component_macro::Lift;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `wasmtime_component_macro`
   --> /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/mod.rs:606:9
    |
606 | pub use wasmtime_component_macro::Lower;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0463]: can't find crate for `wasmtime_component_macro`
   --> /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/mod.rs:665:9
    |
665 | pub use wasmtime_component_macro::flags;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0432]: unresolved imports `crate::component::ComponentType`, `crate::component::Lift`, `crate::component::Lower`, `crate::component::Lift`, `crate::component::Lower`, `crate::component::Lift`, `crate::component::Lower`, `crate::component::ComponentType`, `crate::component::Lift`, `crate::component::Lower`
 --> /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/func/host.rs:4:44
  |
4 | use crate::component::{ComponentNamedList, ComponentType, Lift, Lower, Val};
  |                                            ^^^^^^^^^^^^^  ^^^^  ^^^^^
  |
 ::: /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/instance.rs:4:64
  |
4 |     Component, ComponentExportIndex, ComponentNamedList, Func, Lift, Lower, ResourceType, TypedFunc,
  |                                                                ^^^^  ^^^^^
  |
 ::: /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/linker.rs:6:59
  |
6 |     Component, ComponentNamedList, Instance, InstancePre, Lift, Lower, ResourceType, Val,
  |                                                           ^^^^  ^^^^^
  |
 ::: /home/bailor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmtime-30.0.2/src/runtime/component/resources.rs:3:24
  |
3 | use crate::component::{ComponentType, Lift, Lower};
  |                        ^^^^^^^^^^^^^  ^^^^  ^^^^^

Some errors have detailed explanations: E0432, E0463.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `wasmtime` (lib) due to 6 previous errors

I have tried this on an Arch machine using the rustup from pacman and the build completed successfully. So I'm tempted to blame this on nix but I'm not really sure how or why my choice of package manager should make a difference; especially since cargo is supposed to be managing all rust dependencies.

Versions and Environment

wasmtime v30.0.2
rustup v1.27.1
rustc v1.83.0
cargo v1.83.0

Operating system: NixOS 23.11

Architecture: x86_64

view this post on Zulip Wasmtime GitHub notifications bot (Mar 20 2025 at 18:19):

alexcrichton commented on issue #10424:

Ok thanks for helping to investigate! In that case I'm going to close this.


Last updated: Apr 18 2025 at 12:05 UTC