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

Minimum version dependency installation #381

Closed
roblabla opened this issue Mar 11, 2020 · 10 comments
Closed

Minimum version dependency installation #381

roblabla opened this issue Mar 11, 2020 · 10 comments
Assignees

Comments

@roblabla
Copy link
Contributor

Features Description
I'm currently dealing with bitrot happening in my kernel, which stopped building after leaving it untouched for a couple months. It turns out that newer version of build dependencies stopped building on the rustc version pinned by my project, which caused the build to fail.

It'd be nice to find a way to tell cargo-make to leverage the min-version and cargo's --locked parameter to ensure reproducibility of the builds.

Describe the solution you'd like
A flag or an environment variable to cargo-make (--reproducible, CARGO_MAKE_REPRODUCIBLE=true?) that, when set, causes every crate installed through install_crate = { crate_name = "xargo", min_version = "1.0.0" } to be installed as if ran with cargo install --version 1.0.0 --locked.

@sagiegurari
Copy link
Owner

cool idea.
do you think install_crate_args is not good enough because its not global?

@roblabla
Copy link
Contributor Author

roblabla commented Mar 12, 2020

Huh, install_crate_args somehow flew under my radar. It's only mentioned here in the readme, with no examples to accompany it. I had to look at the Makefile built into cargo-make to find how it's used ^^'. Maybe this example should find its way in the readme?

Indeed, having something more "global" would be nice, to avoid having to redundantly specify the min_version and writing a ton of boilerplate to handle both "install latest" and "install exact" scenarios - which I want to both support. I still expect users to want to install the latest version of the tools (and only fallback to the min_version if that fails for whatever reason), while CI will always use the min_version for reproducibility.

To do this with install_crate_args, I guess I'd write my rules like:

[tasks.install-xargo-locked]
private = true
description = "Installs xargo 0.9.8 reproducibly"
install_crate = { crate_name = "xargo", binary = "xargo", test_arg = "--help", min_version = "0.9.8" }
install_crate_args = ["--locked", "--version", "0.9.8"]

[tasks.install-xargo-latest]
private = true
description = "Installs xargo 0.9.8, fetching latest if available."
install_crate = { crate_name = "xargo", binary = "xargo", test_arg = "--help", min_version = "0.9.8" }

[tasks.install-xargo]
run_task = [
    { name = "install-xargo-locked", condition = { env_set = ["REPRODUCIBLE_BUILD"] } },
    { name = "install-xargo-latest" },
]

Which kinda feels extremely boilerplate-y for my tastes.

@sagiegurari
Copy link
Owner

first of all, you don't have to duplicate things, right? you can extend for example:

[tasks.install-xargo-locked]
extend = "install-xargo-latest"
install_crate_args = ["--locked", "--version", "0.9.8"]

[tasks.install-xargo-latest]
private = true
description = "Installs xargo 0.9.8, fetching latest if available."
install_crate = { crate_name = "xargo", binary = "xargo", test_arg = "--help", min_version = "0.9.8" }

which makes things more readable and maintainable.
i would even make the version as env var in the env table to share same value.

second, i can implement that global env var to enable this automatically, but i hope it will actually help and not cause other problems.

sagiegurari added a commit that referenced this issue Mar 13, 2020
…ARGO_MAKE_CRATE_INSTALLATION_FROZEN and CARGO_MAKE_CRATE_INSTALLATION_LOCKED environment variables #381
@sagiegurari
Copy link
Owner

@roblabla I just pushed support for this global flag.
if CARGO_MAKE_CRATE_INSTALLATION_FROZEN=true you will have version and frozen flags added automatically.
CARGO_MAKE_CRATE_INSTALLATION_LOCKED=true is the same, but instead of frozen, it adds locked.
you must have min_version defined in that specific installation info for this to be triggered.
can you please try it out and give me feedback?

@roblabla
Copy link
Contributor Author

I just took a quick look (didn't run it yet, just going over the code), I think you forgot to prefix the version with --version here? cargo install xargo --locked 0.3.18 won't work (it treats 0.3.18 as a crate to install), it needs to be cargo install xargo --locked --version 0.3.18 ^^.

@sagiegurari
Copy link
Owner

woops. right. thanks.
and thanks for all the great idea you keep giving :)

sagiegurari added a commit that referenced this issue Mar 13, 2020
@sagiegurari
Copy link
Owner

Code updated and added relevant docs as well.
I'm relying on you for functional testing of it (didn't have much time myself, so only added unit tests for actual expected result and not crate actual installation).

@roblabla
Copy link
Contributor Author

Just ran 0.29 on my project, the LOCKED installation works perfectly fine :). I'm not entirely sure FROZEN makes sense for cargo install? When I tried installing xargo with --frozen, cargo complained with

error: attempting to make an HTTP request, but --frozen was specified

(Full command: [cargo-make] INFO - Execute Command: cargo install --force --frozen --version 0.3.18 xargo)

So I'm not sure how --frozen is supposed to be used 👀.

@sagiegurari
Copy link
Owner

ya, frozen does seem only relevant for dependencies. will remove that.

sagiegurari added a commit that referenced this issue Mar 13, 2020
@sagiegurari
Copy link
Owner

@roblabla just released a new version with this.
as usual thanks a lot for the feedback. you provided many great ideas and contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants