cross icon indicating copy to clipboard operation
cross copied to clipboard

Failed to find a workspace root (local workspace dependency)

Open Atmelfan opened this issue 2 years ago • 3 comments

Checklist

Describe your issue

Cross fails to compile local workspace dependencies with manifest inheritance.

The issue seems to be that only dependency paths are copied/mirrored into the container and not the workspace it belongs to.

What target(s) are you cross-compiling for?

armv7-unknown-linux-gnueabihf

Which operating system is the host (e.g computer cross is on) running?

  • [ ] macOS
  • [ ] Windows
  • [X] Linux / BSD
  • [ ] other OS (specify in description)

What architecture is the host?

  • [X] x86_64 / AMD64
  • [ ] arm32
  • [ ] arm64 (including Mac M1)

What container engine is cross using?

  • [X] docker
  • [ ] podman
  • [ ] other container engine (specify in description)

cross version

cross 0.2.4 (aa59bf2 2022-12-23)

Example

git clone https://github.com/Atmelfan/cross_workspace_inheritance_issue.git
cd cross_workspace_inheritance_issue/app
cargo build # works
cross build # doesn't work

Errors with:

error: failed to get `lib1` as a dependency of package `app v0.1.0 (/home/REDACTED/projects/cross_workspace_inheritance_issue/app)`

Caused by:
  failed to load source for dependency `lib1`

Caused by:
  Unable to update /home/REDACTED/projects/cross_workspace_inheritance_issue/dep_workspace/lib1

Caused by:
  failed to parse manifest at `/home/REDACTED/projects/cross_workspace_inheritance_issue/dep_workspace/lib1/Cargo.toml`

Caused by:
  error inheriting `version` from workspace root manifest's `workspace.package.version`

Caused by:
  failed to find a workspace root

Additional information / notes

No response

Atmelfan avatar Jan 05 '23 01:01 Atmelfan

Thanks for raising this issue!

This is a related to #1088 and would be solved by that.

For now, you can circumvent this by specifying in Cross.toml or Cargo.toml accordingly

# app/Cargo.toml
[package.metadata.cross.build.env]
volumes = ["__LIB12_DEP=../dep_workspace"]

# app/Cross.toml
[build.env]
volumes = ["__LIB12_DEP=../dep_workspace"]

Emilgardis avatar Jan 05 '23 08:01 Emilgardis

Thanks for raising this issue!

This is a related to #1088 and would be solved by that.

For now, you can circumvent this by specifying in Cross.toml or Cargo.toml accordingly

# app/Cargo.toml
[package.metadata.cross.build.env]
volumes = ["__LIB12_DEP=../dep_workspace"]

# app/Cross.toml
[build.env]
volumes = ["__LIB12_DEP=../dep_workspace"]

Why the correct way is writing __{XXX}2_DEP?

TD-Sky avatar Aug 21 '24 07:08 TD-Sky

Why the correct way is writing __{XXX}2_DEP?

@TD-Sky It doesn't matter, I just did that to make it clear it's not used anywhere, you can name it whatever you want

Emilgardis avatar Aug 21 '24 13:08 Emilgardis