poc: Enable volta uninstall node@x.x.x#1658
Conversation
| let version = VersionSpec::default(); | ||
| let tool = tool::Spec::from_str_and_version(&self.tool, version); | ||
|
|
||
| tool.uninstall()?; |
There was a problem hiding this comment.
This uninstall is a function of Spec. ↓
volta/crates/volta-core/src/tool/mod.rs
Lines 120 to 124 in 1776387
What I want to do now is to perform an uninstall with a specified version like volta uninstall node@x.x.x, so Spec::uninstall is not appropriate. Therefore, I considered defining Tool::uninstall. (Since Tool is the return type of Spec::resolve, I believe that "Resolved" mentioned in this comment refers to Tool).
But I'm not sure that I can replace Spec::uninstall with the Tool::uninstall completely.
| let tool = tool::Spec::from_str_and_version(&self.tool, version); | ||
|
|
||
| tool.uninstall()?; | ||
| let tool = tool::Spec::try_from_str(&self.tool)?; |
There was a problem hiding this comment.
How about
for tool in Spec::from_strings(&self.tools, "uninstall")? {
tool.resolve(session)?.uninstall(session)?;
}just the same way as install which enable to install/uninstall multiple node/package once.
| let node_dir = home.node_image_root_dir().join(self.version.to_string()); | ||
| if node_dir.exists() { | ||
| remove_dir_if_exists(&node_dir)?; | ||
| info!("{} 'node@{}' uninstalled", success_prefix(), self.version); |
There was a problem hiding this comment.
I think maybe remove node-version.tar.gz in home.tmp_dir is also needed
This pull request is for a PoC.
As per #327, the
volta uninstallcommand does not allow you to uninstallnodeoryarn.However, I have many patch versions of node installed on my machine, and I wanted to delete older versions to free up unnecessary disk space.
Therefore, it is inconvenient that
volta uninstall node@x.x.xis not possible.I looked through the issues and Discord but couldn't understand why this has not been implemented for so many years, so I created a simple implementation for discussion.
I would like to know whether this approach is acceptable or if there are any concerns.
(The core of the implementation is here. The rest of the changes are not significant.)