Skip to content

rustc build fails when run from a subdirectory of a Rust project - error: current package believes it's in a workspace when it's not: #145272

@kpcyrd

Description

@kpcyrd

Summary

I wrote my tooling for packaging in Rust, and execute builds from subdirectories of that project. Cargo doesn't seem to like this.

It's similiar (but not the same) problem as same software having problems when built inside the checkout of a git repository that is not the upstream repository. (not the case here, hopefully this comparison doesn't add confusion).

Command used

DESTDIR="$srcdir/dest-rust" python ./x.py install -j "$(nproc)"

Expected behaviour

Rust builds.

Actual behaviour

==> Starting build()...
Building bootstrap
error: current package believes it's in a workspace when it's not:
current:   /home/kpcyrd/repos/platypos/os/rust/src/rustc-1.89.0-src/src/bootstrap/Cargo.toml
workspace: /home/kpcyrd/repos/platypos/Cargo.toml

this may be fixable by adding `os/rust/src/rustc-1.89.0-src/src/bootstrap` to the `workspace.members` array of the manifest located at: /home/kpcyrd/repos/platypos/Cargo.toml
Alternatively, to keep it out of the workspace, add the package to the `workspace.exclude` array, or add an empty `[workspace]` table to the package's manifest.
failed to run: /usr/bin/cargo build --manifest-path /home/kpcyrd/repos/platypos/os/rust/src/rustc-1.89.0-src/src/bootstrap/Cargo.toml -Zroot-dir=/home/kpcyrd/repos/platypos/os/rust/src/rustc-1.89.0-src --locked --frozen
Build completed unsuccessfully in 0:00:00

Bootstrap configuration (bootstrap.toml)

# see src/bootstrap/defaults/
profile = "dist"

# see src/bootstrap/src/utils/change_tracker.rs
change-id = 142379

[llvm]
download-ci-llvm = false
link-shared = true

[build]
description = "Arch Linux $pkgbase $epoch:$pkgver-$pkgrel"
target = [
  "x86_64-unknown-linux-gnu",
  "x86_64-unknown-linux-musl",
]
cargo = "/usr/bin/cargo"
rustc = "/usr/bin/rustc"
rustfmt = "/usr/bin/rustfmt"
locked-deps = true
vendor = true
tools = [
  "cargo",
  "clippy",
  "rustdoc",
  "rustfmt",
  "rust-analyzer-proc-macro-srv",
  "analysis",
  "src",
]
sanitizers = true
profiler = true

# Generating docs fails with the wasm32-* targets
docs = false

[install]
prefix = "/usr"

[rust]
codegen-units-std = 1
debuginfo-level = 1
debuginfo-level-std = 2
channel = "stable"
rpath = false
frame-pointers = true
lld = false
use-lld = "external"
llvm-bitcode-linker = false
deny-warnings = false
backtrace-on-ice = true
remap-debuginfo = false
jemalloc = true

[dist]
compression-formats = ["gz"]
compression-profile = "fast"

[target.x86_64-unknown-linux-gnu]
cc = "/usr/bin/gcc"
cxx = "/usr/bin/g++"
ar = "/usr/bin/gcc-ar"
ranlib = "/usr/bin/gcc-ranlib"
llvm-config = "/usr/bin/llvm-config"

[target.x86_64-unknown-linux-musl]
cc = "/usr/bin/musl-gcc"
cxx = "/usr/bin/g++"
ar = "/usr/bin/gcc-ar"
ranlib = "/usr/bin/gcc-ranlib"
sanitizers = false
musl-root = "/usr/lib/musl"

Operating system

Arch Linux

HEAD

https://static.rust-lang.org/dist/rustc-1.89.0-src.tar.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions