jeff-hughes / shellcaster

Terminal-based podcast manager built in Rust
GNU General Public License v3.0
199 stars 14 forks source link

Fixed cargo install target dir option #15

Closed dwvisser closed 4 years ago

dwvisser commented 4 years ago

--path didn't work for me. --target-dir did.

jeff-hughes commented 4 years ago

I don't think this is correct -- cargo install does not even have a --target-dir flag. It's possible you were using cargo build. Or else perhaps the API has changed at some point and you're running an older version of cargo? (I updated to the latest version, v1.45.1, to check, but there is still no --target-dir flag there, so it's not that mine is out of date.)

That said, you're correct that cargo install --path is not correct either. I was mistaking the build path with the target path. It looks like cargo install --root <dir> is the correct approach for that command. Looks like I used this flag further down in the readme talking about features but I guess I missed changing it up above.

As far as cargo build --target-dir goes, I have never had any luck getting it to actually install just the binary to a specific target location. It always ends up giving me something in a debug/ or release/ directory with all the extra compiled dependencies and a bunch of metadata. So I don't really recommend that. That's why the readme specifies building with cargo build to the default location and then copying just the binary to the appropriate location. If it worked for you, great. But I would still suggest taking a look in your /usr/local/bin/ or wherever you installed it and make sure that you don't have a whole bunch of extra files in there that don't really belong in /usr/local/bin/.

So thanks for raising the issue. Given that I don't think your change is correct, I'm going to go ahead and close this PR; however, I will update the readme to correct the command flags for cargo install. If it turns out that there's something I'm missing, feel free to reopen this and we can try to figure out the most accurate set of instructions for getting things properly installed :)

dwvisser commented 4 years ago

BTW, I think shellcaster is really cool! I'm not a Rust/Cargo expert. I just confirmed that I did use "cargo install". More info from my local system perspective:

$ cargo --version
cargo 1.46.0-nightly (43cf77395 2020-07-13)
$ cargo help install
cargo-install 
Install a Rust binary. Default location is $HOME/.cargo/bin

USAGE:
    cargo install [OPTIONS] [--] [crate]...

OPTIONS:
    -q, --quiet                                      No output printed to stdout
...
        --target <Build for the target triple>...    TRIPLE
        --target-dir <DIRECTORY>                     Directory for all generated artifacts
        --root <DIR>                                 Directory to install packages into
...

ARGS:
    <crate>...    

This command manages Cargo's local set of installed binary crates. Only
...
jeff-hughes commented 4 years ago

Ahh okay, thanks for that! That's helpful. Looks like you're using Rust nightly, and they have indeed added a --target-dir flag.

cargo install v1.45 docs cargo install v1.46 docs

I have been trying to stick to Rust stable for this project if at all possible, so I'm not using any features that are only available in nightly. That said, it shouldn't break anything either, so again, if it works for you, great!

Thanks for the extra clarification. I guess it turns out we're both right :) That said, it appears that both --target-dir and --root exist in v1.46, and it looks like the difference is that --target-dir also puts the intermediate files there. I'm not exactly sure what counts as an intermediate file in the case of cargo install, but you might still want to check your target location and make sure there aren't a bunch of extra files you don't need in there. The only thing you technically need is the shellcaster binary file. That said, most of the intermediate files tend to be there to speed up the next compilation, so I suppose it doesn't hurt if you want to keep things up to date. Your other option could be to leave it set to the default target directory, which is usually ~/.cargo/, and then copy ~/.cargo/bin/shellcaster to the appropriate place once it's complete. That way the intermediate files are still stored in ~/.cargo/ and aren't cluttering up /usr/local/bin or wherever. Up to you.

Anyway, cheers! Hope shellcaster does what you need :)