-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feat]: Introduce a lock file for lint crates #251
Comments
Big thumps up, this is something I haven't considered thus far! I like the idea of providing a dynamic cargo command wrapper. For the naming, we could use something like
This sounds like a reasonable and easy solution. 👍 If we go this route, I would like the file name and location top be configurable under This is a suggestion in parallel to this and related to #250. Do you think it's interesting, to add an option to use a |
Yeah, it may make sense to have |
Yeah, that's sadly the trade off. Until #250, I didn't even consider the other option, of using a single command. We could try setting up a workspace with the crates in it. That might allow us to merge the lock files, while having a single build command? |
I'll try to look into this more a bit later. I don't think it's reasonably possible to merge all lock files, because all crates in a workspace need to agree on a single lock file and non-conflicting versions of dependencies unless each crate in the workspace pins specific version of them with I think a good place to strat is to study the behaviour of |
One way we could approach this, is to have a single build command for all crates by default with the This sounds like the most flexible solution, but would also means that we might have to maintain two solutions. If I had to select one, I'd probably prefer having a single Investigating |
The more I think about this the more I think that marker should follow a similar behavior that By default Based on that knowledge, and some personal thinking I am thinking of a model where marker has its own We may mimic the behaviour of We may also want to support downloading pre-compiled lint crates, right? I'm not yet confident on what the design for that should be, but having a shared |
Here it would be good to have some references, how a real project uses Marker. I imagined Marker to work on the project level, meaning that most lints would either be specific to one workspace or dependencies used in the workspace. Clippy and rustc, both have custom lints, which are included in the same binary (but Do you have the feeling that lint crates will be generally applicable? Or does this POV mostly come from the fact that "lint crates aren't actually library crates"? 🤔 There were also two other factors, which I no longer believe to be important, but it's still work listing them:
This is not to say, I'm against it, just that I want to understand the reasoning behind it :)
Yes, that would be really cool. It's not a must, but a nice to have |
I'm thinking that lints will be shared by the library owners. Yes, they will still be project specific, but for open source libraries the owner of the library may maintain a separate lint crate that would check the usage of this library. For example in For closed source projects the same will be true, because not all closed source projects are in one repo. Many of them have multiple repos with shared libraries that need shared lints. So in every workspace where you need the same lints for the same crate you would share them all from the marker's home. The problem that I see with this approach is for the lints that are used only in a single cargo workspace, and they aren't shared, because that workspace is for a project with an end binary. In such case it probably makes sense to use the same cargo lock of that project and it's target dir just like |
It does sound reasonable. I would think that we should still restrict Marker to only load the lint crates, that are listed in |
Yes, lints need to be specified in Cargo.toml of the project. This doesn't need to change. Another factoid, is that when having lints in a shared directory for reuse purposes they all need to be separated by their version, source (registry or git), etc. For example, if I specify [workspace.metadata.marker.lints]
marker_lints = "0.2" then Although that There is quite a lot of complexity here. Having everything under a project-specific target dir should simplify the design and implementation at least initially. Having a shared I know I'm switching ideas back-and-forth, but everything will settle when I work on code for this. |
Comments from #283:
|
One more problem that I've found with the approach of maintaining a separate lock file is in the following setup.
Running This makes me more inclined to have the behavior of running multiple The discussions in this issue mention a bunch of edge cases and tradeoffs, and there are lot of them. I'll try to summarize everything in one rfc document to describe the design. |
Context
Today
Cargo.lock
file for the internal cargo workspace created for building the lint crates isn't exposed to the users of marker.This means that every time
cargo marker
would run on a fresh CI environment the latest compatible versions of lint crates and their dependencies will be built.Even though, ideally one would think it should not cause any problem, but the real world is cruel. People may release a breaking change by mistake, or some crate could rely on the behaviour not included in its dependency semver guarantees. For example, I remember some crates that don't bump their major version if they increase the MSRV, or there are crates that simply don't care about the MSRV. There are so many reasons one could fuck up the semver compatibility..
It's also a security concern. You don't want to always use the latest version of your dependencies. That increases the risk that any of the dependencies in your tree introduces a malicious build script in the new patch version that would leak CI credentials.
Summary
This all led to the creation of
Cargo.lock
concept. Marker needs to continue exposing that to the users for its lint crates.I don't have a final design for this yet. What I see right now is the following.
Marker will generate a
Marker.lock
which is going to be just the copy of theCargo.lock
that marker uses internally. Marker will copy that lock file into the internal cargo workspace each time it does a build of the lint crates or better create a hardlink or a symlink.We need to provide the tools for updating the lock file
cargo update
, generating itcargo generate-lockfile
, reviewing the dependency treecargo tree
, auditing itcargo deny
, etc.Basically, we need to expose the users to managing the lock file for the internal marker's workspace.
I wouldn't like to have to write all the possible tools for managing the lock file in
cargo-marker
by hand. Besides the 3-rd party cargo plugins likecargo-deny
orcargo-audit
and any other ones that may arise in the future should also be supported.So I think there should be a dynamic
cargo
command wrapper incargo-marker
to run them inside the internal marker cargo workspace and update theMarker.lock
. For example a newcargo marker cargo
subcommand that allows runningcargo
inside of the internal workspace and it just forwards whatever is passed aftercargo marker cargo
tocargo
inside of that workspace.Naming could probably be improved here, but this is my first thought
Another area to explore is how to include the lint crates in the regular
Cargo.lock
present in the linted workspace. I don't see good options for that yet. The only approach I see with this would burden the users with creating a dummy crate for building the lints themselves.The text was updated successfully, but these errors were encountered: