#Errors when re-exporting bevy

26 messages · Page 1 of 1 (latest)

hexed vessel
#

I'm currently refactoring my code into separate crates and I've created a core crate that re-exports bevy, so all my crates use the same bevy version and I only need to change it in core if I decide to upgrade to a new version.

but doing this gives me the following error in the ide:
failed to resolve: use of unresolved module or unlinked crate 'bevy_ecs'

example code:

use spirit_hotel_core::bevy::prelude::*;

#[derive(Component, Default, Debug, Reflect)]
#[reflect(Component, Default)]
pub struct CanPush;
strong geyser
#

This may be a bug in bevy. It's probably worth filing a bug.

However, a different solution is to just use workspace dependencies. In your workspace Cargo.toml, you add a [workspace.dependencies] section, specify your dependencies, and then in your crate files, you specify your dependency like bevy = { workspace = true }

hexed vessel
crisp pulsar
#

[workspace.dependecies] works the same as the normal packages [dependencies], so crates.io, git or local works fine

hexed vessel
#

but then what do I write into the members section, or is that optional?

crisp pulsar
#

what is the structure of you project? how many Cargo.toml and their locations

hexed vessel
#

game/cargo.toml:

[workspace]
members = ["crates/game*"]

[workspace.dependencies]
...
crisp pulsar
#

the main app (workspace root) depends on all of the subcrates, right?

hexed vessel
#

yes

crisp pulsar
#

e.g.,

[workspace]
members = ["crates/*"]

[package]
name = "spirit_hotel"

[workspace.dependecies]
bevy = "0.17.3"
game_core = { path = "crates/game_core" }
other23crates = { path = "..." }

[dependencies]
bevy = { workspace = true }
game_core = { workspace = true }
other23crates = { workspace = true }
#

and on each of the subcrates you would also be able to use bevy = { workspace = true}

hexed vessel
#

but if I used github links instead of placing all my crates into "crates/..." then the crates folder would be empty and I wouldn't have a way to tell the workspace root that the github packages are members of the workspace

crisp pulsar
#

then it would be

[package]
name = "spirit_hotel"

[workspace.dependecies]
bevy = "0.17.3"
game_core = { git = "https://github.com/???/game_core" }
other23crates = { git = "..." }

[dependencies]
bevy = { workspace = true }
game_core = { workspace = true }
other23crates = { workspace = true }
hexed vessel
#

and game_core would automatically know that it is part of the game workspace?

crisp pulsar
#

wait, then you project would only have 1 crate on it, all of the workspace members on crates/... will have their own git repo?

hexed vessel
#

yes

crisp pulsar
#
[package]
name = "spirit_hotel"

[dependencies]
bevy = "0.17.3"
game_core = { git = "https://github.com/???/game_core" }
other23crates = { git = "..." }
#

and each of the other crates would have their dependencies linking to the other repos

hexed vessel
#

but I want to still be able to do bevy = { workspace = true } in each github repo

crisp pulsar
#

workspace is only if you have Cargo.toml under another in the file hierarchy

hexed vessel
#

so either I wait for a fix from the bevy team or I have all crates in one github repo/file hierarchy with a workspace

crisp pulsar
#

yes

#

having on the same workspace is best, unless you are creating something that you intend on using on multiple projects

#

and even then you could still do

[package]
name = "spirit_hotel_2"

[dependencies]
game_core = { git = "https://github.com/???/spirit_hotel" }
hexed vessel
#

oki