Skip to content

Commit e00048f

Browse files
jonaspleyersyphar
authored andcommitted
add MWE for problematic workspace package when building locally
1 parent fda6616 commit e00048f

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

docs/build-workspaces.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,73 @@ Now the commands specified in [Readme.md](../Readme.md) can be executed targetin
2121
cargo run -- build crate --local /path/to/source/target/package/your_crate_name-version/
2222
```
2323

24+
## Full MWE
25+
To showcase when such problems can occur, take a look at the following example.
26+
### Structure
27+
```bash
28+
$ tree
29+
.
30+
├── Cargo.toml
31+
├── my_lib
32+
│   ├── Cargo.toml
33+
│   └── src
34+
│   └── lib.rs
35+
└── README.md
36+
37+
3 directories, 4 files
38+
```
39+
The actual contents of `my_lib` do not matter, only the two configuration files.
40+
```
41+
$ cat Cargo.toml
42+
[workspace]
43+
members = [
44+
"my_lib",
45+
]
46+
47+
[workspace.package]
48+
version = "0.1.0"
49+
```
50+
and
51+
```bash
52+
$ cat my_lib/Cargo.toml
53+
[package]
54+
name = "my_lib"
55+
version.workspace = true
56+
57+
[dependencies]
58+
```
59+
60+
### Building
61+
62+
The build command
63+
```bash
64+
cargo run -- build crate -l path/to/docs_rs_workspace_package/my_lib
65+
```
66+
fails with
67+
```bash
68+
Error: Building documentation failed
69+
70+
Caused by:
71+
Building documentation failed
72+
73+
Caused by:
74+
invalid Cargo.toml syntax
75+
```
76+
which makes sense due to
77+
```toml
78+
version.workspace = true
79+
```
80+
81+
### Fix
82+
However when running the following sequence of commands
83+
```bash
84+
# Run this in the directory of docs_rs_workspace_package
85+
cargo package -p my_lib
86+
```
87+
and then building again
88+
```bash
89+
# Run this from the docs.rs repo
90+
cargo run -- build crate -l path/to/docs_rs_workspace_package/target/package/my_lib-0.1.0
91+
```
92+
then the build succeeds.
93+

0 commit comments

Comments
 (0)