I have a rust application (https://github.com/Riduidel/rrss2imap) which, when run on my raspberry, fails with the following error message
pi@raspberrypi-server:~/rrss2imap $ ./rrss2imap-armv7-unknown-linux-gnueabihf-debug run
[2019-09-02 11:46:08.847444 +02:00] INFO [rrss2imap::feed] src/feed.rs:74: Reading feed from http://tontof.net/?rss
[2019-09-02 11:46:09.203357 +02:00] INFO [rrss2imap::feed] src/feed.rs:138: Feed date is 2019-09-02 09:46:09 while previous read date is 2019-07-11 17:03:36
[2019-09-02 11:46:09.203874 +02:00] INFO [rrss2imap::feed] src/feed.rs:143: There should be new entries, parsing HTML content
[2019-09-02 11:46:09.211703 +02:00] INFO [rrss2imap::feed] src/feed.rs:74: Reading feed from https://www.brothers-brick.com/feed/
[2019-09-02 11:46:10.897497 +02:00] INFO [rrss2imap::feed] src/feed.rs:138: Feed date is 2019-09-02 02:00:37 while previous read date is 2019-07-11 14:40:44
[2019-09-02 11:46:10.898026 +02:00] INFO [rrss2imap::feed] src/feed.rs:143: There should be new entries, parsing HTML content
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error(Msg("Template \'message.html\' not found"), State { next_error: None, backtrace: InternalBacktrace { backtrace: None } })', src/libcore/result.rs:999:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
What is really weird is that when I run the same code from cargo run
it works like a charm.
So what is going wrong ? How can I fix it ?
Your program can't find the template file.
You have two options:
Ship the templates directory together with the binary and put them on the server, in the location where the binary loads the templates from.
Statically include your templates into your binary with include_str, and then load them with Tera::add_raw_template.
PS: you can also embed whole directories into your app with crates like include_dir.