1

我有一个 rust 应用程序 ( https://github.com/Riduidel/rrss2imap ),当在我的树莓上运行时,它失败并显示以下错误消息

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.

真正奇怪的是,当我从中运行相同的代码时,cargo run它就像一个魅力。

那么出了什么问题呢?我该如何解决?

4

1 回答 1

3

您的程序找不到模板文件。

你有两个选择:

  • 将模板目录与二进制文件一起发送,并将它们放在服务器上,二进制文件从中加载模板的位置。

  • 使用include_str将模板静态包含到二进制文件中,然后使用Tera::add_raw_template加载它们。

PS:您还可以使用include_dir之类的 crate 将整个目录嵌入到您的应用程序中。

于 2019-09-02T17:21:07.723 回答