bevyengine / bevyengine/bevy

Hotpatching not works for workspaces

Open
#22,334 6 comments 0 reactions 0 assignees View on GitHub
C-Bug S-Blocked
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version and features

- 0.17.3

## What you did

I setted up a simple workspace project to test out the hotpatching using the hotpatching example.

## What went wrong

Its simply not working, dx detects the changes but its not reflected to the game

## Additional information

My workspace Cargo.toml
```toml
[workspace]
resolver = "3"
members = [
"crates/game_bin", "crates/game_common",
]

[workspace.dependencies]
bevy = { version = "0.17.3", features = ["hotpatching"] }
```

```rs
[package]
name = "game_bin"
version = "0.1.0"
edition = "2024"

[dependencies]
bevy = { workspace = true, features = ["hotpatching"] }
game_common = { version = "0.1.0", path = "../game_common" }
```

```rs
[package]
name = "game_common"
version = "0.1.0"
edition = "2024"

[dependencies]
bevy = { workspace = true, features = ["hotpatching"] }
```

```rs
// game_common/src/lib.rs
use std::time::Duration;

use bevy::{color::palettes, prelude::*};

pub fn setup(mut commands: Commands) {
commands.spawn(Camera2d);

commands
.spawn((
Node {
width: percent(100),
height: percent(100),
align_items: AlignItems::Center,
justify_content: JustifyContent::Center,
flex_direction: FlexDirection::Column,
..default()
},
children![(
Text::default(),
TextFont {
font_size: 100.0,
..default()
},
)],
))
.observe(on_click);
}

pub fn update_text(mut text: Single<&mut Text>) {
// Anything in the body of a system can be changed.
// Changes to this string should be immediately visible in the example.
text.0 = "test".to_string();
}

pub fn on_click(
_click: On>,
mut color: Single<&mut TextColor>,
) {
// Observers are also hot patchable.
// If you change this color and click on the text in the example, it will have the new color.
color.0 = palettes::tailwind::BLUE_500.into();
}
```
```rs
// game_bin/src/main.rs
use std::time::Duration;
use bevy::prelude::*;
use game_common::{setup, update_text};

fn main() {

// This function is here to demonstrate how to make something hot patchable outside of a system
// It uses a thread for simplicity but could be an async task, an asset loader, ...

App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update, update_text)
.run();
}
```
I need this to work because my game is getting bigger and compile time is taking too much so i need to split it to workspaces to get faster compile times

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.