Comments (7)
Are you sure. Its working for me. You need to run it from the root folder and also have the latest code.
You can also run the tests to see if they are passing. Can you print out logs. Also I've added a logger in the example now. In release mode if it cant find the directory it should fail compilation.
Also I'm using the latest nightly haven't tried it on stable though.
pyros2097 rust-embed[master]> rustup show
Default host: x86_64-unknown-linux-gnu
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu (default)
installed targets for active toolchain
--------------------------------------
asmjs-unknown-emscripten
wasm32-unknown-emscripten
wasm32-unknown-unknown
x86_64-unknown-linux-gnu
active toolchain
----------------
nightly-x86_64-unknown-linux-gnu (default)
rustc 1.25.0-nightly (3ec5a99aa 2018-02-14)
pyros2097 rust-embed[master]>
from rust-embed.
why do you need to run if from the root folder in release mode, shouldn't the files be embedded which results in the fact that it doesn't matter where you run the binary from ?
I just ran your latest version and it works with cargo run --release --example rocket
but if I run the compiled binary in a different pwd
the files are not found. I'm running latest nightly (1.26.0) now
log output:
[fretn@machine rust-embed]$ cargo run --release --example rocket
Finished release [optimized] target(s) in 0.0 secs
Running `target/release/examples/rocket`
[rust_embed][INFO] loading folder -> examples/public/
[rust_embed][INFO] asset from file -> examples/public/index.html
[rust_embed][INFO] asset from file -> examples/public/images/doc.txt
[rust_embed][INFO] asset from file -> examples/public/images/llama.png
[rust_embed][INFO] asset from file -> examples/public/main.css
[rust_embed][INFO] asset from file -> examples/public/main.js
[rocket::rocket][INFO] 🔧 Configured for development.
[_][INFO] address: localhost
[_][INFO] port: 8000
[_][INFO] log: normal
[_][INFO] workers: 16
[_][INFO] secret key: generated
[_][INFO] limits: forms = 32KiB
[_][INFO] tls: disabled
[rocket::rocket][INFO] 🛰 Mounting '/':
[_][INFO] GET /
[_][INFO] GET /dist/<file..>
[launch][ERROR] 🚀 Rocket has launched from http://localhost:8000
[rocket::rocket][INFO] GET / text/html:
[_][INFO] Matched: GET /
[rust_embed][INFO] asset from cache -> index.html
[_][INFO] Outcome: Success
[_][INFO] Response succeeded.
[rocket::rocket][INFO] GET /dist/main.css text/css:
[_][INFO] Matched: GET /dist/<file..>
[rust_embed][INFO] asset from cache -> main.css
[_][INFO] Outcome: Success
[_][INFO] Response succeeded.
[rocket::rocket][INFO] GET /dist/main.js:
[_][INFO] Matched: GET /dist/<file..>
[rust_embed][INFO] asset from cache -> main.js
[_][INFO] Outcome: Success
[_][INFO] Response succeeded.
[rocket::rocket][INFO] GET /dist/images/llama.png image/png:
[_][INFO] Matched: GET /dist/<file..>
[rust_embed][INFO] asset from cache -> images/llama.png
[_][INFO] Outcome: Success
[_][INFO] Response succeeded.
[rocket::rocket][INFO] GET /favicon.ico:
[_][ERROR] No matching routes for GET /favicon.ico.
[_][WARN] Responding with 404 Not Found catcher.
[_][INFO] Response succeeded.
[fretn@machine rust-embed]$ ./target/release/examples/rocket
[rust_embed][INFO] loading folder -> examples/public/
[rust_embed][INFO] asset from file -> examples/public/index.html
[rust_embed][INFO] asset from file -> examples/public/images/doc.txt
[rust_embed][INFO] asset from file -> examples/public/images/llama.png
[rust_embed][INFO] asset from file -> examples/public/main.css
[rust_embed][INFO] asset from file -> examples/public/main.js
[rocket::rocket][INFO] 🔧 Configured for development.
[_][INFO] address: localhost
[_][INFO] port: 8000
[_][INFO] log: normal
[_][INFO] workers: 16
[_][INFO] secret key: generated
[_][INFO] limits: forms = 32KiB
[_][INFO] tls: disabled
[rocket::rocket][INFO] 🛰 Mounting '/':
[_][INFO] GET /
[_][INFO] GET /dist/<file..>
[launch][ERROR] 🚀 Rocket has launched from http://localhost:8000
[rocket::rocket][INFO] GET / text/html:
[_][INFO] Matched: GET /
[rust_embed][INFO] asset from cache -> index.html
[_][INFO] Outcome: Success
[_][INFO] Response succeeded.
[rocket::rocket][INFO] GET /dist/main.css text/css:
[_][INFO] Matched: GET /dist/<file..>
[rust_embed][INFO] asset from cache -> main.css
[_][INFO] Outcome: Success
[_][INFO] Response succeeded.
[rocket::rocket][INFO] GET /dist/main.js:
[rocket::rocket][INFO] GET /dist/images/llama.png image/png:
[_][INFO] Matched: GET /dist/<file..>
[_][INFO] Matched: GET /dist/<file..>
[rust_embed][INFO] asset from cache -> main.js
[rust_embed][INFO] asset from cache -> images/llama.png
[_][INFO] Outcome: Success
[_][INFO] Outcome: Success
[_][INFO] Response succeeded.
[_][INFO] Response succeeded.
[fretn@machine rust-embed]$ cd target/release/examples/
[fretn@machine examples]$ ./rocket
[rust_embed][INFO] loading folder -> examples/public/
[rocket::rocket][INFO] 🔧 Configured for development.
[_][INFO] address: localhost
[_][INFO] port: 8000
[_][INFO] log: normal
[_][INFO] workers: 16
[_][INFO] secret key: generated
[_][INFO] limits: forms = 32KiB
[_][INFO] tls: disabled
[rocket::rocket][INFO] 🛰 Mounting '/':
[_][INFO] GET /
[_][INFO] GET /dist/<file..>
[launch][ERROR] 🚀 Rocket has launched from http://localhost:8000
[rocket::rocket][INFO] GET / text/html:
[_][INFO] Matched: GET /
[rust_embed][INFO] asset from cache -> index.html
[_][ERROR] Response was a non-`Responder` `Err`: Status { code: 404, reason: "Not Found" }.
[_][INFO] Outcome: Failure
[_][WARN] Responding with 500 Internal Server Error catcher.
[_][INFO] Response succeeded.
[rocket::rocket][INFO] GET /dist/main.css text/css:
[rocket::rocket][INFO] GET /dist/images/llama.png image/png:
[rocket::rocket][INFO] GET /dist/main.js:
[_][INFO] Matched: GET /dist/<file..>
[_][INFO] Matched: GET /dist/<file..>
[_][INFO] Matched: GET /dist/<file..>
[rust_embed][INFO] asset from cache -> main.css
[rust_embed][INFO] asset from cache -> images/llama.png
[rust_embed][INFO] asset from cache -> main.js
[_][ERROR] Response was a non-`Responder` `Err`: Status { code: 404, reason: "Not Found" }.
[_][ERROR] Response was a non-`Responder` `Err`: Status { code: 404, reason: "Not Found" }.
[_][ERROR] Response was a non-`Responder` `Err`: Status { code: 404, reason: "Not Found" }.
[_][INFO] Outcome: Failure
[_][INFO] Outcome: Failure
[_][INFO] Outcome: Failure
[_][WARN] Responding with 500 Internal Server Error catcher.
[_][WARN] Responding with 500 Internal Server Error catcher.
[_][WARN] Responding with 500 Internal Server Error catcher.
[_][INFO] Response succeeded.
[_][INFO] Response succeeded.
[_][INFO] Response succeeded.
[rocket::rocket][INFO] GET / text/html:
[_][INFO] Matched: GET /
[rust_embed][INFO] asset from cache -> index.html
[_][ERROR] Response was a non-`Responder` `Err`: Status { code: 404, reason: "Not Found" }.
[_][INFO] Outcome: Failure
[_][WARN] Responding with 500 Internal Server Error catcher.
[_][INFO] Response succeeded.
[rocket::rocket][INFO] GET /dist/main.css text/css:
[rocket::rocket][INFO] GET /dist/main.js:
[rocket::rocket][INFO] GET /dist/images/llama.png image/png:
[_][INFO] Matched: GET /dist/<file..>
[_][INFO] Matched: GET /dist/<file..>
[_][INFO] Matched: GET /dist/<file..>
[rust_embed][INFO] asset from cache -> main.css
[rust_embed][INFO] asset from cache -> main.js
[rust_embed][INFO] asset from cache -> images/llama.png
[_][ERROR] Response was a non-`Responder` `Err`: Status { code: 404, reason: "Not Found" }.
[_][ERROR] Response was a non-`Responder` `Err`: Status { code: 404, reason: "Not Found" }.
[_][ERROR] Response was a non-`Responder` `Err`: Status { code: 404, reason: "Not Found" }.
[_][INFO] Outcome: Failure
[_][INFO] Outcome: Failure
[_][INFO] Outcome: Failure
[_][WARN] Responding with 500 Internal Server Error catcher.
[_][WARN] Responding with 500 Internal Server Error catcher.
[_][WARN] Responding with 500 Internal Server Error catcher.
[_][INFO] Response succeeded.
[_][INFO] Response succeeded.
[_][INFO] Response succeeded.
[fretn@machine examples]$
from rust-embed.
Hmmm.. You're right mate. I thought it loads the files at compile time into a hash in the binary. Need to find out why this is not happening.
from rust-embed.
Well it seems rust macro's don't allow executing code at compile time. Thought there could be a hack for this. I guess then I need to use custom_derive to get this working. Will need to think about the new implementation with breaking api changes.
from rust-embed.
Okay good luck, I’ll keep an eye on this project
from rust-embed.
@fretn Thanks for reporting this issue. Totally overlooked the asset bundling part in release mode. Fixed now and re-implemented in the version 1.1.0 please test it out.
from rust-embed.
it works now, thanks for the quick response
from rust-embed.
Related Issues (20)
- using with askama compile time templates HOT 3
- Fix compression with interpolated env HOT 2
- Clarify MSRV policy HOT 7
- error[E0609]: no field `data` on type `Cow<'_, [u8]>` HOT 1
- Is there a way to include files based on an externally generated list HOT 6
- Rename RustEmbed trait to Embed? HOT 5
- Axum 0.7.1 - no function or associated item named `get` found for struct `Asset` in the current scope HOT 1
- Is there a way to encrypt embedded file? Maybe before/after hooks? HOT 10
- A feature analogous to debug-embed, but for WASM? HOT 2
- Debug builds more lenient when loading relative paths
- `RustEmbed` derive macro is susceptible to naming collisions HOT 2
- rust-embed is tainted with MPL-2 via option-ext HOT 1
- low compilation performance when embeding large folder even though having excludes. HOT 1
- Unable to read symbolic link in debug mode HOT 4
- Replace / expand `prefix` to allow using a generic function for rewriting paths HOT 2
- Option to not include file contents HOT 1
- Check files exist at compile time HOT 2
- RustEmbed indexing may panic error from clippy
- Rust-embed cannot find embedded files if binary has been copied between Docker images in debug mode HOT 1
- Compress folder instead of each file separately
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-embed.