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

buildCargoPackage fails when a dependency uses [workspace.dependencies] #202762

Closed
arcnmx opened this issue Nov 25, 2022 · 6 comments
Closed

buildCargoPackage fails when a dependency uses [workspace.dependencies] #202762

arcnmx opened this issue Nov 25, 2022 · 6 comments
Labels
0.kind: bug Something is broken 6.topic: rust

Comments

@arcnmx
Copy link
Member

arcnmx commented Nov 25, 2022

Describe the bug

When a rust crate uses workspace.dependencies and a nix package attempts to depend on it, building fails:

++ env CC_x86_64-unknown-linux-gnu=/nix/store/dq0xwmsk1g0i2ayg6pb7y87na2knzylh-gcc-wrapper-11.3.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/dq0xwmsk1g0i2ayg6pb7y87na2knzylh-gcc-wrapper-11.3.0/bin/c++ CC_x86_64-unknown-linux-gnu=/nix/store/dq0xwmsk1g0i2ayg6pb7y87na2knzylh-gcc-wrapper-11.3.0/bin/cc CXX_x86_64-unknown-linux-gnu=/nix/store/dq0xwmsk1g0i2ayg6pb7y87na2knzylh-gcc-wrapper-11.3.0/bin/c++ cargo build -j 32 --target x86_64-unknown-linux-gnu --frozen --release
failed to get `hass-mqtt-discovery` as a dependency of package `test v0.0.0 (/build/source)`

Caused by:
  failed to load source for dependency `hass-mqtt-discovery`

Caused by:
  Unable to update https://github.com/YoloDev/hass-rs?branch=poc/builder#0014313a

Caused by:
  failed to update replaced source https://github.com/YoloDev/hass-rs?branch=poc/builder#0014313a

Caused by:
  failed to parse manifest at `/build/cargo-vendor-dir/hass-mqtt-discovery-macros-0.0.0/Cargo.toml`

Caused by:
  failed to find a workspace root

Steps To Reproduce

Try building a test package that depends on such a crate:

nix build -L github:arcnmx/hass-rs/nixpkgs-repro#

Expected behavior

It should build!

Additional context

Removing the workspace.dependencies (and updating the package to use it) allows the build to work normally.

This issue presumably interacts with cargo vendor and importCargoLock in some way, but I'm not really sure what's at fault here?

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

:; nix run nixpkgs#nix-info
system: "x86_64-linux", multi-user?: yes, version: nix-env (Nix) 2.11.0, nixpkgs: /home/arc/.config/nix/path/nixpkgs)
@DeeUnderscore
Copy link
Contributor

rust-lang/cargo#11192 might be the upstream issue related to this

DeeUnderscore added a commit to DeeUnderscore/ruma that referenced this issue Dec 29, 2022
Building packages which use workspace dependencies is currently broken
in Nixpkgs (see NixOS/nixpkgs#202762), so as a
hack workaround for this, all dependencies here have been specified
inline instead.
@yu-re-ka
Copy link
Contributor

As a workaround, you can patch away the workspace dependency feature from the Cargo.toml inside the vendor dir

@CobaltCause
Copy link
Contributor

CobaltCause commented Jan 19, 2023

Upstream merged a fix for this recently though of course it'll be a while before it's available in a release: rust-lang/cargo#11414

@lilyinstarlight
Copy link
Member

It seems this is fixed now based on your repro, so can this be closed?

@CobaltCause
Copy link
Contributor

I think so. I conducted a little test of my own and using [workspace.dependencies] with buildRustPackage works now.

@DeeUnderscore
Copy link
Contributor

We actually even have tests for this in tree now, so this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: rust
Projects
None yet
Development

No branches or pull requests

6 participants