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

empty file list when asset directory is in nested folder #99

Closed
yatesco opened this issue Feb 21, 2020 · 9 comments
Closed

empty file list when asset directory is in nested folder #99

yatesco opened this issue Feb 21, 2020 · 9 comments

Comments

@yatesco
Copy link

yatesco commented Feb 21, 2020

Hi,

Given:

\ (the root of cargo workspace)
\Cargo.toml
\assets\ (a simple folder)
\component-a\ (a crate within the workspace)
\component-a\Cargo.toml
\component-a\assets
\static\ (a simple folder)
\static\assets

where each "\assets" directory is a copy with at least a.txt in, then #[folder = "assets/"] is the only one that works when used within \component-a.

Observations:

  • #[folder = "component-a/assets"] compiles but lists no files
  • #[folder = "static/assets"] compiles but lists no files

this is regardless of whether cargo run is run within \ or \component-a.

What I am trying to achieve is either component-a/assets/ or static/assets/.

Help :-)

@yatesco
Copy link
Author

yatesco commented Feb 21, 2020

Actually, it is slightly more subtle: \assets\ must exist but it can be empty, the actual assets are loaded from \component-a\assets.

If \assets\ is missing then it won't compile. If \component-a\assets\ is missing then it will compile but not find anything.

@yatesco
Copy link
Author

yatesco commented Feb 21, 2020

Nope...even more subtle ;-). For developing \assets\ must exist but the actual assets come from \component-a\assets but for a release build \assets\ is used :-(.

@yatesco
Copy link
Author

yatesco commented Feb 21, 2020

Last comment (for now :-)).

Synchronicity (and thus sanity!) can be achieved by enabling the feature "debug-embed" which removes the need for \component-a\assets but does have the cost of needing a rebuild for each change to an asset.

@AzureMarker
Copy link
Collaborator

Can you provide a link to your code? Your explanation is hard to follow. Are you using a symlink?

@yatesco
Copy link
Author

yatesco commented Feb 22, 2020

No symlinks (this is on Windows) and I’ll get a reproducible repo online tomorrow:-)

@yatesco
Copy link
Author

yatesco commented Feb 23, 2020

Actually, the whole thing is simpler than I thought, and is related to #63

Regardless of whether using debug or release, the value in the folder directive is relative to the current directory, which is really confusing ;-). It would be nice if it could always be relative to the workspace root.

Repo is at https://github.com/yatesco/rust-embed-bug-with-workspaces

@yatesco
Copy link
Author

yatesco commented Feb 26, 2020

Note to self: check if bbe6eea fixes this.

@AzureMarker
Copy link
Collaborator

@yatesco Is this fixed for you as of #101?

@AzureMarker
Copy link
Collaborator

AzureMarker commented May 4, 2020

Tested the reproduction code with the latest version (5.5.1), and the issue is fixed. The embedded path no longer depends on where you start cargo run.

pyrossh pushed a commit that referenced this issue Aug 24, 2021
pyrossh pushed a commit that referenced this issue Aug 24, 2021
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