https://linen.dev logo
Running cargo in build script
# help
a
For one reason or another[0] I'm trying to run
cargo metadata
in a subcommand in a build process, but I'm getting a strange error which looks to me like maybe an entrypoint is different or something 🤔 is what I'm trying to do even possible? My build script is at https://github.com/sd2k/recipes/blob/embed-web/crates/recipe-web/build.rs.
Copy code
2023-01-02T14:17:05.255158427Z  INFO   --- stderr
2023-01-02T14:17:05.262283933Z  INFO   Error: error from HTML pipeline
2023-01-02T14:17:05.268691814Z  INFO
2023-01-02T14:17:05.276181519Z  INFO   Caused by:
2023-01-02T14:17:05.282724839Z  INFO       0: error getting cargo metadata
2023-01-02T14:17:05.288347907Z  INFO       1: `cargo metadata` exited with an error: error: Found argument 'metadata' which wasn't expected, or isn't valid in this context
2023-01-02T14:17:05.294856801Z  INFO
2023-01-02T14:17:05.301009994Z  INFO          USAGE:
2023-01-02T14:17:05.306583215Z  INFO              service [OPTIONS] --provisioner-address <PROVISIONER_ADDRESS> --proxy-fqdn <PROXY_FQDN> --project <PROJECT> --admin-secret <ADMIN_SECRET>
2023-01-02T14:17:05.312050043Z  INFO
2023-01-02T14:17:05.318334428Z  INFO          For more information try --help
[0]: I'm actually running
trunk
programmatically to build some WASM assets so I can embed them, but
trunk
calls
cargo metadata
[here](https://github.com/thedodd/trunk/blob/master/src/config/manifest.rs#L23)
this will also need to have the
wasm32-unknown-unknown
target installed so this idea might also fail there, but I'm still interested 😄
s
Hmm, these are coming from the shuttle deployer (which is the entrypoint for each project). I'm not sure why the
build.rs
would call it though 🤷‍♂️
Copy code
service [OPTIONS] --provisioner-address <PROVISIONER_ADDRESS> --proxy-fqdn <PROXY_FQDN> --project <PROJECT> --admin-secret <ADMIN_SECRET>
a
Yeah that's what I thought 🤔 it's very strange. the
cargo_metadata
crate just calls (effectively)
std::process::Command::new(std::env::var("CARGO").unwrap_or_else(|| "cargo".to_string())).arg("metadata")
so unless
CARGO
is set I have no idea what's going on 😅
s
Nope,
CARGO
is not set inside the project containers 😅