Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work in release mode #10

Closed
fretn opened this issue Mar 16, 2018 · 7 comments
Closed

Doesn't work in release mode #10

fretn opened this issue Mar 16, 2018 · 7 comments

Comments

@fretn
Copy link

fretn commented Mar 16, 2018

When I run the sample application from the readme in release mode it doesn't work. when I put the folder example/public/ next to the release binary, it works

[fretn@machine embed]$ rustup show
Default host: x86_64-apple-darwin

installed toolchains
--------------------

stable-x86_64-apple-darwin
nightly-x86_64-apple-darwin

installed targets for active toolchain
--------------------------------------

x86_64-apple-darwin
x86_64-unknown-linux-musl

active toolchain
----------------

stable-x86_64-apple-darwin (default)
rustc 1.24.1 (d3ae9a9e0 2018-02-27)

[fretn@machine embed]$
@pyrossh
Copy link
Owner

pyrossh commented Mar 17, 2018

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]> 

@fretn
Copy link
Author

fretn commented Mar 17, 2018

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]$

@pyrossh
Copy link
Owner

pyrossh commented Mar 18, 2018

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.

@pyrossh
Copy link
Owner

pyrossh commented Mar 18, 2018

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.

@fretn
Copy link
Author

fretn commented Mar 18, 2018

Okay good luck, I’ll keep an eye on this project

@pyrossh
Copy link
Owner

pyrossh commented Mar 18, 2018

@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.

@pyrossh pyrossh closed this as completed Mar 18, 2018
@fretn
Copy link
Author

fretn commented Mar 18, 2018

it works now, thanks for the quick response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants