alepez / lavagna

A collaborative blackboard, ideal for simple sketches during online meetings
https://github.com/alepez/lavagna
Apache License 2.0
149 stars 10 forks source link

cargo install fails – could not find asset folder #21

Open hiimsergey opened 1 year ago

hiimsergey commented 1 year ago

Describe the bug When performing cargo install lavagna, the compilation process fails. The bevy_embedded_assets can't find the assets folder.

Full output, directly after Compiling <dependency> v<version>:

The following warnings were emitted during compilation:

warning: bevy_embedded_assets@0.7.0: Could not find asset folder, please specify its path with $BEVY_ASSET_PATH

error: failed to run custom build command for `bevy_embedded_assets v0.7.0`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installklO25G/release/build/bevy_embedded_assets-36be3b4b8a9ca65c/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed={}
  cargo:rerun-if-env-changed=BEVY_ASSET_PATH
  cargo:warning=Could not find asset folder, please specify its path with $BEVY_ASSET_PATH

  --- stderr
  thread 'main' panicked at /home/sergey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_embedded_assets-0.7.0/build.rs:111:9:
  No asset folder found
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `lavagna v2.1.7`, intermediate artifacts can be found at `/tmp/cargo-installklO25G`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

To Reproduce Steps to reproduce the behavior:

  1. Assure that you have cargo installed.
  2. cargo install lavagna

Expected behavior The log throws no errors and lavagna is installed at ~/.cargo/bin/lavagna.

Desktop (please complete the following information):

Side Note In my project, I have the same issue. I uploaded it to crates.io but can't cargo install, due to the same error messages, although cargo package --list lists my assets folder.

Thank you in advance.

hiimsergey commented 1 year ago

I found a kind of hack to get it to compile:

  1. cargo install lavagna and let it fail (it spawns a /tmp/cargo-install\<random letters> directory)
  2. git clone the source code and cd into it
  3. BEVY_ASSET_PATH=assets/ CARGO_TARGET_DIR=/tmp/cargo-install\<random letters\> cargo install lavagna
  4. The compiler throws and error message and points to /tmp/cargo-install\<random letters>/release/build/bevy_embedded_assets-\<random hash>/out/include_all_assets.rs Delete the body of the only function there and replace it with:
embedded.add_asset(std::path::Path::new("fonts/FiraMono-Medium.ttf"), include_bytes!("/absolute/path/to/lavagna/assets/fonts/FiraMono-Medium.ttf"));
embedded.add_asset(std::path::Path::new("sprites/pen.png"), include_bytes!("/absolute/path/to/lavagna/assets/sprites/pen.png"));
  1. Run step 3 again

I did this for both your and my project and it seemed to work, although I don't know how to use this information so that users can install the program normally.

alepez commented 1 year ago

Hi @hiimsergey, thanks for sharing this issue.

I've just tested it and I confirm that cargo install lavagna gives this error:

error: failed to run custom build command for `bevy_embedded_assets v0.7.0`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installZgTg2e/release/build/bevy_embedded_assets-5842e00b13fe4b91/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed={}
  cargo:rerun-if-env-changed=BEVY_ASSET_PATH
  cargo:warning=Could not find asset folder, please specify its path with $BEVY_ASSET_PATH

  --- stderr
  thread 'main' panicked at 'No asset folder found', /home/alepez/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_embedded_assets-0.7.0/build.rs:111:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `lavagna v2.1.7`, intermediate artifacts can be found at `/tmp/cargo-installZgTg2e`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

But cargo install --path . from a fresh clone of the last commit dd260dd seems to be ok.

I've also tried cargo clone lavagna (https://crates.io/crates/cargo-clone) and cargo install --path . from the downloaded directory and it seems to be fine.

I need more time to handle this issue, but if in the meanwhile you've find a solution, feel free to PR.

hiimsergey commented 11 months ago

Any updates?

alepez commented 10 months ago

I think this is related to https://github.com/vleue/bevy_embedded_assets/issues/5

When executing cargo install lavagna, dependencies are built first. bevy_embedded_assets is expecting to find the assets folder, but when it is built, that folder does not exist yet.

I think cargo install lavagna cannot be used to install this crate.