#bevy_cli
1 messages · Page 2 of 1
I find myself not using them sometimes because I know how many gaps there are. Many of those cases are my fault, it's just hard to stay on top of when it is opt in.
Yeah, I find it quite frustrating to constantly be playing whack-a-mole manually
Still not sure of the right solution, but at least the problem is clearly recorded
Yeah. Not clear cut if it would be a good call, but I find myself leaning that way, especially because of all the other things reflection unlocks, especially when you don't need to worry if your deps have it set up.
e.g. serialization, validation, inspection, modding, networking, etc etc
Yeah. I want to see how an on-by-default lint changes the story here first but if we need to push it harder we can :p
forcing registration also gives us affordances for doing even more validation/registry type stuff at startup.
You can do a lot of cool stuff if you know that codepath exists for all ECS data
wen auto trait proc macro derive

@vagrant frigate has done some truly arcane stuff to work around this at work.
fyi it looks like there's a credible path towards auto-registration in Bevy 😄
linkme, and cargo metadata in macros at compile time
It's by the wayside right now but no linkme needed
Looks like inventory, I seem to recall that had some issues, don't remember what
Upstream problems in rustc IIRC. Seems resolved? We'll take a proper look in 0.16 though
@lapis scroll I'm writing a lint that allows users to force all components, resources, and events to implement reflect. Should I search for Reflect implementations, or is there another trait that I should use instead?
(Like I'm noticing PartialReflect and FromReflect... are there cases where those are enough, and should not raise a warning?)
(Or maybe Reflectable?)
Reflect should be enough
That’s what the derive contains and what manual implementors (if there are any) will most likely be using
Are there cases where a user cannot implement Reflect, and needs to fall back to another trait?
(Specifically for the case of components and resources?)
The only time you’d only implement only PartialReflect is if you’re creating your own custom dynamic type
Which is generally unlikely
Yep! No problem!
When I finish the lint, would you be interested in testing it?
If there's anyone who can find bugs / pain points in the lint, it would be you
Yeah definitely!
I can try to help review too if you need it
Another lint worth considering is trivial trait registrations like #[reflect(Serialize)] if the trait derives Serialize
Though you’d probably only be able to make that work for type data exported by bevy_reflect
Unless you have type/trait information available to your lint?
Yup, already have an issue for that!
Lints do have type checking results available, but I can’t directly evaluate code
By type checking, does that include access to what traits a type implements?
This suggestion seems trivial but I don't see a 🎟️ for it ... Would it be possible for there to be a lint that tells people to do this:
- commands
- .spawn(Transform::from_matrix(VOXEL_FROM_WORLD))
- .insert(IrradianceVolume {
- voxels: assets.irradiance_volume.clone(),
- intensity: IRRADIANCE_VOLUME_INTENSITY,
- })
- .insert(LightProbe);
+ commands.spawn((
+ Transform::from_matrix(VOXEL_FROM_WORLD),
+ IrradianceVolume {
+ voxels: assets.irradiance_volume.clone(),
+ intensity: IRRADIANCE_VOLUME_INTENSITY,
+ },
+ LightProbe,
+ ));
Yes, please make an issue!
precisely 🙂 Thanks!
Yup! That's currently how I check if there's a component that's missing #[derive(Reflect)]
I'm giving a talk on how the linter works next Bevy Meetup, if you want to learn more :)
If you want to see what I've done so far, you can take a look at https://github.com/TheBevyFlock/bevy_cli/blob/missing-reflect/bevy_lint/src/lints/missing_reflect.rs. Though I must admit I don't recommend it right now, since I have yet to cleanup and comment everything 😅
It gets a little crazy at times. I'm half convinced the Rust language designers introduced pattern matching specifically for compiler devs
It would be cool if this could be prevented: https://github.com/bevyengine/bevy/pull/15912
Can bevy_cli or clippy detect when module paths need hygene?
Basically looking for #[macro_export] and making sure all paths are qualified with $crate
That seems genuinely useful in the wider ecosystem, you should submit an issue to Clippy directly for it!
Ah, wait, turns out its harder than expected
Thanks for finding that for me
there was a talk about "expandable" at eurorust, a new tool to prove macro expansion https://github.com/scrabsha/expandable
Sasha (the author) would probably be interested about this kind of use case
Added to the linked PR 😄
The missing_reflect lint is now up for review! https://github.com/TheBevyFlock/bevy_cli/pull/139
(Though it's still missing module documentation and UI tests, but I'm working on that now!)
Two bug fixes for bevy run web:
Reviewed! (@royal void also got to them as well)
So we're at mid-October now (it's crazy to think that this all started a month and a half ago!). I've reviewed the bevy_lint 0.1.0 milestone (https://github.com/TheBevyFlock/bevy_cli/milestone/1) and parred it down to 3 issues left before release
My goal is to publish 0.1.0 by November 1st, so we're on pace
At this point I want to ask: what are the pain points of using the linter and the CLI as a whole, and how can we polish it before release?
I'm planning on publishing the linter even if the CLI isn't ready, since it's technically a standalone project, but I still want to coordinate and make sure everyone's on the same page
If there's any other issue that someone wants to add to the 0.1.0 milestone, now's your chance to speak :)
Detailed install instructions please!
The install instructions aren't just cargo install bevy_lint and then running bevy_lint in your repo? 👀
Is bevy_lint meant to require the specific nightly version to run?
I installed it with the following in a docker file
RUN rustup toolchain install nightly-2024-08-21 --component rustc-dev --component llvm-tools-preview
RUN cargo +nightly-2024-08-21 install --git https://github.com/TheBevyFlock/bevy_cli bevy_lint
And then in a separate stage copied the built executable (without the nightly-2024-08-21 toolchain)
COPY --from=bevy_lint /root/.cargo/bin/bevy_lint /root/.cargo/bin
COPY --from=bevy_lint /root/.cargo/bin/bevy_lint_driver /root/.cargo/bin
RUN bevy_lint
But this failed because the nightly-2024-08-21 toolchain is not in that stage (latest stable/nightly is).
What is the instructions so far for the cli anyways, I haven't kept up too much
Nevermind, got it figured out
Form the CLI side there are two main things:
- Bringing the web commands on par with the native counterparts, so that most cargo options seemlessly work for the web part too. This will also require more testing on how exactly cargo behaves (especially cargo build).
- Implementing the web --bundle argument. This will be needed for CI, e.g. to replace trunk in the quickstart template.
Unfortunately I am currently not able to dedicate as much time to open source as I want to, so I cannot say yet if it will be ready by November 1st
Nope, you need to install the nightly channel and components in rust-toolchain.toml
There are no installation instructions, which is why it's still in the 0.1.0 milestone :)
Yup, you also need to copy over the nightly toolchain. bevy_lint dynamically links to librustc_driver.so, so it won't work without that as well
librustc_driver.so can be found at ~/.rustup/toolchains/nightly-2024-08-21-TRIPLE/lib/librustc_driver.so
You may need to copy over other files that librustc_driver.so depends on
I was wondering, clippy also works with stable rust, but they ought to use the same APIs right? how do they do it, special magic because they are a rustup component?
Yup, special magic! Normally, linking to rustc requires #![feature(rustc_private)], but Clippy gets special privileges and can use that feature on stable Rust. (Just like the standard library)
Ok, that's fine! Are you cool if I still go ahead releasing bevy_lint, even though the CLI isn't ready yet?
Sure!
bevy_lint might imply that you can do workspace.lints.bevy. Is that true?
I believe you can! You need to add #![register_tool(bevy)] to the crate root, but then it should work
Let me test it real quick :)
Ah, nevermind. It appears to be currently broken
Two new PRs!
- https://github.com/TheBevyFlock/bevy_cli/pull/149, which fixes a crash when linting
bevy_reflect - https://github.com/TheBevyFlock/bevy_cli/pull/147, which greatly improves the public documentation for lints and lint groups
@rocky oxide thanks for the reviews! I realize that you're super busy right now, so I appreciate you taking the time to look them over :)
It's a pleasant distraction from the endless "oh god rendering is broken" bugs 😅
https://github.com/TheBevyFlock/bevy_cli/issues/150: bevy_lint currently cannot be published to https://crates.io because it depends on clippy_utils, which is a Git-only dependency.
Removing clippy_utils is challenging but possible, as it requires copying over everything we use from it. (https://github.com/search?q=repo%3ATheBevyFlock%2Fbevy_cli clippy_utils&type=code)
Embedding clippy_utils as a module (bevy_lint::clippy_utils) is distasteful, as it requires having a lot more code in the repository than what we usually need
I may have missed completely that discussion, but did you look at using dylint? https://github.com/trailofbits/dylint
Not publishing to crates.io means that users can't easily do cargo install bevy_lint, which I'd like to avoid
I have, but I'd like to avoid it if possible. bevy_lint was originally a Dylint project, but I had trouble using it and chose to start from scratch
I could look into it again, if that's the only good option, but it still wouldn't let us publish lints to crates.io
yup, but it has a nice syntax to add your linter from git in the cargo.toml file
Could we publish a fork of clippy_utils on our own?
if there are issues in dylint, it would probably be nicer for the ecosystem to improve it rather than recode from scratch
https://github.com/rust-lang/rust-clippy/issues/13556 figured we might as well ask
Description Over at the bevy_cli project, we're implementing custom lints for Bevy, and bootstrapping off of Clippy's existing tools :) We'd love to publish this to crates.io so folks c...
But we could say the same thing about Clippy 🙂
Like, I don't think that relying on Clippy's infrastructure is any worse than relying on dylint 🙂
And if we can prompt them to make it more reusable that would be great
dylint is an helper on top of clippy
Oh I see 🤔
Not exactly, they’re more like siblings
Standard linters like Clippy and bevy_lint fall into one category, while Dylint falls into another
How to address clippy_utils?
1
2
Description Over at the bevy_cli project, we're implementing custom lints for Bevy, and bootstrapping off of Clippy's existing tools :) We'd love to publish this to crates.io so folks c...
Clippy team seems interested in doing this for us 😄
@pale viper I'm now getting hundreds of errors when trying to cargo check main, this didn't happen before.
Did anything with the setup change? Was bevy_lint optional before and required now?
Nevermind, rustup update && cargo clean && cargo check fixed it :)
Yup! I recently bumped the nightly toolchain, so that would be it
@rocky oxide could you take a look at https://github.com/TheBevyFlock/bevy_cli/pull/152 ? It's a bunch of documentation improvements, especially on the rustdoc side. I could use your eye for writing :)
Are any of the issues available to work on? I was thinking about maybe trying my hand at this one
Yeah take your pick 🙂
Reviewed!
Hm, I'm trying to get started in Rust Rover, but it seems like none of the types are being resolved correctly. Getting things like Unresolved import: `rustc_lint`
Any idea what set up steps I might need to take?
Looks like things work correctly with VSCode + RA
Oof it's just an issue with RustRover: https://youtrack.jetbrains.com/issue/RUST-11921
Maybe it'll work in Fleet?
(or I could stop being a baby and use something other than IntelliJ)
Does Fleet use language servers, or Jetbrains's Rust-specific checker?
Yeah it’s weird. Gimme a sec I’ll pull up the error just in case there is something that we can do here
As for what you said above, feel free to pick one and and work on it! DM me if you need any help, rustc's internals are scary
Let me add some good resources to the CONTRIBUTING.md in https://github.com/TheBevyFlock/bevy_cli/pull/152 for getting started on lints too
This might not be specific to bevy_cli idk:
Failed to spawn one or more proc-macro servers.
- Failed to run proc-macro server from path ~/.rustup/toolchains/stable-aarch64-apple-darwin/libexec/rust-analyzer-proc-macro-srv, error: Custom { kind: Other, error: "proc-macro server's api version (5) is newer than rust-analyzer's (4)" }
Yeah seems daunting but possibly pretty fun. Just need a break from reflection for a bit lol
Haha I'm not entirely sure since it doesn't seem like they have a way to control what version you're using
And it's fine if we can't get it working. I'm just very used to JetBrains products so it would have been great to be able to work on it in one of those IDEs
It might not be language server in general, though, because version 4 and 5 don't make sense given the website: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/
This document describes the 3.17.x version of the language server protocol. An implementation for node of the 3.17.x version of the protocol can be found here.
Strange indeed. I'd try looking through Fleet's settings and bug tracker, but don't know after that
Yeah it's probably just Fleet honestly
I personally use VSCode VSCodium, so I can guarantee that will work, but I'm not sure if I'd recommend it long term
I've been trying to switch to a modal editor like Helix, since it helps when jumping between symbols in code
Yeah VSCode works fine, and is probably what I'll have to use if I can't find a solution
Using this hack, I can almost get RustRover working. Now I'm just getting hit with:
error: failed to run custom build command for `rustc_macros v0.0.0 (~/.rustup/toolchains/nightly-2024-10-03-aarch64-apple-darwin/lib/rustlib/rustc-src/rust/compiler/rustc_macros)`
Caused by:
process didn't exit successfully: `~/Projects/bevy_cli/target/debug/build/rustc_macros-9fcfb1b8cfc8bac6/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rerun-if-env-changed=RUSTC_BOOTSTRAP
--- stderr
error: you are attempting to build the compiler without going through bootstrap
help: see https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html for how to build the compiler
help: if you know what you're doing, set the RUSTC_BOOTSTRAP environment variable to any value
Documentation for the Kani Rust Verifier
Wait. I think I got it working
Okay so the trick is to not rely on RustRover's automatic Cargo.toml syncing
Instead, you have to first call cargo clean then build with cargo build or cargo check
(along with having added in the hack to your Cargo.toml)
Then autocomplete and stuff should work
Just don't click Load Cargo Changes lol
Anyone looked at updating bevy_new_2d for 0.15 yet? If not, I might do it as an exercise
I usually wait for the first release candidate, but if you want to work on it now then go for it!
@analog fern could you add me as an owner of bevy_lint on crates.io in preparation for its upcoming release?
My username is "BD103" :)
Yeah, I'll just start taking a quiet look. I think the changeset is going to be quite large and lots of users will need examples to migrate their own code, so we may as well start getting ready.
that error means your rust-analyzer is outdated
Yeah but I don’t think Fleet gives you control over what version it’s using :/
Switch off of Fleet I guess :p
First, can we talk about (or can you point me to) the plan for the management / governance of bevy_lint? Given the name, it seems like it should be an "official crate". But so far development has happened (to my knowledge) under the Bevy Flock umbrella without much oversight.
Forgive me for being out of the loop / if this has already been discussed.
Put another way, I was expecting the release of something like bevy_lint to be a "final" output of this working group, where the bevy_lint release happens under the bevyengine org umbrella after significant review of the implementation and ruleset
I would like to start getting user feedback and testing though, so it's worth discussing the best way to meet that need
There's only a few lints so far, and setup is a bit jank
But overall this seems very useful even now
Yeah it sounds like it would be worth getting this into user’s hands early
Though I suppose it could probably still happen through git preleases?
Or maybe alpha releases on crates.io if we want to save the “official” release for a more polished state
I'd also be really keen on a nice github actions for this, and testing that out on various ecosystem crates
cargo install --git https://github.com/TheBevyFlock/bevy_cli.git bevy_lint seems a good way to have it used without any release
Could you go into a bit more detail on what you mean by "management / governance"? In my interpretation that's very broad, and could mean a whole host of things
I'll try my best to answer, though. My plan was to release 0.1.0 early so that users could begin testing out bevy_lint, even if it lacked a complete set of features and had a few rough edges
As Alice alluded to, there are a few lints that can already be useful to others, namely missing_reflect and panicking_methods. I'd like to get these setup in Bevy's CI and a few other popular 3rd party crates so I can get some actual feedback on them
I originally planned on releasing 0.1.0 November 1st on crates.io, then making small releases from there. Before now I hadn't really considered that you may want more thorough review of the crate for each release
In my mind bevy_lint has always been "unofficial and unstable", so I didn't think it needed that level of (for lack of a better word) bureaucracy
I imagined (and hoped!) that it would one day become officially adopted, but thought there would be a few releases before then
I hope that somewhat answers your question! If you have any concerns, additional questions, or ideas, please let me know! I'd be happy with a lot of solutions, I just want my work to become actually useful to others 😅
Could you go into a bit more detail on what you mean by "management / governance"?
In my mind, the publishing of a bevy_lint crate under that name would be a signal to people that this is an official Bevy project, whose defaults and implementation have gone through the "normal" process (controversial changes reviewed by SMEs and maintainers). This is especially important for lints because they have significant effects for Bevy developers. Lints are defining what "correct" Bevy code looks like, so pretty much every lint change is "controversial".
In my mind bevy_lint has always been "unofficial and unstable", so I didn't think it needed that level of (for lack of a better word) bureaucracy
I think this is a great way to do it. My only qualm is doing it under the umbrella of the name we intend to use upstream. I think that blurs the lines too much.
There are a few lints that can already be useful to others, namely missing_reflect and panicking_methods. I'd like to get these setup in Bevy's CI and a few other popular 3rd party crates so I can get some actual feedback on them
I'm on board for this. Provided the relevant people review the lints being adopted and we scope the CI to those lints specifically. You choosing to merge a new lint shouldn't arbitrarily result in Bevy adopting it. And any changes to existing lints would need to be discussed and approved ahead of time with leadership.
I imagined (and hoped!) that it would one day become officially adopted, but thought there would be a few releases before then
I'd also love for this to be how this plays out! My preference is that you do this under a different name, and then we use bevy_lint for whatever we end up upstreaming.
(sorry I hit send too early, give me a second)
In my mind, the publishing of a bevy_lint crate under that name would be a signal to people that this is an official Bevy project, whose defaults and implementation have gone through the "normal" process
That makes a lot more sense, thanks for the explanation!
You choosing to merge a new lint shouldn't arbitrarily result in Bevy adopting it.
My preference is that you do this under a different name, and then we use bevy_lint for whatever we end up upstreaming.
I understand your concern there. Here's my proposed solution:
What if bevy_lint releases "alpha" versions, just Git tags for version 0.0.1, 0.0.2, etc. When you run cargo install, you specify --tag v0.0.1 to install a specific version. (We can then add crates.io later, if / when it becomes official.)
Having a version system means that maintainers can look over the changelog of stabilized and enabled-by-default lints in bulk. It also means that CI is far less likely to break, since it won't be targeting main.
It's a bit difficult to disable lints as of right now, since the [lints.bevy] and [workspace.lints.bevy] tables don't work, you have to add #![allow(bevy::...)] to each crate root. I'm planning on adding support for loading a bevy.toml file with linter-specific configuration to amend this, but that's a later thing
To add to this, only publishing on Git signals that the project is unstable and bypasses some issues we've been having with clippy_utils
Yup I'm cool with git-only publishing of alpha versions.
there's the package.metadata table for that in the Cargo.toml file rather than adding a new one https://doc.rust-lang.org/cargo/reference/manifest.html#the-metadata-table
Good suggestion! I'll make any issue for that
I think it would be good to prioritize linter config if the goal is to get projects like Bevy and popular plugins to adopt it
How do I convert a rustc_hir::hir::Ty to a rustc_middle::ty::Ty?
Trying to copy this from another lint ICEs:
let ty = cx.typeck_results().node_type(ty.hir_id);
(context: I'm using LateLintPass::check_fn to get the function's inputs which is a rustc_hir::hir::Ty list)
Okay I think this works (it's not blowing up at least haha):
let ty = cx.tcx.type_of(ty.hir_id.owner).instantiate_identity();
Not really sure how EarlyBinder and stuff works haha but I'm sure if I'm using it wrong, it'll come up in review (or here)
Nvm that seems to return the type of the parent 🙃
Could you send the error message? That should work, since you're within a body
Yup, Expr HirId is just a DefId of its parent (the function / body that contains it) and a local index relative to other Expr in that body
EarlyBinder is for<'a>, it's used to "define" new lifetimes and generic types. I would experiment calling it on different generic expressions, and see the results
(Take a look at no_bound_vars(), skip_binder(), and plain instantiate())
And in case I forgot to send you this before, look at https://rustc-dev-guide.rust-lang.org/, https://doc.rust-lang.org/nightly/nightly-rustc/, and https://doc.rust-lang.org/clippy/development/common_tools_writing_lints.html
Most of my existing knowledge is from those resources, asking on Rust Zulip occasionally, and calling dbg!() everything in lints
Is a feature that diagnoses system errors planned?
something like:
Please explain to me why this fn does not implement IntoSystem.
I just spent a solid 15 minutes debugging some obscure function signature just to figure out I forgot to wrap a Resource type inside a Res<>
Yes, though it may not be possible
Lints run after type checking, meaning the type needs to be valid for us to even inspect it
So while it is planned, it needs further investigation and might not be finished for a while
Sorry!
What axum and diesel does is to have an attribute macro you can put on things that need to implement certain traits, which rewrites the code slightly to generate better error messages. We can probably do a very similar one for systems.
bevy_system_check did this IIRC
Yeah I thought so too (once I learned that a Body includes the function arguments, assuming that's what it's referring to).
Not sure if you want the whole ICE, but here's the initial message:
error: internal compiler error: compiler/rustc_middle/src/ty/typeck_results.rs:334:13: node_type: no type for node HirId(DefId(0:10 ~ spoofed_name[9be2]::{impl#0}::build).11) (type `self`)
Ah okay that makes a lot more sense, thank you!
So how do you get the Ty if it only returns its parent?
What specifically are your trying to find the type of?
I want the type of the argument in the function signature. If it's a Commands, I want to see if we're taking a reference to it (i.e. &mut Commands). If so, we want the lint to suggest replacing it with an owned Commands and have callers simply reborrow
check_fn() should give you access to the FnDecl type, which gives you the input types
The inputs are HIR Ty, but you should be able to lower them with cx.tcx
Wait, but that would be node_type(), huh…
Oh wait! @lapis scroll you need to skip &self arguments, that’s the issue
Wait even if there's no receiver, it still contains a self?
Hm, it seems like it only contains a single type? This is the one I'm getting:
Yeah I'm using decl.inputs to get the input types
I'm not sure. Could you send a link to your branch on Github so I can test it locally?
Haven't made a branch yet since I'm still trying to get this part to give me the type haha, but i'll put one together
Also let me know if there's a better way to debug. I've just been emitting lints and running the tests haha
I'll take a look!
I usually put dbg!() macros everywhere and use cargo watch to repeatedly run the lint on an example file
It's a bit cursed, but it works 🤷♂️
@lapis scroll so I managed to fix the initial error by skipping self types, since those are special-cased by the compiler and don't have an associated rustc_middle::ty::Ty
if let TyKind::Path(QPath::Resolved(_, Path { res: Res::SelfTyAlias { .. }, .. })) = ty.peel_refs().kind {
continue;
}
But then I ran into a few other ICEs as well, so I just replaced node_type() with node_type_opt():
let Some(ty) = cx.typeck_results().node_type_opt(ty.hir_id) else {
continue;
};
In the above code, if the type cannot be resolved, it simply exits and moves on to the next function argument
This is the patch file for my changes. You should be able to call git apply fix.patch (great name, I know) to apply them locally
You shouldn't need to use TyCtxt::type_of() anymore, which is good since it doesn't work on expressions anyways. Let me know if you need anything else!
Oh awesome, thanks for the help! I’ll try the patch out tomorrow
If anyone has time for review, I have 5 PRs open that could use a set of eyes :)
#154 if a 2-line change, if you only have a minute (https://github.com/TheBevyFlock/bevy_cli/pull/154)
This seems to completely skip the Commands type in the test function
Or at least, it's not emitting anything for me
Yup, just tested it out and you're totally right
I found this Zulip thread that has a good lead: https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/Converting.20.60rustc_hir.3A.3ATy.3C'_.3E.60.20to.20.60rustc_middle.3A.3Aty.3A.3ATy.3C'_.3E.60/near/467947235
Looks like they suggest tcx.fn_sig() to find the rustc_middle::ty::Ty of the inputs
I started fiddling around with this, though it requires binders:
fn check_fn(
&mut self,
cx: &LateContext<'tcx>,
kind: FnKind<'tcx>,
_: &'tcx FnDecl<'tcx>,
_: &'tcx Body<'tcx>,
_: Span,
def_id: LocalDefId,
) {
if let FnKind::ItemFn(ident, _, _) | FnKind::Method(ident, _) = kind {
dbg!(ident);
let fn_sig = cx.tcx.fn_sig(def_id).instantiate_identity();
let inputs = fn_sig.inputs();
}
}
Not sure how to move on from here, though. Maybe open a thread in the Clippy channel on the Rust Zulip?
I’ll look into it
Sorry for not giving it my full debugging attention haha it’s been pretty busy
My first lint attempt!
https://github.com/TheBevyFlock/bevy_cli/pull/164
Before I take it out of draft, I'm curious if we should add support for the other re-borrowable types (e.g. Mut, EntityMut, FilteredResourcesMut, etc.)
Or I guess we could also punt that decision off into a followup PR
Yay!
I’m a bit busy right now, but I’ll take a look by Thursday :)
No rush. I barely have time to work on things these days anyways 🥲
so remind me, what is this group for again?
Linting and project-from-template workflows mostly 🙂
A Bevy CLI tool. Contribute to TheBevyFlock/bevy_cli development by creating an account on GitHub.
seems like it could connect up with this launcher people are prototyping then https://discord.com/channels/691052431525675048/1301174282893656167
I mainly beg people here to review my linter PRs 😅
Speaking of which, ||https://github.com/TheBevyFlock/bevy_cli/pull/163||
:D
Average open source experience
is this not controversial?
help me understand, this is on a different repo owned by a different org
whats the goal here?
Lol it was merged just as I was finishing my review with suggestions 😭
Follow up issues are just as good!
Sorry though 😅
We're looking to dogfood the linting tools for a bit on the main Bevy repo before announcing it as a proper product
And we want to make sure that any on-by-default lints have sign off from Bevy leadership
Since they can seriously degrade the developer experience and promote weird patterns if we get them wrong
To add on to what @rocky oxide said, TheBevyFlock is an organization owned by @trail shale that we throw prototype and unofficial projects on
bevy_new_2d is there, and so is flag-frenzy and bevy-bencher
The eventual goal with these projects are to flesh them out enough to see whether they could become official projects
While there's a good chance that bevy_lint will be upstreamed before bevy_cli (and the linter is designed with this in mind), they were started together
Let me know if you have any further questions! :)
I reached another milestone to get the Web UX on par with the Native UX. You can now just do bevy run --example breakout web and it works without further configuration!
Code still needs to be cleaned (and probably split) up, but the functionality is implemented.
at one point someone talked about auto-patching of repos
like, having the ci autogenerate cargo overrides for all the bevy crates
is that implemented?
Are you talking aboht this issue?
https://github.com/TheBevyFlock/bevy_cli/issues/79
I don't think that's implemented
Thanks to @ChristopherBiscardi for the original suggestion on Discord. If you depend on a fork of Bevy and want to patch 3rd-party plugins to use said fork, you need to use dependency overrides. Du...
@pale viper would you happen to have any insight here ?
I just want a span for the given middle::Ty 😭
I might just have to do my parsing via manually matching hir::TyKind if it's not possible
I'm not sure that's possible, unfortunately
Darn
There can be multiple hir::Ty for a single type String, but there will only ever be one middle::Ty for String
Yeah I wasn’t sure if there was a way to track the specific hir type
But it’s fine it shouldn’t be too hard to rewrite to use hir
It may be possible to find a list of all hir::Ty in a crate for a specific middle::Ty, but that sounds expensive
Speaking of which, this reminds me to review your PR. I'll be sure to do so by the end of today :)
Oh right haha. Again no rush lol
And complex. I’ll just rework it
Is it possible to walk the generic arguments of a type before lowering it to middle::Ty?
Not sure. I could try to see if there is. My current method is also a bit hacky:
/// Returns the [`GenericArg`] at the given index.
fn generic_at<'tcx>(ty: Ty<'tcx>, index: usize) -> Option<GenericArg<'tcx>> {
let mut walker = ty.walk().skip(index + 1);
let arg = walker.next()?;
Some(arg)
}
/// Returns the list of types inside a tuple type.
///
/// If the type is not a tuple, returns a list containing the type itself.
fn detuple<'tcx>(ty: Ty<'tcx>) -> Vec<Ty<'tcx>> {
if let TyKind::Tuple(items) = ty.peel_refs().kind() {
items.to_vec()
} else {
vec![ty]
}
}
I also considered making the check_ty operate on the generic type itself, then check for Query in the parent, but I think I ran into an issue there as well (iirc the parent ended up being the function rather than the Query)
But if that could work, then getting the span is trivial
Oh but then I'd still need to check if the type is in the QueryData position
Nvm then haha
Yeah matching the hir sounds like the simplest approach
I think I saw another lint in the repo do a similar thing to extract the span
Take a look at hir::TyKind::Path, which gives you a QPath::Resolved, which gives you a Path with an array of PathSegments, which should then have generic arguments
GenericArg::Ty has an hir::Ty, which can give you the span you're looking for
Yeah looks like insert_event_resource does this:
// This is some crazy pattern matching. Let me walk you through it:
let event_span = match events_hir_ty.kind {
// There are multiple kinds of HIR types, but we're looking for a path to a type
// definition. This path is likely `Events`, and contains the generic argument that we're
// searching for.
rustc_hir::TyKind::Path(QPath::Resolved(
_,
&Path {
// There can be multiple segments in a path, such as if it were
// `bevy::prelude::Events`, but in this case we just care about the last: `Events`.
segments:
&[.., PathSegment {
// Find the arguments to `Events<T>`, extracting `T`.
args:
Some(&GenericArgs {
args: &[GenericArg::Type(ty)],
..
}),
..
}],
..
},
)) => {
// We now have the HIR type `T` for `Events<T>`, let's return its span.
ty.span
}
// Something in the above pattern matching went wrong, likely due to an edge case. For
// this, we set the applicability to `HasPlaceholders` and return the default snippet.
_ => {
if let Applicability::MachineApplicable = applicability {
*applicability = Applicability::HasPlaceholders;
}
return DEFAULT;
}
};
I thought GenericArg was part of rustc_middle?
There's two structs with the same name lol https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.GenericArg.html?search=GenericArg
API documentation for the Rust GenericArg enum in crate rustc_hir.
I've never quite figured out how to differentiate between the two variants in code, since their imports would conflict
How would I get GenericArg?
The search results for return position don't seem to be very useful
Ah looks like I can maybe get it from the hir::Node?
From this message, Path.segments -> PathSegment.args -> GenericsArgs.args -> GenericArg
Oh I see
Okay I'll try to work on this some more and come back with any followup questions 😅
Yup! It's quite literally drilling through the type system
Cool! I'll be around most of today, so ping me whenever :)
Alright I think I got it working: https://github.com/TheBevyFlock/bevy_cli/pull/168
Are there any objections to moving some of the helper functions in this PR to a dedicated hir_parse_utils module or something?
I think I want to use them again for another lint (assuming there aren't any issues with them lol)
I don't like utils modules, but I admit it can be useful if you don't want a separate crate.
Yeah I know there's a similar sentiment among others (I personally don't mind a utils module, especially if properly scoped or given well-named sub-modules)
What if we called the module hir_parse?
On a related note, clippy_utils is pretty organized, but I do wish it were just a bit more organized haha. Or at least, given more descriptive docs
Better!
I can start with that and we can iterate as necessary
FYI I think I want to try and tackle this lint next
Essentially moving the runtime conflicting access check to compile time (via a lint)
My preference is to put utilities under crate::utils::category, so in your case crate::utils::hir_parse
It's really difficult to avoid utils modules in this scenario, unfortunately, so our best solution is to organize them super well
Sounds good. That’s normally my preferred way of doing things too haha. I’ll update the PR when I have a chance
Can we turn off the This workflow requires approval from a maintainer. for CI?
I just pushed changes that should fix my CI errors, but I can't see if they truly worked until the workflow is manually approved 😅
(it was a simple fix so I'm pretty sure it did, but I mean more for the future)
It’s only like that for new contributors! Once we merge your first PR it will go away :)
Oh I had no idea that was even an option. Neat!
Hey, do you people think it would sense to integrate a bevy-specific documentation generating process (basically rustdoc + extensions) for things like this #documentation-dev message into the CLI?
The reworked binary detection is ready for review: https://github.com/TheBevyFlock/bevy_cli/pull/169
It's a big PR, but hard to entangle unfortunately.
But with it, we can now run every bevy example in the browser without additional configuration!
What would be the steps needed to implement something like this?
- Run the parser, which creates mermaid files
- Run mermaid to create SVGs
- Include SVGs into doc comments
The last step is currently still manual, but it's wip. There were also ideas in documentation dev to automatically generate the docs with the process macro. So maybe it isn't needed after all.
Nevertheless I think it's a cool idea for a project as complex as bevy to automatically enrich the docs by things we can parse as an extra step before or after rustdoc
Sounds interestering. I suggest to create an issue in the bevy_cli repository to gather more input :)
Possibly, but we should really talk with rustdoc about first party support 🙂
They're very receptive!
Question: should the first release of bevy_lint support Bevy 0.14 or 0.15?
If it's trivial to support 0.14 might as well 🤔
We don't currently have the technology to support both, so we have to choose. Going for 0.14 will allow for quick adoption, but may hold back the ecosystem when 0.15 is released. Supporting 0.15 hurts people using prior versions who cannot update quickly
Can't we just ship an immediate follow-up version?
0.14 is currently supported, but 0.15 does not because some critical types (like Event) have moved, causing their hardcoded paths to change
That would work! I plan on supporting multiple versions of Bevy in 0.2.0, so picking one version is just for the initial 0.1.0 release
We can always backport to support older versions, as well, for the epic people at Foresight and such
This hardcoded path thing actually feels like something we could use string localization to solve
locale = bevy_0.14
Are you thinking something like fluent? That may be too connected to language in order to work, but I'm curious to hear your thoughts!
On another note, the PR that adds a README.md for bevy_lint is ready for review! (https://github.com/TheBevyFlock/bevy_cli/pull/170) This is the final blocker to getting 0.1.0 out the door, so I'm hoping to get a lot of eyes on it!
@rocky oxide and @twilit dew you may be interested, but no stress :)
Yeah, that was my thought. It's cursed, but I think it's fundamentally a good fit
Otherwise we end up having to write our own "map this special string to this other string based on a global config value" layer
Which isn't that complex, but the problem domain really feels like it has the same shape
Mostly a matter of pulling in the dependency or not IMO
(in theory we could localize help / error strings too, on the basis of language)
Reviewed
I think fluent requires valid Unicode language identifiers as locales, so we wouldn't be able to use it for this if I remember correctly
Did match allow ranges with anything implementing partial order? if yes, I would suggest to match on a semver object of the bevy version.
That would be simple to implement and only uses dependencies we already have
A browser interface to the Rust compiler to experiment with the language
Looks like you can't use range patterns on non-literals
match two {
PartialNum(0)..PartialNum(3) => println!("Yes!"),
_ => println!("Oh no!"),
}
^ results in compiler error
I do like the idea of using the semver crate! I was originally just going to have an enum with variants for major Bevy versions, but semver allows for a lot more control
(Especially since changes that aren't breaking for users could be breaking for us)
This nerdsniped me; more precisely you can't use range patterns on anything that isn't a char or a primitive number. You can use it with constants of those types as well as literals, but nothing else. There is also a nightly feature for inline const expressions in patterns, which lets you modify the code snippet to const { PartialNum(0) }..const { PartialNum(3) } and avoid the syntax error, but that still throws the same type error you get from using named consts.
Interesting! I know pattern matching is generally a "magic" feature, as there's not much you can do to extend it, but I wonder if it will ever support PartialOrd structs of all kinds
There's been some discussion of it that I found, but most pattern matching things use the marker trait StructuralPartialEq to ensure that the runtime and compile time behaviour agree when matching on constants; this trait can only be added by deriving PartialEq rather than manually implementing it. The decision a few years ago seems to have been that an equivalent would be needed for StructuralPartialOrd to ensure it is well behaved, but that it would end up being needing a bunch of attributes to control the derived PartialOrd for it to actually be useful in cases where a custom implementation is needed.
I guess a primitive if else also works although its not as pretty :D
<@&1064695155975803020> I believe bevy_lint is ready to kick off the release of v0.1.0! Please take this time to review its current features and documentation, then leave your review at https://github.com/TheBevyFlock/bevy_cli/pull/172. If you have any questions or issues that you want to bring up, please do not hesitate to ping me in this channel or on the PR. Thank you!
@pale viper just updated the borrowed_reborrowable PR and should be ready for review
I also think I fixed the problem with closures, but uncovered another issue in the process (made a ticket already)
I think it’s short for “type context”
Seems to be a convention from what I can tell
Which is also why I use cx instead of ctx. Just seems to be what’s used
(even though I typically prefer the latter haha)
huh, TIL
'tcx is the lifetime of the type context TyCtxt, which lives for the entirety of the compilation process
It’s similar to 'static in that way. It was introduced because most data is stored in long-lived memory arenas
Whenever a lint accesses the HIR, AST, or an evaluated type, it always works on references instead of owned data because of this fact
And just like that, v0.1.0 of bevy_lint has been released! (https://github.com/TheBevyFlock/bevy_cli/releases/tag/lint-v0.1.0)
Thank you all so much for your help along the way, I truly appreciate it 💙
I'm giving a talk this Thursday at the Bevy Meetup #7 (https://www.meetup.com/bevy-game-development/events/304078762/) about the linter, so I would love if you all would stop by and say hello!
I'd love to see what this looks like in CI on Bevy itself next 😄
I've run it on the engine a few times to ensure the linter doesn't crash, but I haven't yet tried fixing the hundreds of warnings :)
Yeah 🙂 I'd do an allow-all config first, and then turn on each warning one at a time
(in seperate PRs)
It probably won't be useful in CI until v0.2.0, where I plan on adding support for configuring lints for an entire workspace
Right, that makes sense
Of the existing lints, I think missing_reflect and panicking_methods would be the most useful, but also the most annoying to fix due to how many cases there may be :)
@molten merlin this is worth highlighting 😄
Agreed 😄
Slowly enabling it will be good
Ayy congrats on getting it out!
Thank you c:
ooo 7 AM... how dedicated am I 🤔 "we'll see" 😆
If someone has the time, could they review #173? It's a 3-line change that fixes the linter's docs at https://thebevyflock.github.io/bevy_cli/bevy_lint/
bevy_lint is a custom linter for the Bevy game engine, similar to Clippy.
The ) is messing up the link for me lol
Hey there im looking for a relative easy first issue to contribute to the linter. I found this https://github.com/TheBevyFlock/bevy_cli/issues/15 is this something that i can try to implement or should we wait to see if this will no longer be required after the addition from @ekuber as mentioned: https://github.com/TheBevyFlock/bevy_cli/issues/15#issuecomment-2336835073
IMO we should implement this rather than waiting
Go right ahead, that would be awesome! The contributing docs are a bit sparse, so let me find you some good resources to get you started...
Here are the nightly rustc docs, the Rust Compiler Dev Guide, specifically the section on lints (also check out the Analysis and Source Code Representation categories).
A guide to developing the Rust compiler (rustc)
All lints are inside of the lints module. Check out mod.rs for registering your lint and missing_reflect.rs for a good example
I recommend creating a late lint pass that overrides the check_crate() method for starters
API documentation for the Rust LateLintPass trait in crate rustc_lint.
You may even be able to create an EarlyLintPass, but I wouldn't worry about doing that right now
thanks for all the helpful links!
The most relevant crates to you are going to be clippy_utils, rustc_hir, rustc_middle, and rustc_lint. You may also want to familiarize yourself with the TyCtxt type, which lets you query information from the compiler
The central data structure of the compiler. It stores references to the various arenas and also houses the results of the various compiler queries that have been performed. See the rustc dev guide for more details.
Of course! If you run into trouble, please don't be afraid to reach out to me in this channel or privately. If I'm not around, you can also ask @lapis scroll questions, since he's also written a few lints :)
i will for sure :)
do you know how i can get the version of a crate? @pale viper
impl<'tcx> LateLintPass<'tcx> for DuplicatBevyDependencies {
fn check_crate(&mut self, cx: &LateContext<'tcx>) {
let bevy_crates = find_crates(cx.tcx,Symbol::intern("bevy"));
for bevy_crate in bevy_crates {
if let Res::Def(_, def_id) = bevy_crate {
// what now?
}
}
}
}```
Can you get it from the global context?
https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/dep_graph/type.DepGraph.html
API documentation for the Rust DepGraph type in crate rustc_middle.
I don't believe rustc has a concept of crate versions, only Cargo, so you may not be able to find what you're looking for
Check out https://doc.rust-lang.org/stable/nightly-rustc/rustc_metadata/locator/index.html, which is a fascinating read on how rustc manages multiple crates with the same name
For your case, I would just check if bevy_crates.len() > 1. Open a PR with that as a minimum viable lint, then we can work on better diagnostics :)
My thoughts are to fingerprint versions of Bevy's crates by checking if certain properties exist (such as structures that are added in newer versions, or removed in older ones), but I don't know how well that would work
You could also run cargo metadata to get a list of crates in the workspace, and check that for duplicates instead of going through rustc's lint process
Makes me appreciate cargo even more
Wouldn’t that be pretty annoying to maintain? I think i will give the cargo route a try after work
This RFC is relevant to our work here: https://github.com/rust-lang/rfcs/pull/3730
I talked about why Bevy uses "deny warnings in CI" as the dominant workflow: https://github.com/rust-lang/rfcs/pull/3730#issuecomment-2495657593
Interesting, thanks for sharing!
Description Over at the bevy_cli project, we're implementing custom lints for Bevy, and bootstrapping off of Clippy's existing tools :) We'd love to publish this to crates.io so folks c...
🥳
That’s awesome! I’m going to open a PR to switch us over to crates.io
Ok, PR is open for review! :)
If you're looking for early adopters of bevy_lint, I'd be open to trying it on my project.
I'd love that! What specifically are you looking for from bevy_lint?
I have 62k lines of bevy rust code in the game so far.
What am I looking for? Avoiding any common mistakes, writing mostly to best practices, being able to incorporate this into CI so I don't have to think about it. (I enforce clippy and fmt on my CI.) And helping to establish and clarify those best practices for the community.
I'm able to track main. I tracked main for 0.15 and it worked out well for me, by spreading a painful migration over time instead of hitting me all at once.
bevy_lint as a whole does three things: catch common mistakes, enforce a common style, and enable restricting your code. Common mistakes are things like calling init_resource::<Events<T>>() instead of add_event(), style are things like requiring all plugin names to end in "Plugin", and restrictions are lints that, for instance, let you force all components within a module to derive Reflect
In my case, I mostly use fn plugins, as I find them more concise. I only use struct Plugins when I need to finalize (for renderer plugins, mostly). But yeah, at least I could offer some actual on the ground testing.
If you want a quick plug-and-play experience, you'll get common mistakes and style enforcement out of the box. Restrictions require a bit more thinking, and depend a lot on how you structure your code
Common mistakes and style enforcement is a good place to start. Restrictions are probably valuable to me (maybe around things like "how to extend commands") but yeah, I'm willing to put in thought.
Awesome! If you want to get started running it locally, definitely check out the manual at https://thebevyflock.github.io/bevy_cli/bevy_lint/index.html
bevy_lint is a custom linter for the Bevy game engine, similar to Clippy.
Okay, I'll do that.
I can help you setup CI, since the installation is a bit strange :)
Let me know if you run into any road bumps! There's an issue tracker here if anything is annoying or bugged
Ok, I probably won't have time to fully tackle it until Monday.
Do note that bevy_lint only has official support of 0.14. 0.15 will work in most cases, though I know for a fact bevy::insert_event_resource is broken
Hm. This block is in bevy_new_2d, but it doesn't quite make sense to me 🤔 since there's nothing specifically platform-targeting here. Would a better description be, "Set max static log levels to debug by default, and warn for release builds"?
# Compile low-severity logs out of native builds for performance.
log = { version = "0.4", features = [
"max_level_debug",
"release_max_level_warn",
] }
# Compile low-severity logs out of web builds for performance.
tracing = { version = "0.1", features = [
"max_level_debug",
"release_max_level_warn",
] }
was gonna chuck it in minimal
the platform-targetting aspect is that tracing is responsible for the low-severity log spam in web builds and log is responsible for the low-severity log spam in native builds
i don't remember why
it is maybe an unnecessary detail to include in the comments
or at least confusing without an explanation
I see. So maybe context would be, "tracing can cause unwanted low-severity log spam in web builds" or the like
though tbh it probably would be unwanted in any release build
trying to track down the context: #1258521739395203174 message
interesting, Jan seems to be saying it'd be beneficial to disable tracing in debug too 🤔
i guess i never actually knew the reason for this
trace-level logs i think, which max_level_debug will filter out in both debug and release profiles
ah, of course
word overload
how 'bout just:
# Set max static log levels to `debug` by default, and `warn` for release builds. This helps avoid
# unwanted low-severity log spam.
log = { version = "0.4", features = [
"max_level_debug",
"release_max_level_warn",
] }
tracing = { version = "0.1", features = [
"max_level_debug",
"release_max_level_warn",
] }
possibly with a "which can affect performance"
i'd say specifying the debug by default and warn for release builds is redundant since you can see those specifics by reading the following lines anyways
fair enough!
I'll leave you to https://github.com/TheBevyFlock/bevy_new_2d/pull/318 🙂
did you ever figure out what to do with the ChildBuild stuff?
yeah, it's possible the whole spawning bit might change anyway
What can I do to move https://github.com/TheBevyFlock/bevy_cli/pull/169 forward? Does the PR need to be smaller to be reviewed?
That's a good PR. I don't have time to test it myself on various workspaces to make sure it works as intended, but it looks good to me.
I think that it's not too big
This feels like the kind of PR where you just have to nag people for review until it happens. Being able to run web projects without any setup is really exciting to me, so I'll give it a review tonight (EU time) unless others beat me to it
Awesome, thanks!
Oh I also just noticed there are merge conflicts now, Ill resolve them asap
Conflicts resolved!
I was planning on reviewing it, but I took a small break with bevy_lint v0.1.0 and Thanksgiving
I'll take a look today or tomorrow :)
I've done a bit more work on the contributing guide for the linter! It now has more content than the release checklist, as well as a plethora of additional resources linked. Check it out!
It even uses the fancy documentation system that I've seen linked in this server so often :)
😄
Didn’t know that and just watched the talk. Was very pleasant and informative to watch definitely a great speaker.
But it showed me even more that i definitely need to step up my documentation game😅
Thank you! I’m one of the few people that I know that actually enjoys public speaking :)
Yes, but the documentation requirements for bevy_lint for unique. I probably would go this far in other projects
Mainly: The rust compiler has poor API docs, the people reviewing and contributing are almost always unfamiliar with the code, and I’m trying to make the linter as maintainable as possible
I want the linter to be a community project, not a pet project, so that should I move on or become too busy it doesn’t stagnate
We’re not there yet, but it is a goal I have in mind! :)
Yea totally especially once the linter gets more adoption
error: Mismatching versions of `bevy` found, expected crate to be using bevy version: 0.14.2 --> Cargo.toml:9:11 | 9 | avian2d = "0.1.2" | ^^^^^^^ | = note: `#[deny(bevy::duplicate_bevy_dependencies)]` on by default Not sure what the best lint message should be that gives enough information without being confusing, what is your opinion?
What about this?
error: Mismatching versions of `bevy` found
--> Cargo.toml:9:11
|
9 | avian2d = "0.1.2"
| ^^^^^^^ Note: `avian2d` depends on `bevy` 0.14.2
Help: Expected all crates to use `bevy` 0.15.0
Add a note to the main span, saying the incompatible version of Bevy being pulled in
Then add a help message saying the expected version
Optionally, you could also add a span to the help message pointing to where the bevy crate's version was originally defined
error: Mismatching versions of `bevy` found
--> Cargo.toml:9:11
|
9 | avian2d = "0.1.2"
| ^^^^^^^ Note: `avian2d` depends on `bevy` 0.14.2
Help: Expected all crates to use `bevy` 0.15.0
|
7 | bevy = "0.15.0"
| ^^^^^^^^
(please ignore the poor formatting 🙃)
I like this one
https://docs.rs/inquire/latest/inquire/
Dropping this here incase it might be useful for CLI
inquire is a library for building interactive prompts on terminals.
Are y’all using a custom error/report type or anyhow/erye/whatever?
iirc at the moment just anyhow
Thanks! I think we're using dialoguer right now for this, but I'll look at inquire to see if it's better
dialoguer is a library for Rust that helps you build useful small interactive user inputs for the command line. It provides utilities to render various simple dialogs like confirmation prompts, text inputs and more.
anyone knows of this: https://docs.rs/semver/latest/semver/struct.VersionReq.html#method.matches but to see if a VersionReq can match another VersionReq
SemVer version requirement describing the intersection of some version comparators, such as >=1.2.3, <1.8.
Hmmm is it possible to convert a VersionReq to a Version?
I could see that getting weird quickly though, VersionReq does implement PartialEq and Eq
What problem are you running into, specifically?
my problem is, i get a Vec<VersionReq> of crates that use bevy from cargo:metadata. Now i need to decide if these versions match or not. As you mentioned they do implement Eq and PartialEq so checking if they are the same VersionReq is easy but seems like it will often lead to false positives.
this is more the case if the project does not also depend on bevy itself in its cargo.toml. I thought it would be nice to just give a lint "mismatching versions found" in that case while if we have a "target" version defined in the Cargo.toml we would output this
Hmmm, that's tricky
I'm not sure how much it applies to your situation, but Cargo.lock contains the resolved versions of all crates
yea was searching for a "resolve" method in the semver docs
would be so nice. I will check the resolved crates tomorrow iirc they should be part of cargo metadatas output
@pale viper do you happens to know how to use rustc_interface::run_compiler to compile crates including dependencies? I'm currently using this config but I can't figure how to make rustc create any rlib file so I can pass them to dependent crates as extern.
I have this snippet of my config here. I'm using this to compile recursively through all dependencies. The first crate to get compiled should be the one with no dependencies. In my testing, it did compiled and print out some types but I can't figure why rustc isn't making any file.
So the first thing is that rustc cannot compile multiple crates at the same time, but Cargo can
If you want to compile dependencies, you need to override which rustc Cargo uses
bevy_lint does this by separating into two executables: bevy_lint, which acts like cargo check, and bevy_lint_driver, which acts like rustc
To override the rustc that Cargo uses, set the RUSTC_WORKSPACE_WRAPPER environmental variables to the path to your custom rustc
Then anytime Cargo needs rustc, it'll run your_executable rustc --actual --arguments
Check out https://github.com/TheBevyFlock/bevy_cli/tree/main/bevy_lint/src/bin to see how the linter does this
Thanks, for the explanation.
Though Isn’t cargo just a wrapper over rustc? I’ve seen people says that quite often. Running cargo build -v also shows exactly what rustc commands it uses. I’m curious how to does like what cargo does.
Yes, but Cargo manages building all of your dependencies into rlibs before it compiles your actual crates
Alright thanks, Ill come back to this tmr.
Of course! Let me know if you have further questions :)
@lapis scroll I finally got around to reviewing borrowed_reborrowable. If you have a chance, could you merge https://github.com/MrGVSV/bevy_cli/pull/1 so that we can finally ship the lint?
Awesome! I’ll try to merge it either tonight or tomorrow when I have a chance!
do rustc_interface dont create any files what so ever? I pass OutFileName::Stdout to most options but nothing every shows up in the stdout. print requests -> nothing, output_di -> nothing, output_file -> nothing.
running rustc as a command itself seems to do something at least
oooh wait
i think i get it now
rustc_interface is only used for interfacing but not a direct rustc command replacement
I have to use rustc directly to actually get stuff to compile. that's probably why running commands from the result of cargo --verbose works but through rustc_interface didn't. Those output options is a scam.
Also, you guys might want to consider adding configuration for running cargo without using toolchain proxy for folks who installed cargo and other components without using rustup, eg. via nix.
Mostly yes, if you want to actually mimic rustc you can use rustc_driver
Would you mind opening an issue in the github repo for this?
I tried to summarise here: https://github.com/TheBevyFlock/bevy_cli/issues/194
Thanks!
👋 Hi, haven't been following here. What's the status of
Out-of-the-box support for bundling projects into WebAssembly
Any design work done already? Anything I can help with?
Im not that familiar with Wasm but i think the bevy build command supports this
Hey!
Thats my focus area ATM :)
The status is that we can already run most apps without additional setup for the web with bevy run web, but for bevy build web not all arguments are supported yet that you know from cargo build.
Also, bundling all files into a single folder you can host is not implemented yet.
I hope to make progress there over the holidays
You can follow https://github.com/TheBevyFlock/bevy_cli/issues/68, that's probably what you are looking for
Cool, thanks.
Im playing around a bit with ui tests for cargo lints.. does someone know how i can get rid of the --edition flag? ```rs
fn run_ui_cargo() -> color_eyre::Result<()> {
let mut config = Config {
host: Some(String::new()),
program: CommandBuilder {
program: "bevy_lint".into(),
args: vec![],
out_dir_flag: None,
input_file_flag: None,
envs: Vec::new(),
cfg_flag: None,
},
..Config::rustc(Path::new("tests").join("ui-cargo"))
};
config.program.input_file_flag = CommandBuilder::cargo().input_file_flag;
ui_test::run_tests_generic(
vec![config],
|path, config| {
path.ends_with("Cargo.toml")
.then(|| ui_test::default_any_file_filter(path, config))
},
|_config, _file_contents| {},
status_emitter::Text::from(ui_test::Format::Pretty),
)
}
A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/ - rust-lang/rust-clippy
output: ```FAILED TEST: tests/ui-cargo/duplicate_bevy_dependencies/fail/Cargo.toml
command: "bevy_lint" "--manifest-path" "tests/ui-cargo/duplicate_bevy_dependencies/fail/Cargo.toml" "--edition" "2021"
config.comment_defaults.base().custom.clear();
``` does the trick
I've opened https://github.com/TheBevyFlock/bevy_cli/pull/195, which adds the --bundle option to bevy build and bevy run.
It will create a folder with all things needed to deploy the web app, placing it in the target folder (for easy cleanup).
@lusty galleon can you take a look if this is what you had in mind and maybe test it on a real-world project if you have one?
Once this PR is completed we can also port bevy_new_2d from trunk to Bevy CLI (https://github.com/TheBevyFlock/bevy_new_2d/pull/312)
Is there some particular project structure that's being assumed? Seeing this output:
bevy build web --bundle
Compiling to WebAssembly...
Finished `dev` profile [optimized + debuginfo] target(s) in 0.16s
Bundling JavaScript bindings...
Error: No such file or directory (os error 2)
Attempted tossing my index.html in ./web/, ./assets/web/, and ./, but same output.
(project is https://github.com/rparrett/pixie_wrangler, building on macos)
Interesting, I'll investigate
bevy run web did work (after removing custom canvas and the various custom index.html I flung around above)
FYI, in your case you can probably just remove your index.html, we will provide a default one which also adds a loading screen
Yeah, I don't think this particular project needs a custom index.html.
But I'll still try to fix your current setup, maybe I missed to consider something
I found two bugs with bundling up the assets and custom index.html, your project works for me now (after changing the import path to ./build/pixie_wrangler.js)
Cool. I'll give it a go in another project that actually uses some custom html and static assets and just see how that feels.
I think that some feedback for the cli user around what is going on with the "custom web" directory would be helpful. Just a "No web directory found, creating default content" or whatever.
And just a note on https://github.com/TheBevyFlock/bevy_new_2d/pull/312: in its current state, we're losing wasmopt.
Good point, I should add that before we migrate.
I wonder how to design the arguments for that, just an --optimize flag or do we need more customization?
IMO being able to toggle wasm-opt and also override the args used for optimization would be nice. I don't think the options are one-size-fits-all, there are tradeoffs.
(but bevy_new_2d's setting is a good default)
Awesome! I'll take a look after Christmas 🎄
I guess for the first iteration I'll just go with something simple that works for most use cases and then we can improve on it further down the road
I assume at some point we will want to add a bevy.toml that allows for more customization, without having to define very long arguments every time
Added a message!
Created https://github.com/TheBevyFlock/bevy_cli/issues/196 to track this
Instead of bevy.toml, I'd much prefer putting configuration in Cargo.toml under the metadata table
That's the approach I'm leaning towards with the linter
after Christmas when you have some time could you take a "first" look at https://github.com/TheBevyFlock/bevy_cli/pull/185@pale viper (the tests don't pass in CI yet
)
Of course! I look forward to it, this lint is going to be very useful :)
Merry Christmas!
I opened a PR with which we use custom default profiles for the web builds.
This allows us to use better default configurations and makes it easier for the user to customize it :)
https://github.com/TheBevyFlock/bevy_cli/pull/199
@pale viper I think a github milestone for the MVP of the web features (i.e. bevy build web and bevy run web) would be useful to track what still needs to be done.
Afterwards, I would announce the progress more prominently here on Discord to find more people to test everything.
What do you think?
I guess a project would also work, not sure which is better
Ok! I just created https://github.com/TheBevyFlock/bevy_cli/milestone/4 for tracking bevy_cli's v0.1.0 release
Would you prefer I scope it specifically to the web features, or would you rather keep it general?
Projects are great for organizing lots of issues, but milestones work well when you just want a single list :)
Using it for 0.1.0 also works for me :)
Would maybe also be cool to add it to the bevy website: https://bevyengine.org/learn/quick-start/getting-started/
True! But I think that probably needs to happen after the initial release and after the CLI is "blessed" by the maintainers
Yes yes that’s for sure!
I'm definitely looking forward to make the CLI official though!
Especially for game jams I think it will make a big difference, enabling everyone to test their game in the browser from the start
In other news, I opened https://github.com/TheBevyFlock/bevy_cli/pull/206, which adds a feature flag to run wasm-opt on the binary in release mode.
Once all open PRs are merged, we should be ready to procede with the migration to Bevy CLI in the 2d template
Yes i think so too! Im very excited to see where it goes
I would start working on this after New Year's: https://github.com/TheBevyFlock/bevy_cli/issues/138. If the linter would get blessed, could we add annotations to bevy that helps autogenerate these: https://github.com/TheBevyFlock/bevy_cli/blob/main/bevy_lint/src/paths.rs ?
The linter should support being configured for a specific version of Bevy, likely through some form of configuration (#113). It could also be feature-flagged, though that could become quite rigid.
If you would like, though I have a few specific ideas for the design!
I've been working on a system to configure lints in https://github.com/TheBevyFlock/bevy_cli/tree/lint-config. My thoughts are that we can store the desired Bevy version there
Then lints can do something like:
let is_past_0_14 = with_config(|config| {
VersionReq::parse("^0.14.0").unwrap().matches(config.bevy_version)
});
Hard-coded paths will probably need to be switched to a HashMap or BTreeMap, so we can dynamically adjust them based on the Bevy version
As you mentioned, I would like to move many of these hard-coded paths to diagnostic items, but I worry that's too much of a commitment on the engine side
A guide to developing the Rust compiler (rustc)
More-specifically, the linter should probably be blessed and upstreamed before we begin making changes to the engine for our own benefit
Yes exactly i was more thinking long term. Until the linter is blessed and moved upstream i think hard coded paths are fine
Will take a look Tomorrow thanks for all your input!!
Only if its fine for you i just looked into the milestone and saw that you didn’t add this to your work log. If you have been looking forward to it i will do something else😊
I may try my own implementation this week, but don't let that stop you! We can compare notes and find the best solution :)
I see that in the linter this is often used with a similar comment above it
let src_ty = cx.typeck_results().expr_ty(src).peel_refs();
do we want to move it into a helper function in src/utils/hir_parse.rs?
something like ```rs
fn get_src_type(cx: &LateContext<'tcx>, src: &Expr<'tcx>, peel_refs: bool) -> Ty<'tcx>
I’d rather not. Creating a utility function requires an extra import, and hides what it’s actually doing
If getting the type of an expression was more complicated, I may be convinced, but in my opinion it’s not worth it for a single line of code
makes sense yea, it would have been more to avoid having to document the same thing multiple times. But perhaps its enough that its already explained in how-to/types.md
Yeah, it’s good for people to learn how to use LateContext and TyCtxt directly, instead of hiding it behind too many layers of abstraction
Happy new year, let's make it the year of Bevy CLI :)
Happy new year!🎆 Thank you for all your hard work and support!
Let’s goooo! With the new year, we should have some goal for when the CLI and linter get blessed
Maybe say we want to have them in a good working state by June, for instance
Then we can plan and schedule what needs to be done!
The biggest way to get blessed is through actual user adoption. With the CLI, that can be done by adding it to popular Bevy templates
For the linter, it could also be added to templates, but I also want to introduce it to the main engine’s CI
I think for the linter 0.2.0 is very important!
Yes the cli has some very handy features. Maybe if some of the content creators start using it in their guides etc
@molten merlin maybe you’d be interested in covering a tutorial on using the CLI and linter, once they hit their next release? Only if you think they’re good tools, though, I don’t want to pressure you!
I think the next step for the CLI will be to just announce all the new features on #showcase.
And we are getting quite close to do that IMO, the web functionality has come quite far.
If users think he features are good, adoption will follow naturally.
For the future/bigger features we will probably also need a bit more formal discussion with the broader Bevy community, I've seen some complaints that our working group is a bit less formal and doesn't have a full design document etc :D
yeah absolutely. Are the install instructions the same as the november release currently? I'll start playing around with it more.
I think cargo install --git https://github.com/TheBevyFlock/bevy_cli should work.
You can try out the bevy build web and bevy run web commands, which should allow you yo build and run your game in the browser with zero setup.
You can also try the --bundle option which bundles up all the web assets into a folder for easy deployment
does it still require nightly?
Adding more user facing documentation (or rather, adding some at all) is going to be my next priority
Nightly is only a requirement for the linting stuff
(And I'm not 100% sure if that still applies, @pale viper will be able to clarify)
I started a design document so we can more formally discuss the web functionality of the Bevy CLI: https://hackmd.io/@timjen/bevy-web-initiative/edit
Feel free to review and improve it!
Will take a look in the evening! thanks for starting one
The linter requires nightly, but the main CLI does not :)
The two are installed separately, but are designed to play nice together
looks really good!! I think for the 0.1.0 release I would still like an overarching document. I envision that the CLI would be a central part of a future editor and i think we need to provide some more structure on how this could look. There we could link this as a "first feature" together with the ability to run the linter.
True, design docs for the other features would also be useful!
The command also requires to specify the package/binary:
e.g. cargo install --git https://github.com/TheBevyFlock/bevy_cli bevy_cli (just leaving it here for anyone looking for the way to install bevy_cli specifically)
Ah thanks, I thought that cargo install would also use the default_run attribute, but apparently not!
Is bevy_cli designed to work in a CI environment? Either I'm missing some flag, or it's not supported atm 🤔
https://github.com/vladbat00/bevy_egui/actions/runs/12620032025/job/35165252825
Run bevy build --example color_test web --bundle
bevy build --example color_test web --bundle
shell: /usr/bin/bash -e {0}
env:
CARGO_HOME: /home/runner/.cargo
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
CACHE_ON_FAILURE: true
Error: IO error: not a terminal
Caused by:
not a terminal
oh I guess it's trying to prompt for wasm-bindgen install or smth?..
oh, I'll try it with the --yes flag
Yes exactly! This should just install the needed dependencies
worked flawlessly, thank you! 😊
love how the bundle command works, really just 1 command, zero configuration - and it's ready for deployment. Got all my crate's examples on github pages now :)
https://vladbat00.github.io/bevy_egui/ui/
Glad that it works well for you!
I suppose we should improve the error message in CI, hinting to the --yes flag
Created https://github.com/TheBevyFlock/bevy_cli/issues/212 to track this
PSA: https://github.com/TheBevyFlock/bevy_cli/pull/191 is being merged, meaning the linter now officially supports Bevy 0.15. You may need to update your PRs, especially if you introduce new paths
Hopefully we'll be able to re-introduce 0.14 support, but for now it's just 0.15 :)
that's huge! 
what's the status of this? can i just point this at a bevy repo and have it work?
These are still some Setups where it won't work as expected, e.g. when you use custom asset folders.
But most repositories should work, feel free to try it out!
Testing more real world projects is quite valuable to us at this stage
I tried running bevy_cli new and got this message, which could probably use an explanation if its going to request to run
bevy build currently prints an error about reserved profile names after initializing a project with bevy new
Ah, that's my bad. The profile name itself and the folder name in the target folder isn't the same for dev profile for some reason, I have to special-case it
@limber wedge Sorry for the delay reviewing #185! I have finals this week(end), but I'll review it in full by the end of next week :)
No worries! I also have finals this month so i dont have much time :(
Good luck to you!!!!
(But i cant wait to get back im so excited to continue working on the linter) stupid university 
You as well! :D
Hm, would it be possible to lint for transforms with scale = 0?
some animations and things might want to shrink objects to a scale of zero (for e.g. a vanishing animation), or even have objects smoothly changing between positive and negative scale for a kind of mirroring effect
I probably wouldn't have a runtime warning for that, even if these cases are niche
Ah yes the classic ps1 technique of "shrink it out of existence"/j
What all Lint's are currently in the linter?
I tried finding a list but couldn't
I don't think there is an up to date list.. yet. For now the easiest way is to probably just check here: https://thebevyflock.github.io/bevy_cli/bevy_lint/lints/index.html
All lints offered by bevy_lint.
Made an issue to add lint for bad system param setup
https://github.com/TheBevyFlock/bevy_cli/issues/217
I made a comment, but have you checked out borrowed_reborrowable?
Checks for function parameters that take a mutable reference to a re-borrowable type.
ahh the name didnt sound like what i was facing but reading it now yea might as well kill that issue
can someone merge the 0.15 update for the minimal template repo that the cli pulls in? https://github.com/TheBevyFlock/bevy_new_minimal/pull/15
Done
thanks!
Should be fixed by https://github.com/TheBevyFlock/bevy_cli/pull/219
Lint to favor println! over print!
yea.. Made that mistake and gave me hell of a headache.
print! Doesn't work in anything till you close the app
I opened a PR which adds some E2E tests for bevy build and bevy build web which should prevent such regressions in the future:
https://github.com/TheBevyFlock/bevy_cli/pull/222
Sorry Chris, I should have been keeping a closer eye on this. We should probably also update bevy_new_2d by merging @near mist ' PR although I know there was some discussion around the ChildBuild stuff.
it's still an incredibly convenient resource to refer people to for e.g. fn plugins, project structure etc.
I can give a review on the rc upgrades and make sure it runs, etc. I don't really have an opinion on the childbuild stuff though as I don't use this template myself and think the extension trait is awkward already.
this has a failing test that needs to re-run before it can merge. there's a comment on the PR about shared lib locations. not sure if this changed from previous PRs or if this test was always failing.
I expanded the README with a basic overview of the web functionality:
https://github.com/TheBevyFlock/bevy_cli/pull/223
install command seems like it needs an update, otherwise seems good
cli generally is now working for me with 0.15 in the minimal template and the newest dev/debug fix
Whoops, not sure what happened there. Thanks for catching it!
Awesome! Any pain points you noticed / features you're missing?
not at the moment, I haven't used it much yet because of the previous dev/debug issue so I'll use it more over the next week or so. Just running through the commands (run, web, etc) and making sure they all work at the moment
do we have some sort of watch already?
actually, would be nice to be able to dump the current index.html to a file
Try bevy build web --bundle
sure, but building the entire application to write out an index.html file so I can customize it is not really a great solution
No, but that's something I'd like to look into.
Maybe it's possible to use bacon for that to avoid having to build an entirely custom solution. Although for the web we will have to customize it a bit.
Asset hot reloading for web builds is also on my list, but will also be complex
That's fair, although you typically only have to do it once.
Would you prefer a custom command for it?
yes thats what im using on some projects works really well
rustfmt has rustfmt --print-config default rustfmt.toml. I think if the CLI is providing default files it should be able to provide them without requiring workarounds through unrelated commands
Works for me, I created https://github.com/TheBevyFlock/bevy_cli/issues/224 to track this
i'll take a look at that today
tyty
CI is now passing: https://github.com/TheBevyFlock/bevy_new_2d/pull/318
i changed the rules temporarily to merge this since it has an approving review from @toxic quartz and the update to 0.15 is overdue anyways
I'm not sure I understand. As far as I know, print!() is just println!() without the trailing newline \n
Prints to the standard output.
Are there some logging shenanigans that I'm unaware of?
print!() doesn't clear the buffer, so nothing get displayed until the buffer is cleared. the easiest way to do that is to print a \n, which println!() does
but if you want to get into details, there should be a lint against both print!() and println!() because they will both destroy your performances as they perform blocking io
Neat, TIL!
Should the lint recommend using tracing's macros instead, such as info!()?
yup!
that's one of the main reason to use a log backends instead of just printing, it buffers the write, and often does them in another thread
I still use it for basic "did the code actually reach this point?"
Useful when shit isn't happening and can't tell if its your system not running or if its the conditions in the system.
Please see this message on Discord for context. recommend using tracing's macros instead, such as info!()
Based on the discussion is this something of value or rather not since it „should go away“ at one point or another?
I think a pair of style lints for both ..default and Default::default are very reasonable
same, but it's not that hard to get in the habit to use info!() instead
What would they favor anyways?
I usually do ..default()
Either! Style lints often cover both sides of a contentious but pointless decision
Just to enforce consistency
I was imagining a deny lint against using ..default() while implementing Default what did you have in mind so i can add this to the issue for more clarity 
The linter enables style lints by default, so I'd probably put both of these lints into the restriction category instead
Opened a refactoring PR to de-duplicate the web build logic: https://github.com/TheBevyFlock/bevy_cli/pull/231
After that is merged, I will probably play around with the web multi-threading
I'd also appreciate more feedback on the web design document.
Should we create one unified design doc on the whole CLI instead, as @limber wedge suggested? Or would that become too big / to hard to gather feedback on?
Is there anything about the proposed design / vision that I could improve?
When should we move forward to "release" this as a Bevy discussion to get feedback from the broader community?
i don't necessarily mean one unified doc but i think we are not doing the template functionality and other ideas justice if we don't also give them a space. i don't know how you do it for bevy normally but i imagine a top level document for the cli and then just sub categories (maybe as a link to another document) for the specific bigger features like the web stuff?
i like the doc a lot!! i have read it a few times and never had anything i thought needs to change
Yea, definitely agree we need something unified.
For the template functionality we also don't have a brief user introduction in the README yet.
For the design doc it's a little difficult, because I assume we want target feedback about specific topics.
Since the topics are so big individually, the discussion around all of them together could get messy.
But I like one unified doc which serves as "entry point" and then e.g. linting and the web stuff being separate documents that are linked to
Opened a PR to support cargo's --config argument, which (essentially) allows you to modify Cargo.toml without editing the file:
https://github.com/TheBevyFlock/bevy_cli/pull/209
We can use this to find the best default web compilation profiles for Bevy without much hassle!
o nice! i will take a look tomorrow
@limber wedge are you DaAlbrecht on GitHub? What's the status on your two lint PRs, shall I review them or is there anything else needed to be done?
Yes thats me
i think this one could use a review: https://github.com/TheBevyFlock/bevy_cli/pull/210
To be fair the other one could use a review too. The cargo lint is just more complex but maybe if you could give a hint why CI is failing would be nice!
I will take a look at it when I have time!
It seems to have a merge conflict now
thanks!!
What do you think about switching to a logging crate after 0.1.0?
A very good idea, I also thought about that recently
Especially if we want to support options like --quiet and --verbose
Yes or verbose mode
It will also help us to make our output messages more consistent and make them prettier
Feel free to create an issue for it!
Will do!
Created an issue: https://github.com/TheBevyFlock/bevy_cli/issues/236
Do you have a strong opinion on what logging crate to use? I think it makes sense if we just use what bevy uses already i.g tracing?
@foggy basin While creating https://github.com/TheBevyFlock/bevy_cli/pull/237 i thought that maybe after 0.1.0 we could move some of the web stuff from build/ and run/ into the web module?
I havent really looked into the options yet, but tracing sounds reasonable!
Absolutely, for example the the binary selection should probably in web instead.
Thanks for working on that ticket, I'll review it as soon as I can!
Ha, I was also thinking about that but forgot to create an issue. Can you set one up?
yes! i can add a comment on the HackMD doc aswell
https://github.com/TheBevyFlock/bevy_cli/issues/238
so you can label
For Bevy Jam's, it would be nice if the CLI supports publishing the web build directly to itch.io perhaps with something like butler
we are pretty close to 0.1.0 makes me very happy!
I think adding the web feature flag will also force us to organize things a bit better
I left a comment on how to fix the CI failure :)
o thanks!!
will take a look tomorrow
I think my next goal will be to work on the web auto reload and then to try and make it work with bacon. I think we might even be able to integrage bacon directly inside the CLI for a bevy watch implementation, but I'll have to experiment with it first
I'm close to finishing a system to configure the linter through Cargo.toml, which is on the linter-config branch!
This is one of the last blockers preventing us from using the linter in Bevy's own CI, which is pretty exciting!
Once I finish, you should be able to configure lints like this:
[package.metadata.bevy_lint]
lint_name = "warn"
other_lint = { level = "deny", further-config = true }
Internally it uses the new declare_bevy_lint_pass! macro, with the @config extension:
declare_bevy_lint_pass! {
pub LintPassName => [LINT_NAME.lint],
@config "lint_name" = {
further_config: bool
},
}
@pale viper Could you potentially expand the CLI readme with a basic explanation of the linting, similar to the web stuff? I think we will need that for the 0.1 release :)
For the templating with bevy new we will also need a section. I can't remember who spearheaded that command
Totally! I believe @dreamy yacht originally wrote the bevy new command, with @toxic quartz stepping in a little later, but no pressure towards either of them
I created https://github.com/TheBevyFlock/bevy_cli/issues/239 and https://github.com/TheBevyFlock/bevy_cli/issues/240 to track these
True, these tasks should also be easy enough to pick up for someone who didn't directly work on these features :)
What format do you want my section in the README.md to be?
Right now it just talks about the web-specific features of bevy {build,run}, but not much else
(Specifically, what should the heading be named? Where should I put it? How format / specific should it be?)
Right, so my thought was that we have a heading for each major feature (which we summarize in the list at the start).
So maybe a heading like "Linting" or "Static analysis" or something similar and then a brief overview of what it can do.
Personally, I think giving a couple of examples that the user can just copy paste in their terminal to try it out would be nice :)
You can probably come up with better heading names though, writing is not my strength 😅
It occurred to me that the cargo generate template for the minimal bevy template asks to run the update command, but why is there a command to generate a Cargo.lock at all?
Would we like to have a recommened keyboard input handling lint?
like using run conditions instead of using a if at the start of your system?
Too opinionated IMO
I'm not convinced that either of them is bad
Its more just a question of "what's the standard way to do xyz"
I see a lot of people ask stuff just looking for the standard method people use, and they get frustrated when you hand em 5 ways to do the same thing yknow?
Its like with Godot offering the slide fn just to simplify movement physics. Its not the best way just the common way.
Standard way should be using actions, not raw inputs >.>
Annnd you see my point? I didn't even know that was the standard way lol
That's because I haven't upstreamed LWIM yet T_T
Yea someday
But yea, I think a category of opinionated lints based off whats common practice is a good idea, sorta like how caseing of fns is opinionated for common practice.
Maybe not on by default but available
I definitely agree with that 🙂
Cooked up an issue so it's not buried here
https://github.com/TheBevyFlock/bevy_cli/issues/241
Iirc this is so that CI doesn't fail on initial commit, since it passes --locked to cargo commands
on which initial commit? the user that bootstrapped a new project?
that template doesn't have workflows:
it has a workflows directory, but nothing in it
Hm I guess that hasn't been added yet to bevy_new_minimal
I don't recall what the plan was
The --locked issue may have been hit in bevy_new_2d then
Yeah bevy_new_minimal only has a ci-generate.yaml for now, which tests that cargo generate works as expected, but no ci.yaml yet
I submitted a PR to remove it for now since it doesn't currently have a purpose: https://github.com/TheBevyFlock/bevy_new_minimal/pull/16
Currently when running bevy new to generate a new project with this template, the user is prompted to run a script.
The lockfile update script was initially added as a way to make it so that users...
If none beats me to it i can add a section for the new command today or tomorrow should be pretty straightforward.
well, tried to write a short section https://github.com/TheBevyFlock/bevy_cli/pull/243
thank you so much for the review and pointer! Appreciate it a lot ❤️
Thanks for your work! We're progressing at a nice pace I would say :)
@pale viper @limber wedge How do you feel about the current v0.1.0 milestone, is anything not tracked yet?
How exactly do we want to go about the release once it's complete, I assume a maintainer has to approve it first or something like that?
After double checking the issues again the only thing that i would either like to close or add to the milestone is https://github.com/TheBevyFlock/bevy_cli/issues/13. Imo we can close the issue once https://github.com/TheBevyFlock/bevy_cli/issues/221 is merged. What i think is also very important is that we really check the templates that TheBevyFlock provides. I think Chris ran into some issues / questions that he posted here and i think for an "initial launch" its important that everything is smooth.
A Bevy CLI tool and linter. Contribute to TheBevyFlock/bevy_cli development by creating an account on GitHub.
We should add some CI tests which run the bevy build and bevy build web commands to ensure that they work as expected. At minimum, they should assert that the command returns a successful status co...
True, I think we can close it once the PR is merged. The testing is not really complete then, but we can create more specific follow-up issues when needed
Testing the templates also sounds good to me!
Writing my last exam for the semester today and then im FREE
will take a look at https://github.com/TheBevyFlock/bevy_cli/pull/222 tomorrow
Do we want to link the HackMD in the #engine-dev channel so we get some more feedback or what needs to be done so we can close this? https://github.com/TheBevyFlock/bevy_cli/issues/205
maybe after the weekend alice could take a look
Good luck!
thank you! i can use that ^^
Right, feedback from a maintainer would probably be useful. Then we can think about how to best publish it
do you know how its "normally" done? or is there not really a specific way
Honestly not sure if they are really "published" ususally. I think mostly it's just linked in the working group and pinned?
But we did it a bit backwards that the design document was very surface level and then we just started experimenting :D
It has been critizised a bit that we didn't provide a more formal design doc yet so I think it makes sense to gather more feedback
With something like the CLI which I assume would get used quite a lot, I am prepared for a lot of contrary opinions on some topics, but hopefully the parts that we have built are relatively uncontroversial :)
But if there is strong community disagreement on some parts of the current implementation we should definitely change it.
Might be more work at this stage, but definitely worth it to ensure that the CLI can be widely adopted
oh i see yea makes sense i can see both sides so its good to have one now ^^
True maybe then for the 0.1.0 release milestone we should add an issue to create a cli design doc or update this maybe? https://hackmd.io/cCHAfbtaSviU_MDnbNHKxg. So if there already exists plans for future features that we get feedback on them aswell to better scope 0.2.0?
The design doc is basically something you sand to the maintainers to get official approval on. It has the same sort of feel as an rfc, except that it is supposed to sort of be built in conjunction with experiments just as you have done.
Once you want approval (eg so that this tool becomes official) you can probably just at cart/alice and ask for it.
Makes sense to me.
I think for the "main CLI" we already have a solid foundation and now we get to the parts that are more complicated to implement and might also require some changes to Bevy itself (e.g. the hot asset reloading for the web)
Alright, then I think we should also create design docs for the linter (I think we already started that?) and the templating and combine them in the design doc that was started right at the beginning.
Then get that and the current prototype signed off and release 0.1 afterwards if everything is good?
You can if you want to. The idea was that a quick approval on a design doc can save people wasting work on an implementation that will get rejected.
That might not be applicable here?
Not for the 0.1 work that has already been done, you are right. But there are still several features on the roadmap where it would be useful to get approval first before investing more work on it
I also think it's important to approve of the current prototype first before we release it, to avoid broader adoption of something that will get scrapped or changed significantly. Especially if it were to be included in the 0.16/0.17 release notes
Yea i see it as useful to get approval on the prototype first and with that form a doc that focus on the next chunks of work that are on the roadmap.
Just remembered I'll also finish porting bevy_new_2d to the Bevy CLI, I think we have everything we need now
Made some progress: https://github.com/TheBevyFlock/bevy_new_2d/pull/312
I think it's mostly done now. We mainly need to test the release CI workflow and fix a bug with the audio.
We do ship a script in the CLI that should restart the audio context automatically, but maybe it has a bug right now
ok i left a comment regarding testing the release workflow. let me know when the pr is ready for review depending on the option you choose
Thanks! I'll try to fix the audio issue tomorrow
Why does the bevy_new_2d have the indirection of main just importing a plugin that contains the whole app?
I don't see the purpose
better for testing etc
you can write a bin/ script to run bevy_mod_debugdump on the schedule graph created by adding your whole app as a plugin, for example
then stuff like that should probably be explained in comments
noobs to programming often try to start with game dev and might think that its neccesary to always do that
yeah it probably should be either in comments or docs/design.md
preferably the latter imo
probably both.
comment duplication wont kill us
yeah it's moreso that the comments in the template shouldn't look like example comments but more like something a user might write in their own project, because the template will become their project
if the comment is worded in such a way then yeah both is good
the comments are meant too explain the "why" to someone
im writing up a pr rn to add some to the lib rn (diffrent topic)
actually this is a good example of the style of comments
It concisely explains why its being done
@foggy basin I hope this does not come across as disrespectful. Thought it would be less work for you so i left my review and how it could look with the assert_cmd crate here: https://github.com/TheBevyFlock/bevy_cli/pull/247
No worries! Unfortunately I had less time today than I thought, so I couldn't look into it myself yet.
I'll check your PR later today!
How did your exam go?
First one went really good. Second one was a bit poorly designed imo. I still think i will pass.. hopefully.
Should this then just be "web" https://github.com/DaAlbrecht/bevy_cli/blob/221-test-build-commands/tests/build.rs#L90 or change this to web-dev
I think web-dev is fine, because the web profile inherits dev. But not a strong preference
I looked at the web design document, and it looks good! I browsed the rest of the issue tracker, and nothing stood out to me at critical for v0.1.0
Yea let's close it and create a follow up if we need anything else :)
So then porting the templates to Bevy CLI is probably the last thing left
That’s awesome! Thank you for your effort on this, it’s really coming together :D
Are you still studying for exams? @pale viper 
Nope, I'm finally out of that tunnel! I wanted to suggest a few changes to your lint about inserting () into an entity, but accidentally edited your PR directly! Would you mind looking over what I did in #210 (with the changes summarized in this PR I tried to open) and let me know your thoughts?
If they look good to you, I'll approve #210 and merge it :)
Yes i saw yesterday but was so tired after work will take a look once i get home!
And congrats!🎉
Hah, you're good :)
While you do that, I'm going to look over the Cargo lint infrastructure you set up (finally!)
Yea that one was a bit more complicated. Interested in your thoughts
The porting might be tricky though, I couldn't figure out the audio issue yet
Should we have a lint that warns on Query<Entity>? I feel like that's pretty much never what you'd want unless a very niche use case.
I ask because I just saw that in a PR
I'm not sure, I feel like I've found Query<Entity> useful in the past, but I can't think of any immediate use-cases off the top of my head
That's why I suggest a warning
Are there better alternatives?
I honestly can't think of a reason where you would need all entities
Ohhh, you mean just Query<Entity>, not Query<Entity, With<SomeFilter>>
A warning that can be disabled should allow people to do that if they wish too, but at least it won't happen by mistake
yes
same for Query<()>
which is also technically valid
or at least it builds
That makes a lot more sense! 😅
Due to how lints work, the linter will see Query<()> and Query<(), ()> as the same thing! :)
There's any issue for weird queries already, so I'm adding a comment to it now
I want to say empty, but Query<Entity> is the opposite of empty
Ah, yeah, makes sense
What's the issue? I was about to make an issue with my proposed lint
I think it's a bit separate? I mean, it could be the same lint, but I feel like there might be a very niche use case for Query<Entity> but I don't see that for Query<&Foo, With<Foo>>
Maybe calling Query<Entity> a "bad query" is too harsh, how about "suspicious query"?
We already have a SUSPICIOUS category, so it would fit nicely there :)
Yeah, I guess all of those could be classified as suspicious queries
so you could #[allow(suspicious_queries) if you ever need Query<Entity> and that reads better than #[allow(bad_queries)]
I made another pass over the linter v0.2.0 milestone. I set a soft deadline for February 15th, with a hard deadline for the end of February. I also pushed quite a few issues onto v0.3.0, since it doesn't look like we'll complete them within that time.
Is this something someone would do on accident and get problems from? Linting something like this kinda feels like linting for the sake of linting
I'm not necessarily against it, just curious what the value is
I just saw it in a PR. A lint would have caught this earlier than a reviewer
If they use that query for something then I consider it a problem
🤔 Okay fair I guess
At least, a performance problem
Looking over the 5 issues left: 2 already have PRs open (thanks to @limber wedge), 1 I've almost finished (lint configuration), and the other 2 are small bugs / improvements
yea makes sense i think we both have more time now than last month ^^
Hmm, so with the Bevy CLI port for bevy_new_2d I had the issue that I didn't get any audio, along with the warning "An AudioContext was prevented from starting automatically. It must be created or resumed after a user gesture on the page."
But also a user gesture doesn't fix it.
However, I just tested on main with trunk as we had before, but I get the same issue. Did something break when updating to Bevy 0.15? Does anyone know what the issue may be?
Ah nevermind, looks like the main version works now. Seems like the Bevy CLI doesn't find any audio contexts to resume, I'll look into it
The fix turned out to be simple: https://github.com/TheBevyFlock/bevy_cli/pull/249
I think the port of bevy_new_2d to the Bevy CLI is complete now, feel free to give it a thorough review. https://github.com/TheBevyFlock/bevy_new_2d/pull/312
I've been noticing that CI has become significantly slower (~1 hour 😱) after the end-to-end tests added in #222. To share dependencies, could we make them use the main target folder instead of tests/bevy_cli_test/target?
I'm not against E2E testing in the slightest, but I definitely would prefer the 5 minute times we had previously 😆
i thought this is just the case because for the e2e tests we remove most artefacts but the insane long ci time is really annoying
didnt know that putting them into the main target folder would improve that sorry
Nah, you're good! Just removing the generated executable shouldn't cause such significant slowdowns, since usually it takes far more time to build the dependencies
As a fun fact, check out the contents of target/debug next time you're working on a Rust project! target/debug/deps contains the object files for the built dependencies, target/debug/build contains build.rs output, and target/debug/.fingerprint is used to Cargo to track when things need to be rebuilt
https://github.com/TheBevyFlock/bevy_cli/issues/94, for this panicking_query_methods would a function call look like this? ```rs
fn my_system(query: Query<&Foo>) {
let foo = Query::single(&query);
}
oh neat! kinda crazy how many deps are "needed"
Yeah we can look into it. We could also add an additional cargo cache action for the other folder, but I assume that would explode cache size, so reusing the target folder is probably the better solution
Yeah, another alternative is to allow specifying multiple target folders into cargo-cache, but I fear that could get really complicated quickly
My Cargo.toml linter configuration PR is finally up! This was one of the last features blocking the linter from being used in Bevy's CI :)
With that done, I'm going to go back to knocking out the rest of the v0.2.0 milestone
Hello you fine people, I don't know if it's possible but have you thought about adding a cli command to add a new plugin crate to a project ?
What exactly do you mean? Adding a new crate to the current workspace which contains a scaffold vor a Bevy plugin?
I definitely thought about adding a template for a Bevy library, which would include a basic plugin scaffold and Bevy without default features as dependency.
For the command you proposed, I assume it would be harder because of different workspace setups, I don't know how we could determine in which folder to put the crate
(well, it's still slower than before the E2E tests, but only 20 min instead of 1 hour now)
I agree I wasn't very clear.
When I need to create a new plugin I need to make a new folder, import bevy prelude, then add the plugin declaration and impl.
This could be simplified to something like bevy plugin game/tree
That would create a file src/game/tree/mod.rs
containing
use bevy::prelude::*;
pub struct TreePlugin;
impl Plugin for TreePlugin{
fn build(&self, app: &mut App) {}
}
It could even maybe set it up as a completely standalone crate with a .toml and everything (I don't usually do that BECAUSE of the boilerplate even though there are tons of pros of doing it this way).
I'm not a pro in rust workspaces so I might be wrong about some things.
I just thought about it because it felt like something I spend a lot of time doing when it could be automatic.
Are you using VSCode? If so, you may be interested in snippets to reduce this repeated work
I’m not sure about a custom subcommand yet, I’d rather we reach a consensus from the community / maintainers before going in a specific direction like that
I see, do you know of any bevy specific ones or do I have to make my own
I find they’re easy enough to make yourself, but I do think there may be a few Bevy plugins out there that you could try!
I tend towards snippets too. I personally just use the lsp impl command and it at least generates fn build(&self, app: &mut App)
Ya this looks like a problem solved by snippets
in bevy_lint/docs/howto/README.me, the Tutorials hyperlink goes no where
Yea we dont have any yet
was not sure if we want to remove the hyperlink until then
But we should probably remove it
Gotcha
I'm interested in working a bit on the linter. Just reading thru the conversation here and next the changelogs
I can recommend the rustc section highlighted in the readme a lot!
bevy_new_2d comes with vs code snippets for bevy
it doesn't include one for a struct plugin like you wanted, because of the convention in bevy_new_2d to mainly use fn plugins
but it's easy to add
There's a bevy code snippets in the vscode extensions
I use it
Has plugin/resource/component and a few others I never think to use
I opened a PR which causes the browser tab to reload when bevy run web restarts:
https://github.com/TheBevyFlock/bevy_cli/pull/256
This will (probably) enable us to fake a bevy watch web with bacon already.
It also sets up the infrastructure for cold and eventually hot asset reloading for Bevy web apps!
Thats so cool! I can have a look tomorrow evening but im not that familiar with wasm
Im sorry that you need to review two „big“ pr‘s
@pale viper will clean up the bevy duplicate version lint a bit more / fix merge conflicts
what is the relationship between bevy lint and cargo clippy? I see some overlapping warnings and some unique
bevy lint is specialized for types and warnings that can only be implemented for Bevy projects. Everything else should be in clippy
ok good to know, I'm seeing unused_variables, etc from bevy_lint right now. I think its 0.1 (not main) but there doesn't seem to be a --version option for bevy_lint either.
Do we already have a lint to override the normal "too many arguments" lint? Because systems can get pretty big and I get tired of adding the allow to every other system
you can add that allow at the Cargo.toml level instead of on every system: https://github.com/TheBevyFlock/bevy_new_minimal/blob/b542dd6a74d37e69daf8d04c8658b720417fd628/Cargo.toml#L20-L25
the templates the cli uses by default set it there
iirc Bevy lint runs cargo check and additionally registers the bevy specific lints
Does anyone know the difference between debug = false and strip = "debuginfo" in the profile configuration?
I'm thinking whether we should disable or limit debuginfo in the default wasm dev profile, as I think it could greatly reduce iteration times (as it will also speed up bundling and loading)
Hm not sure sorry. Found this: https://doc.rust-lang.org/rustc/codegen-options/index.html#debuginfo, https://doc.rust-lang.org/rustc/codegen-options/index.html#strip
Yea I read through this and still dont understand the difference :D
Hahahaa yea i didn’t fully get it either. How I understood it is that with debug=false you could not use a debugger if you want to and no backtraces. While with strip both should be most likely still possible 
So i would tend towards strip?
Yea we'll also have to see what type of debug info is even usable on wasm
Yup, as @limber wedge mentioned, all normal cargo check lints are also raised by bevy lint (cargo clippy does the same thing!)
bevy_lint also does not currently support multiple versions of Bevy. v0.1.0 supports Bevy 0.14, and the main branch supports Bevy 0.15
Eventually there will be configuration to select which version you want (issue), but it's not been started yet
I guess once we support multiple versions, we can automatically select the correct one by looking at the dependencies
I think we still need a way to tell the user what version of bevy lint they are using. Maybe this could also only be supported via the bevy cli for now?
I'm glad I'm not the only one to suffer from this: https://www.reddit.com/r/rust/comments/1igcszx/dev_profile_outputting_into_targetdebug_is_the/
Hahah yes!!!!!
what are the next steps for the CLI? I think the milestone can be completed. Do you want to release 0.1.0 together with the linter 0.2.0?
From my perspective:
- Updating the overarching CLI design doc with the individual parts (e.g. the new web design doc)
- Finishing the port of the templates to the Bevy CLI (I think for the minimal template we need to create a PR, for the 2d one we just need a review I think (and fix any potential CI errors on the release pipeline)
- Lots of testing!
- Getting approval from a maintainer about the current prototype and the visions in the design doc
- Release!
And then after 0.1.0 my main focus will be (a) aiding with the experimental multi threading feature (b) exploring asset hot reloading for web builds
Are overlapping queries linted ? Systems with query params that conflict with eachother and cause a panic ?
As you may have already realized, writing is not my strength
will see if i can prepare a pr for the minimal template tomorrow and maybe provide a subsection for the bevy new command
I read "- Lints panicking_query_methods and panicking_world_methods" in CHANGELOG and it looks like they just lint single vs get_single stuff
No there is no lint for this as of right now
Is it within scope of things we would want to be linted ?
Hm not sure how possible that lint even would be.
This was considered, but since apps already panics with conflicting queries, it's not high priority
Right now we're focused on footguns that cannot be caught as easily, though this is definitely on the table a little later on!
Yeah I guess the panic instantly, right after compilation
Makes sense
Let me check if there's an existing issue for this, if not I'll make one!
Ahh thanks, I see lints that people have actually been asking for now
Can someone explain the tests for bevy_lint ? I don't really understand it
I've only written very basic tests myself
Issue has been opened! https://github.com/TheBevyFlock/bevy_cli/issues/258
Sure! One of the most challenging issues with testing the linter is that you cannot easily construct the AST / HIR in code. This makes unit tests really hard
So instead of this, we have UI tests. These are tests that feed the linter a Rust program and verifies that certain warnings / errors are emitted
Aah okay, so the UI is kind of capturing the output of that compilation of the RUst program ?
We use ui_test for this, which is a crate that facilitates UI tests. It also happens to be used by Clippy, Miri, and maybe the Rust compiler!
Exactly!
Lol what a unique problem
Take the main main_return_without_appexit test
fn main() {
//~^ HELP: try
App::new().run();
//~^ ERROR: an entrypoint that calls `App::run()` does not return `AppExit`
}
The //^ ERROR comment tell ui_test that an error diagnostic should be emitted on the line above it
You can also look at main.stderr, which stores a copy of the diagnostic emitted!
Ah okay. I suspect I can learn more about this just reading ui_test ?
Yup, though the docs aren't too in-depth for ui_test. I believe the rustc dev guide may have more information as well...
Oh i've never been to lib.rs before. very unfamiliar with this ui
A guide to developing the Rust compiler (rustc)
Oh yeah, I prefer it to https://crates.io! There's some cool extra features, and crate discoverability is better
Cool
Just so people are aware, I bypassed the review process to get https://github.com/TheBevyFlock/bevy_cli/pull/259 merged, which updates openssl to the latest version that fixes a use-after-free vulnerability
This vulnerability is unlikely to ever be exploited with the bevy_cli, but the change was so simple (cargo update) that I figured it would be fine
Furthermore, @limber wedge I reviewed https://github.com/TheBevyFlock/bevy_cli/pull/253! :)
And don't worry, I'm still going through #185, it's just a little bit larger
Yeii! thanks will fix the stuff in the evening