Skip to content

Hotpatching not works for workspaces #22334

@mentalrob

Description

@mentalrob

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

[workspace]
resolver = "3"
members = [
    "crates/game_bin", "crates/game_common",
]

[workspace.dependencies]
bevy = { version = "0.17.3", features = ["hotpatching"] }
[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" }
[package]
name = "game_common"
version = "0.1.0"
edition = "2024"

[dependencies]
bevy = { workspace = true, features = ["hotpatching"] }
// 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<Pointer<Click>>,
    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();
}
// 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorS-BlockedThis cannot move forward until something else changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions