base icon indicating copy to clipboard operation
base copied to clipboard

Add remove-tool command

Open rarkins opened this issue 3 months ago • 14 comments

  • remove-tool foo removes all installations of tool foo
  • remove-tool foo x.y.z removes installation of [email protected]
    • If another version of foo is still installed then it needs to be linked instead

rarkins avatar Aug 25 '25 14:08 rarkins

What if there are more than 2 versions installed? Which version should be linked?

viceice avatar Sep 01 '25 13:09 viceice

Should it support the <TOOL>_VERSION env variable like install-tool ?

viceice avatar Sep 01 '25 13:09 viceice

What if there are more than 2 versions installed? Which version should be linked?

It's much easier to simply unlink the tool. 🤔

viceice avatar Sep 01 '25 14:09 viceice

//cc @nabeelsaabna @Gabriel-Ladzaretti

viceice avatar Sep 01 '25 14:09 viceice

It seems it much more tricky.

I can easily remove a version, if it's not the linked one (latest installed).

If i remove a node version which is the linked one, i don't now if the linked npm or corepack is from this node install or installed by the tool after node was installed. 🤔

viceice avatar Sep 01 '25 14:09 viceice

Unlink is not good. the main idea is to delete the file and reduce vulnerabilities in the final image.

It seems it much more tricky.

I can easily remove a version, if it's not the linked one (latest installed).

If i remove a node version which is the linked one, i don't now if the linked npm or corepack is from this node install or installed by the tool after node was installed. 🤔

That does complicate things 😕 Is it only an issue for node and npm ? python as well ? maybe also deleting Java can break maven and/or Gradle ?

nabeelsaabna avatar Sep 01 '25 14:09 nabeelsaabna

yes, same for python and java.

python, node and ruby based tools are dependent on the ruby version which was linked when installed. so removal of node or ruby can break npm, bundler, pip, ...

https://github.com/containerbase/base/blob/acbf0913cf2915886c52b1b0c3fe112b7bf9609f/src/cli/tools/node/utils.ts#L103

https://github.com/containerbase/base/blob/acbf0913cf2915886c52b1b0c3fe112b7bf9609f/src/cli/tools/python/utils.ts#L50

viceice avatar Sep 01 '25 16:09 viceice

Some points I remember:

  • Needs to remove the tools. e.g. remove older dotnet while keeping newer
  • Maybe we could say that "delete-tool foo x.y.z" is only supported if x.y.z isn't the linked one?

rarkins avatar Sep 02 '25 04:09 rarkins

Some points I remember:

  • Needs to remove the tools. e.g. remove older dotnet while keeping newer
  • Maybe we could say that "delete-tool foo x.y.z" is only supported if x.y.z isn't the linked one?

that would be much easier

viceice avatar Sep 02 '25 05:09 viceice

uninstall-tool node will uninstall all versions which are not linked.

It'll still be easy to break tools, eg:

  • install python 3.9
  • install poetry xx
  • install python 3.10
  • uninstall python 3.9

poetry will be broken because it's installed into a virtualenv which uses a symlink to use the proper python version.

so users should always reinstall tools like poetry when they installed a new python version. that's a requirement for now.

we would need a kind database to track those dependencies. then we would be able to do a better cleanup. it would then be possible to also remove linked tools and all poetry, pip, ... versions which depend on the currently removed python version. we could also simply abort with a warn, that you need to uninstall poetry to uninstall python.

viceice avatar Sep 03 '25 12:09 viceice

I'll add some minimal db handling to store the relevant data, so the uninstall tool can use the information for better removal.

viceice avatar Sep 03 '25 14:09 viceice

Removing legacy tools won't be possible, thex need to be convertet first.

That are all tools in this folder and subfolders: https://github.com/containerbase/base/tree/main/src/usr/local/containerbase/tools

viceice avatar Sep 04 '25 13:09 viceice

v2 are legacy and not possible to remove? Or v2 are the ones possible to remove?

rarkins avatar Sep 05 '25 09:09 rarkins

v2 are legacy and not possible to remove? Or v2 are the ones possible to remove?

to complicated to implement, it's easier to convert them to TS code.

when I'm done with, I'll check if I can support B2 tools

viceice avatar Sep 05 '25 10:09 viceice