bazelbuild / bazelbuild/rules_rust

Splicing out-of-tree cargo workspaces fails

Open
#3,450 0 comments 0 reactions 0 assignees View on GitHub
needs-triage
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

Splicing `Cargo.toml` files always assumes in-tree workspaces and crashes on out-of-tree workspaces.

### Reproduction

Copy `examples/crate_universe/cargo_workspace` to `examples/crate_universe/cargo_workspace_oot` and modify the second to implement an out-of-tree workspace. See, for example, https://github.com/Synss/rules_rust/tree/pr-oot/

Then run
```
$ cd examples/crate_universe
$ REPIN=1 bazel mod deps --lockfile=update
```

Splicing fails with
```
error: failed to load manifest for workspace member `/tmp/.tmp17zZ7O/../num_printer`
referenced by workspace at `/tmp/.tmp17zZ7O/Cargo.toml`

Caused by:
failed to read `/tmp/num_printer/Cargo.toml`

Caused by:
No such file or directory (os error 2)

Error: Failed to generate lockfile

```

Compare with `cargo`
```
$ cd examples/crate_universe/cargo_workspace_oot/workspace
$ cargo run --quiet printer --version
Number Printer

```

### Analysis

It seems splicing always triggers the discovery, which assumes either flat or in-tree workspaces.

### Note

I'm already working on the feature as we need it where I work. I'm already working on a patch and I'll upstream when I'm done.

### See also

Out-of-tree workspaces are documented at

* https://github.com/nox/rust-rfcs/blob/master/text/1525-cargo-workspace.md
* https://doc.rust-lang.org/cargo/reference/workspaces.html

where the RFC appears to provide a more precise specification of the feature.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.