kornelski / cargo-deb

Make Debian packages directly from Rust/Cargo projects
https://lib.rs/cargo-deb
MIT License
423 stars 50 forks source link

`cargo deb` looks for target-specific configuration in target directory #84

Closed domenicquirl closed 1 year ago

domenicquirl commented 1 year ago

Hi, cargo deb doesn't seem to pick up a target-specific strip command if I set $CARGO_TARGET_DIR to a non-local folder (such as /target or whatever). I'd expect this to not influence loading a project's config, as cargo loads from the project directory (and up) or $CARGO_HOME, not $CARGO_TARGET_DIR, and it picks up config values like aliases just fine with this setup.

I think what might be happening is that Config::cargo_config passes self.target_dir to CargoConfig::new, which expects a project_path instead.

It also seems a little inconsistent to read $HOME from the environment to check a user-wide configuration, but not $CARGO_HOME (the Cargo Book lists $CARGO_HOME/config.toml as the global configuration directory, which the current behaviour matches for the default cargo home directory, I assume you already knew this). At least, that makes it quite annoying to work around this, because I have to actually put the config inside the target directory (the build itelf is running inside a Docker container).

domenicquirl commented 1 year ago

While this is an issue, I also want to say that cargo-deb generally handles the setup very well otherwise. Including some very nice things like automatically resolving the path of assets that are targets - that was very welcome, so thanks for that!

kornelski commented 1 year ago

You're right that target dir shouldn't be used for config, and that conflated it with manifest dir. Can you make a PR?

domenicquirl commented 1 year ago

Opened #85 with a fix. It includes looking into CARGO_HOME as well, but you can let me know how you'd like to proceed there.

kornelski commented 1 year ago

Thank you