Somewhere in my code I have
const LOGO: &[u8] = include_bytes!("../../assets/logo.png");
I added the following in my
include = [ "src", "../assets/logo.png"]
# I also tried `../../` as a sanity check but it didn't work
but the file is not included and I can't tell why
$ cargo package --list --allow-dirty
I also find it weird that doing
include = [ "./src" ] makes the src` folder not included, should I open an issue for this somewhere?
Instead of using a relative path outside the package directory, you can create a symlink inside the package that refers to the file outside, and
include_bytes the symlink. Then when
cargo package finds the symlink it will automatically substitute a copy of the file.
Isn't there a cleaner way of getting this to work?
I don't know, but IMO that is a cleaner way. The package internals only depend on paths from the root. If what you tried had worked, what would the package look like on the file system where it is unarchived and used?
Ah, are you perhaps thinking of packaging working "bundler" style, rewriting the content of the files? It does not. The source code, including the
include_bytes, is unmodified (the only file that gets modified is
Cargo.toml), so a file must exist at the path it uses.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.