Comments (9)
Not sure how easy or practical this is or how often this situation occurs.
I suspect it is pretty rare, as newer package will by default get edition
key if created via cargo new
. We also have #13505 which warns if edition key is missing, so I guess #13505 can mostly improve the situation here?
I ran into it by following instructions from an example in the Cargo book.
Which example is it? Maybe we can fix that example instead.
from cargo.
@rimutaka would like to take on this tassk
from cargo.
@rohansx, the same, this is not triaged yet. (Sorry I have been consumed by day job these days)
If you wanna help out, you can look at how the issue tracker works in this repository. Specifically, issues with S-accepted
are open for people to pick up.
Whenever you made up your mind picking up an issue, you could optionally add a comment @rustbot claim
to assign the issue to yourself. See the doc for bot commands.
from cargo.
TLDR;
After writing all this I realise I was looking for an example how to create a workspace, found none, tried to piece together bits and pieces, failed. I'm not the brightest spark out there, so not sure how many others walk the same path :)
There is probably a dozen ways how it may happen, but here is my sequence of events:
- reading https://doc.rust-lang.org/cargo/reference/workspaces.html with the goal to quickly try how WSs work
Seems simple, but what do I put in # ...
?
What's root package? I don't seem to need one. Skipping.
What's resolver? Why 2? I don't quite get it. Skipping.
- created Cargo.toml in an empty root folder
- copy-pasted the above example into it
- ran
cargo new foo
- stared at the error for some time trying to understand where I went wrong and what it all means
- looked at both Cargo.toml files and realised that I do not need the resolver as suggested - I have to specify the edition in the root
I think what tripped me up was the expectation that I do not have to have the root package table at all.
To create a workspace, you add the [workspace] table to a Cargo.toml:
At minimum, a workspace has to have a member, either with a root package or as a virtual manifest.
...
Alternatively, a Cargo.toml file can be created with a [workspace] section but without a [[package] section](https://doc.rust-lang.org/cargo/reference/manifest.html#the-package-section). This is called a virtual manifest. This is typically useful when there isn’t a “primary” package, or you want to keep all the packages organized in separate directories.
I didn't want to use cargo new
for the root because it doesn't have a workspace option and I wasn't sure if it's even appropriate for that. So I opted out for creating one manually.
There is a lot of info to take in on that page. All of it is well explained.
Maybe an example of how to create a WS using cargo commands would help. Relates to #11234 .
from cargo.
I see. This is more like a documentation issue than the resolver error message issue.
There are a couple of area to improve,
- Explain the behavior of a root package (or primary package or root mainfest, it has different names even in the source code 😓).
- Add
resolver = 2
to every code block that people might simply copy over. This might be too much though. - Add an example of, like your suggestion, creating a workspace step-by-stey
Alternatively, doing researches into #8365 or #5151 would also improve the current situation.
from cargo.
I think the original problem of this issue is resolved via #13505. We could keep this as a workspace doc enhancement request. Could you update the issue title and content?
from cargo.
In general, we need to improve our "best practice" documentation though that is covered with issues like #11234.
from cargo.
@weihanglo , I reposted it as #13580. Feel free to close this one.
from cargo.
Thanks. Closing.
from cargo.
Related Issues (20)
- Panic with "already borrowed: BorrowMutError" since nightly-2024-03-26 HOT 5
- cargo add --no-default-features displaying wrong feature selection HOT 3
- `cargo generate-lockfile` panicked when `--offline`
- Already borrowed panic (`BorrowMutErr`) during `cargo update` HOT 5
- cargo clippy error when using compile option --emit=obj, and crate-type = ["staticlib"] HOT 1
- Cargo `vendor` doesn't include dependency's hidden files HOT 3
- better support for generation and installation of associated files HOT 4
- Make `.cargo/config` deprecation warnings silent HOT 2
- Cargo runs unit tests when they are disabled and `--lib` is passed HOT 6
- Cargo clean removes target directory, even when it is a softlink HOT 3
- cargo should clone iced and smithay one time and partial HOT 1
- Access to compiler artifact notifications messages
- Cargo generate-lockfile picks dependencies that are too high for my current rustc HOT 1
- Build script allowlist mode HOT 3
- The built release by `cargo build -r` has the wrong format (Malformed Mach-o file) on MacOS aarch64-apple-darwin HOT 8
- -Zscript doesn't download dependecies HOT 2
- Unhelpful error messages with env-vars that don't set all fields of a config struct HOT 9
- Support for loading command line arguments from a file HOT 2
- `cargo package --list` shows different whether `.git` is present or not HOT 4
- Include cargo_vcs_info.json even for dirty working directories HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo.