rksm / hot-lib-reloader-rs

Reload Rust code without app restarts. For faster feedback cycles.
MIT License
597 stars 19 forks source link

"The specified module could not be found." when running bevy example on Windows #37

Open zoeesilcock opened 4 months ago

zoeesilcock commented 4 months ago

I was trying to integrate hot-lib-reloader into my bevy project and got to the point where everything compiled and ran, but the hot reloading wasn't working. After trying to fix it in various ways I decided to try the example from the repo to sanity check my system setup. I ran the cargo watch line and it compiled successfully. Next I ran the cargo run line which compiled successfully but then panicked just after it launched. The panic is on line 9 which is the hot_lib_reloader::hot_module line and running the exact same command without the --features reload part worked and gave a working game.

I also tested on MacOS and that gave me a fully functioning example with working hot reloading, so it appears to be a Windows specific issue.

On Windows I used Powershell, but I also tried cmd.exe and got the same result. I am using rustc version 1.80.0-nightly in both cases.

Full output from from cargo run on Windows:

PS C:\Users\<me>\Developer\hot-lib-reloader-rs\examples\bevy>  cargo run --features reload --target-dir "target-bin"
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.44s
     Running `target-bin\debug\bin.exe`
2024-05-19T07:19:24.415852Z  INFO bevy_winit::system: Creating new window "App" (0v0)
2024-05-19T07:19:24.794028Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce GTX 1080", vendor: 4318, device: 7040, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "551.86", backend: Vulkan }
thread 'Compute Task Pool (23)' panicked at src/main.rs:9:1:
failed to create hot reload loader: LibraryLoadError(LoadLibraryExW { source: Os { code: 126, kind: Uncategorized, message: "The specified module could not be found." } })
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'thread 'thread 'Compute Task Pool (19)Encountered a panic in system `<unnamed>thread 'Compute Task Pool (20)Compute Task Pool (14)bin::systems_hot::move_other_ships' panicked at ' panicked at ' panicked at ' panicked at `!
src/main.rssrc/main.rssrc/main.rssrc/main.rs::::9:9991::::
111:
Once instance has previously been poisonedOnce instance has previously been poisoned
:
:
Encountered a panic in system `Once instance has previously been poisoned
Once instance has previously been poisonedbin::systems_hot::bullet_movement_system

`!
Encountered a panic in system `bin::systems_hot::spawn_other_ships`!
Encountered a panic in system `bin::systems_hot::bullet_hit_system`!
Encountered a panic in system `bin::systems_hot::player_shooting_system`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
error: process didn't exit successfully: `target-bin\debug\bin.exe` (exit code: 101)

Let me know if I can test anything to help resolve this.

revillo commented 4 months ago

I had this issue for a while, and in my case the solution was using "cdylib" instead of "dylib" in the dynamically reloaded library cargo.toml:

[lib] 
crate-type = ["rlib", "cdylib"]
programlife555 commented 1 month ago
thread 'tokio-runtime-worker' panicked at crates\frontend\src\logics\theme.rs:11:1:
failed to create hot reload loader: LibraryLoadError(LoadLibraryExW { source: Os { code: 126, kind: Uncategorized, message: "The specified module could not be found." } })

Same error as you, it doesn't work under Windows, it works under Linux.