Git Product home page Git Product logo

Comments (9)

weihanglo avatar weihanglo commented on June 15, 2024 1

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.

rohansx avatar rohansx commented on June 15, 2024

@rimutaka would like to take on this tassk

from cargo.

weihanglo avatar weihanglo commented on June 15, 2024

@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.

rimutaka avatar rimutaka commented on June 15, 2024

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:

image
Seems simple, but what do I put in # ...?

image
What's root package? I don't seem to need one. Skipping.

image
What's resolver? Why 2? I don't quite get it. Skipping.

image
This looks like what I need!

  • 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.

weihanglo avatar weihanglo commented on June 15, 2024

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.

weihanglo avatar weihanglo commented on June 15, 2024

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.

epage avatar epage commented on June 15, 2024

In general, we need to improve our "best practice" documentation though that is covered with issues like #11234.

from cargo.

rimutaka avatar rimutaka commented on June 15, 2024

@weihanglo , I reposted it as #13580. Feel free to close this one.

from cargo.

weihanglo avatar weihanglo commented on June 15, 2024

Thanks. Closing.

from cargo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.