Skip to content

Improving binary distribution through cargo. #20

Open
@XAMPPRocky

Description

@XAMPPRocky

Summary / Motivation

The current cargo-install user experience is very poor. For both the user's
(people using cargo-install) and the developer's (people publishing binaries
through cargo-publish). For example having no upgrade story, having no way
to separate dependencies between libraries and binaries, and having no awareness
of binaries on the crates.io website.

CLI applications are currently the third most popular category
on crates.io. From general purpose tools like ripgrep, tokei, and hyperfine,
to rust development tools like the [diesel CLI], to the myriad of cargo plugins
which one of the biggest categories on crates.io. Despite crates.io initially only
being designed for libraries it's clear that people want to use it to distribute and
share Rust applications.

Cargo and the crates.io is a lot of developer's first distribution of their CLI
application. Improving this experience helps smooth out building a CLI
application to rust by having a complete distribution experience out of the box
with Cargo.

Upgrading

The is no current way in cargo to upgrade a binary. The user's options are to
run cargo install --force <package> or
cargo uninstall <package> && cargo install <package>. The problem with both of
these options is that neither respects the currently installed package's version
so to upgrade a cargo package requires a complete reinstall of the application
regardless of whether there is a newer version.

This is a very poor experience as Rust developer's we know how long Rust release
compile times are. Even with with all the great work the compiler does to reduce
compile times there is no better compile time than having to not compile at all.
Cargo should provide upgrade functionality either through a new subcommand a la
brew upgrade <package> or through a flag like pip pip install -u <package>.

Separation of dependencies

Currently cargo allows you to specify the developer's intent of a dependency
with [dev-dependencies] allowing a developer to use different dependencies for
development that the end user of their library or application doesn't need to
download or worry about compiling for their system. cargo-install does not
respect this and will download and build these packages.

Cargo currently does not have the ability to separate dependencies for binaries
and libraries. While at first this doesn't seem like a big issue since a binary
that depends on the library has to get all of their dependencies. This becomes
a problem for the reverse libraries downloading their binary's dependencies.
Which becomes an issue when installing a CLI through cargo-install.

Cargo should provide a way to specify library or binary specific dependencies.
This could be done in a similar way to development dependencies and having
[lib-dependencies], [bin.dependencies], and [bin.bin_name.dependencies]
which would allow developer's specify which packages are used only for libraries
or binaries while retaining the current behaviour and having [dependencies] be
for crates that used in all.

It might not be a big deal to get these packages but they do add a non trivial
amount of compile time. We also should not be wasting a user's bandwidth there
is still a lot of situations where bandwidth is tight whether the user lives in
an area with poor service or is using cellular which are no where near the
level's of bandwidth or stability, so any reduction of data is a
big improvement.

Showcasing applications

Currently crates.io only shows instructions on how to add a crate as library
dependency. Cargo should show cargo install <package> for binary only, and
show other binaries that are part of that crate.

Unresolved questions

  • How cargo would remember features of an installed app?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-distributionArea: Licensing, packaging, etcC-tracking-issueCategory: A tracking issue for an unstable feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions