Skip to content

Commit 3fd5a17

Browse files
committed
fixes
1 parent 6e5eaa7 commit 3fd5a17

File tree

1 file changed

+10
-10
lines changed
  • content/blog/2024/12-12-rust-feature-debugging

1 file changed

+10
-10
lines changed

content/blog/2024/12-12-rust-feature-debugging/index.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ cargo:warning= | ^~~~~~~~~~
2121
cargo:warning=1 error generated.
2222
```
2323

24-
So that looks like some crate tries to build some c code under the hood. That is not a problem on native build targets but wont fly on **wasm**.
24+
So it looks like some crate is trying to build c code under the hood. That is not a problem on native build targets but it won't fly on **wasm**.
2525

2626
This happens in the `basis-universal` crate, what could that be good for? Reading up on it's [crates.io page](https://crates.io/crates/basis-universal) we find out that it is:
2727

@@ -39,7 +39,7 @@ Let's find the cause for this.
3939

4040
We first want to find out where in our tree of dependencies this one is used. `cargo tree` is the tool to help you analyze your dependencies as the graph structure they make up.
4141

42-
When running `cargo tree` we get get over 1.000 lines of output where we can search for `basis-universal`:
42+
When running `cargo tree` we get over 1.000 lines of output where we can search for `basis-universal`:
4343

4444
```sh
4545
│ │ ├── bevy_image v0.15.0
@@ -51,13 +51,13 @@ When running `cargo tree` we get get over 1.000 lines of output where we can sea
5151

5252
We got a winner. It is used by `bevy_image`. The problem is that we do not know why. Based on the changelog linked above we know it is supposed to be behind a `feature` flag called `basis_universal`, looking at our `Cargo.toml` we do not enable it though.
5353

54-
> Cargo will enable the minimum subset of `features` needed so that every dependency using `bevy` get the features they ask for.
54+
> Cargo will enable the minimum subset of `features` needed so that every dependency using `bevy` gets the features they ask for.
5555
5656
The question therefore is: Which crate asks for this feature?
5757

5858
# Playing Cargo Feature Detective
5959

60-
There is a little known feature in `cargo tree` that allows us to not only see our dependency tree but also the features that are enabled in each crate.
60+
There is a little-known feature in `cargo tree` that allows us to not only see our dependency tree but also the features that are enabled in each crate.
6161

6262
Running `cargo tree -e features` in our repository root we get over 3.000 lines of this:
6363

@@ -79,7 +79,7 @@ Running `cargo tree -e features` in our repository root we get over 3.000 lines
7979
│ │ └── tracing-attributes v0.1.28 (proc-macro)
8080
```
8181

82-
Luckily we know know already what feature we are looking for: `basis-universal`, so lets search for `bevy feature "basis-universal"`:
82+
Luckily we now know already what feature we are looking for: `basis-universal`, so let's search for `bevy feature "basis-universal"`:
8383

8484
```sh
8585
├── bevy_libgdx_atlas feature "default"
@@ -88,7 +88,7 @@ Luckily we know know already what feature we are looking for: `basis-universal`,
8888
│ │ ├── bevy v0.15.0 (*)
8989
```
9090

91-
Here we go. Our own crate `bevy_libgdx_atlas` enables the feature `basis-universal` which in turn enables the dependency `basis-universal` which breaks our build on **wasm**. That makes it easier to fix. Funny enough it was used to enable `bevy_image` while trying to depend on the smallest subset of features of `bevy`. This is a known in Bevy 0.15, see [issue #16563](https://github.com/bevyengine/bevy/issues/16563). But there is a cleaner workaround by just enabling the `bevy_image` feature.
91+
Here we go. Our own crate `bevy_libgdx_atlas` enables the feature `basis-universal` which in turn enables the dependency `basis-universal` which breaks our build on **wasm**. That makes it easier to fix. Funny enough it was used to enable `bevy_image` while trying to depend on the smallest subset of features of `bevy`. This is a known issue in Bevy 0.15, see [#16563](https://github.com/bevyengine/bevy/issues/16563). But there is a cleaner workaround by just enabling the `bevy_image` feature.
9292

9393
## Improving ergonomics
9494

@@ -106,13 +106,13 @@ With this we limit our root to `bevy` and we will find *one* entry for the featu
106106

107107
The feature option in `cargo tree` is a very powerful tool in fighting against the subtle way dependencies and features in them can creep into your codebase.
108108

109-
Since it is close to christmas I want to make a whishlist to improve the situation:
109+
Since it is close to Christmas I want to make a wishlist to improve the situation:
110110

111111
1. A `cargo deny` like tool that allows me to white/blacklist features in dependencies.
112-
2. `cargo tree` should generate a computer readable format (ron/json whatever) to facilitate point 1.
113-
3. In a perfect world there would be a `cargo tree-tui` allowing to interactively inspect dependencies, their features and fan in (who uses it) and fan out (what it is using).
112+
2. `cargo tree` should generate a computer-readable format (ron/json whatever) to facilitate point 1.
113+
3. In a perfect world there would be a `cargo tree-tui` allowing to interactively inspect dependencies, their features, and fan in (who uses it) and fan out (what it is using).
114114

115-
That being said `cargo tree` seems underutilized, so go and run it on your bevy project to figure out what features of dependencies like Bevy you actually compile. This can have a huge impact on your wasm binary size!
115+
That being said `cargo tree` seems underutilized, so go and run it on your Bevy project to figure out what features of dependencies like Bevy you actually compile. This can have a huge impact on your wasm binary size!
116116

117117
---
118118

0 commit comments

Comments
 (0)