astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.45k stars 459 forks source link

`rye self update` always re-downloading binary, even when up to date. #1033

Open poopsicles opened 4 months ago

poopsicles commented 4 months ago

Steps to Reproduce

  1. Install the latest version of rye on Linux.
  2. Attempt to update it with rye self update

Expected Result

It should check and see that it's the latest version and report "Already up to date."

Actual Result

It re-downloads the binary and makes a new virtualenv.

image

Version Info

$ rye --version
rye 0.32.0
commit: 0.32.0 (e1b4f2a29 2024-03-29)
platform: linux (x86_64)
self-python: cpython@3.12.2
symlink support: true
uv enabled: true

Stacktrace

No response

mikky-j commented 4 months ago

A possible fix for this would be to host the checksum of the latest version (preferrably on GitHub) and then use that to validate if the user's binary is up to date or not

ashemedai commented 4 months ago

I guess it would be similar to what uv does:

% uv self update
info: Checking for updates...
success: You're on the latest version of `uv` (v0.1.38).
mikky-j commented 4 months ago

Exactly. The ideal case would be something like what uv is doing

Looking at the the uv codebase, I can see that it is using AxoUpdater which is a crate that is used to install files distributed using cargo-dist

here for the uv implementation

The functionality that we would want is already built into AxoUpdater but we would need to ensure that rye can be distributed using cargo-dist

From the little testing that I did with AxoUpdater, "rye" is not currently using cargo-dist

So we have two options if we want to do this

  1. We implement the checksum by providing it in the releases and then comparing the checksum of the current binary to that one to know if we need a release similar to what a tool like rustup here
  2. We need to use cargo-dist for rye's distribution

Note: For rustup, instead checksums they have a toml file that they get the latest stable version from and then they compare it to the current version of that the program is running on. This is much simpler than the checksum.

I think the team is probably planning on 2 because they did it for uv so it would make sense that they would do it for rye but I'm not sure why (maybe there's an issue using cargo-dist?).

For a hotfix, something like what rustup does would be the likely candidate

If there is an interest in adding this feature, I would like be assigned to it.

mikky-j commented 4 months ago

There's already a MANIFEST.json in the releases so implementing any of the solutions mentioned below would be trival

So we have two options if we want to do this

1. We implement the checksum by providing it in the releases and then comparing the checksum of the current binary to that one to know if we need a release similar to what a tool like `rustup` [here](https://github.com/rust-lang/rustup/blob/bbb9276d24519f8684cd616b2e46b7596f7dd891/src/cli/self_update.rs#L1214)

2. We need to use `cargo-dist` for rye's distribution