Rocket.rs panic when moved to a different directory

I am trying to build a Rocket.rs chat app but when I compile the final release version and move it to a different directory, it gives the following error:

Error: FileServer path '/workspaces/Chat/static' is not a directory.
   >> Aborting early to prevent inevitable handler error.
thread 'main' panicked at src/main.rs:169:21:
invalid directory: refusing to continue
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted (core dumped)

How would I run it on this new system without moving it to the directory that it was compiled in? All of the static files were moved as well. I cannot recompile the program on the new system since it does not work (locks up most of the time, likely due to a lack of resources). The line in question is the following:

.mount("/", FileServer::from(relative!("static")))
            ^

I guess you have to make sure static/ exists before starting your sever, i.e. with std::fs::create_dir_all.

It exists, but I figured it out. The relative! macro is evaluated at compile time rather than at run time, witch means that it was hard coded.

1 Like