rust-lang / rust-lang/rust

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:

Open
#145,272 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-discussion T-bootstrap
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the bootstrap build invoked by ./x.py and the manifest at src/bootstrap/Cargo.toml, using the reported command from the Rust project subdirectory. Compare how the enclosing /home/kpcyrd/repos/platypos/Cargo.toml is detected with the bootstrap configuration in bootstrap.toml. Done means the Rust build completes successfully from that subdirectory without the workspace error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.