Giter VIP home page Giter VIP logo

Comments (7)

pyrossh avatar pyrossh commented on August 18, 2024

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.

fretn avatar fretn commented on August 18, 2024

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.

pyrossh avatar pyrossh commented on August 18, 2024

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.

pyrossh avatar pyrossh commented on August 18, 2024

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.

fretn avatar fretn commented on August 18, 2024

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

from rust-embed.

pyrossh avatar pyrossh commented on August 18, 2024

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

fretn avatar fretn commented on August 18, 2024

it works now, thanks for the quick response

from rust-embed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.