Asdf: Add a reinstall command

Created on 23 Oct 2017  路  6Comments  路  Source: asdf-vm/asdf

Sometimes, especially during development and troubleshooting, it would be nice to be able to reinstall a version in a similar manner to Homebrew. In its primitive form, it could be just uninstall and install chain, but take further, it could be done transactionally, too, i.e. a failure to install won't remove the previous instance.

enhancement help wanted

All 6 comments

Good feature. I like the idea of transactional reinstalls.

Should this be a separate command or just a flag to the install command as discussed in
https://github.com/asdf-vm/asdf/issues/148?

I'm open to either approach, but transactional reinstalls are a must either way.

I'm closing #148 in favor of this issue.

I started looking into this, unfortunately it doesn't look like transactional properties can be achieved without some support from the plugins.

While many of them are simple (download + extract) and this could be done by installing into temp dir, then uninstalling the old one, then moving the temp location into place, there are plugins like clojure which injects the install dir location into some installed scripts (so moving it after installation will make them invalid).

Also a lot of plugins use upstream installers or ./configure && make && make install so it's hard to tell whether moving directories after install would be safe (most likely it would require passing additional options to the installer, like DESTDIR with autotools).

I wonder if we could work around this issue by doing something like this:

  1. Move the currently installed version and copy it out of it's installed directory and into a temp directory (making it unusable)
  2. Tell the plugin to install that same version, with the name of the original directory containing the old version (so that if it succeeds it's in the right spot)
  3. If the new version installs successfully delete the temp dir containing the old install. Otherwise delete the directory containing the failed new install (or copy it elsewhere for debugging) and copy the original installation directory back to the original location (restoring the original version and making it usable again).

Would that work? And if so do you think we will run into any problems with this approach? Thanks for taking the time to look into this!

I had to reinstall erlang after installing a few dependencies to compile it again and I can say that at least asdf-erlang wouldn't work this way, as it keeps its own record of which version is installed, so moving the install directory doesn't work.

(Tried on Archlinux).

I saw there are some plugin-test, maybe it would be interesting to add some tests for this feature before shipping it, so those plugins have the time to adapt ?

@Aethelflaed I don't think the erlang plugin should be keeping a record of which versions of Erlang it installed. It uses kerl underneath, and kerl does typically keep records, but I think we altered it such that asdf-erlang doesn't rely on that behavior. If not we may need to change it. Generally plugins should not be keeping track of installed plugins on their own.

I'd like to do this without changing the plugins at all if possible. We may have to update a few plugins so they will work properly however.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

peleteiro picture peleteiro  路  3Comments

jthegedus picture jthegedus  路  3Comments

kevinkjt2000 picture kevinkjt2000  路  4Comments

michalmuskala picture michalmuskala  路  5Comments

robsonpeixoto picture robsonpeixoto  路  4Comments