cargo-make icon indicating copy to clipboard operation
cargo-make copied to clipboard

Support self update

Open sagiegurari opened this issue 4 years ago • 4 comments

Features Description On linux/mac the exe is not locked while running so if the min version is defined, we could also have cargo-make validate and self update if need and configured to do so. naturally windows is out of scope here. (this is based on discussion in #265)

Describe the solution you'd like

[config]
min_version = "0.21.0"
self_update = true

In case the min version is higher then installed and self_update = true, cargo-make will first trigger self update and then restart. restarted process would NOT support self update.

sagiegurari avatar Jul 31 '19 22:07 sagiegurari

on windows, would it be possible to download to another file, exec into a seperate exe/batch script, move the file, and then exec back?

EDIT: or, i suppose a seperate executable that performs the update of the first, and the first can update the update executable, etc.

kitlith avatar Aug 01 '19 01:08 kitlith

not sure its worth it. but anyway you can't move or rename the files being executed. usually you need to have another update process for this and I'm not planning to go there

sagiegurari avatar Aug 01 '19 03:08 sagiegurari

Yeah windows support definitely involves a bit more logic, but it'd be really nice to have it there too. I think it could be done using a fairly simple process (assuming cargo is used to actually do the update):

  1. Copy self to new temporary location (Can get self with current_exe and open in read-only should work).
  2. Run self from new location with some kind of --trigger-update arg, then promptly die
  3. Have new process wait for parent to die, then trigger the update (letting cargo install the new version)
  4. Finally, run the updated executable with the original args

I'd be willing to implement and test something like that.

roblabla avatar Aug 01 '19 15:08 roblabla

Need a bit of time to think about this whole thing. don't think we need to start copying exe files, instead we could (for windows) run a batch file from cargo-make, and in it:

  • kill/wait for cargo-make to end
  • run cargo install --force cargo-make
  • run original command

this batch could be generated in runtime by cargo-make using the input data we have from the cli and the current env (cwd and other related stuff).

sagiegurari avatar Aug 01 '19 20:08 sagiegurari