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

Update capability to replace arkade with a newer version #973

Open
alexellis opened this issue Sep 14, 2023 · 9 comments
Open

Update capability to replace arkade with a newer version #973

alexellis opened this issue Sep 14, 2023 · 9 comments

Comments

@alexellis
Copy link
Owner

alexellis commented Sep 14, 2023

It would be possible to self-update by running arkade update and having the running binary replaced by a newer version.

arkade get arkade has the logic to download the latest version, but we need something to replace this version.

I'd also like to see the self-check only download the binary if there's a newer version, something which we can find a way to optimise.

This way, people could add arkade update to their .bashrc, profile, or a daily cron.

Expected Behaviour

Update command can replace the running version

Current Behaviour

It prints out install instructions, which can be copy/pasted

Possible Solution

  • Use the equivalent code of arkade get arkade to get an updated version
  • Move that file to replace the location of the currently running binary
  • Make sure this only downloads the ~ 10MB binary, if it's required

I want to avoid using any self-updating libraries or external dependencies. We did this for another project using stdlib.

Context

I've been seeing a lot more breakages recently with projects changing binary names and formats, this would make arkade self-update, and work better for when we've fixed issues introduced by upstream projects.

@alexellis
Copy link
Owner Author

@Jasstkn / @mrwormhole do you have time for a challenge?

@mrwormhole
Copy link
Contributor

mrwormhole commented Sep 14, 2023

yes makes sense to me, is it potentially safe to swap old arkade binary with new arkade binary during the old arkade CLI process? I believe it is safe on linux, but on windows I have doubts

currently this makes sense;

  1. remove cached versions of arkade, $HOME/.arkade, %USERPROFILE%\.arkade
  2. remove old arkade binary via which , where
  3. get the latest arkade binary to previously found arkade binary path
  4. from above points, only complete the linux compatible ones for now

@alexellis
Copy link
Owner Author

Perhaps we'll start with Linux first then?

@Jasstkn
Copy link
Contributor

Jasstkn commented Sep 25, 2023

Hm, on Mac I just have an alias to do the following:

which upd_arkade
upd_arkade: aliased to sudo curl -sLS https://get.arkade.dev | sudo sh

@alexellis
Copy link
Owner Author

The first sudo shouldn't be needed for curl

@Jasstkn
Copy link
Contributor

Jasstkn commented Sep 28, 2023

The first sudo shouldn't be needed for curl

yep, you're right!

@Shikachuu
Copy link
Contributor

How about we get the current binary first with os.Executable() then check in the get command if we are updating arkade itself and in that case we set the movePath to the result?
Also everything in the get package seems path aware, so we should approach this with get.Download() like everywhere else.

Honestly I don't know if this will work on windows, but I'm quite sure it this will solve the problem for our unix friends.

@Jasstkn
Copy link
Contributor

Jasstkn commented Nov 12, 2023

I have a windows to test on now 😃

@Shikachuu
Copy link
Contributor

How about we get the current binary first with os.Executable() then check in the get command if we are updating arkade itself and in that case we set the movePath to the result? Also everything in the get package seems path aware, so we should approach this with get.Download() like everywhere else.

Honestly I don't know if this will work on windows, but I'm quite sure it this will solve the problem for our unix friends.

@alexellis, @Jasstkn is this solution seems good for you guys?

I can start to skeetch up a PR this weekend or so.

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

No branches or pull requests

4 participants