如何删除bundler安装的旧ruby版本的gems ?

时间:2023-02-02 00:18:14

I want to free up disk space in my production environment taken up by gems installed for old ruby versions. I don't believe bundle clean will work in this instance, because I don't think it cleans out the old gems for other rubies.

我想在我的生产环境中释放为旧ruby版本安装的gems所占用的磁盘空间。我不相信bundle clean会在这个例子中起作用,因为我不认为它能清理掉其他红宝石的旧宝石。

These gems are installed via capistrano and are installed in a custom location, rather than system wide. In my /path/to/my-project/shared/bundle/ruby dir, I see 2 subdirs - 2.2.0 & 2.3.0. Since I am now using ruby 2.3, is it safe just to delete the 2.2.0 directory? Is there anything else I need to do?

这些gems是通过capistrano安装的,安装在自定义位置,而不是系统范围内。在我的/path/to/my-project/shared/bundle/ruby dir中,我看到两个subdirs - 2.2.0和2.3.0。既然我现在使用的是ruby 2.3,那么删除2.2.0目录是否安全?我还需要做什么吗?

3 个解决方案

#1


2  

Use "sudo gem cleanup" to remove all previously installed gems which respecting all the dependencies be it on old version of ruby. You can see all the gems that ll be removed with command "sudo gem cleanup -d"

使用“sudo gem cleanup”删除所有先前安装的gem,它将所有的依赖项都放在ruby的旧版本上。你可以看到所有的宝石将被移除,命令“sudo gem cleanup -d”

#2


1  

here is how you can remove a specific version of the gem:

以下是如何移除特定版本的gem:

gem uninstall (gem name here) --version (version number here)

#3


0  

Go to Gemfile.lock and delete all its content. Then you go to Gemfile and delete gems you do not want anymore. After, You type bundle install and it will install just the ones you want.

去Gemfile。锁定并删除其所有内容。然后进入Gemfile,删除不想要的gems。之后,您输入bundle install,它将安装您想要的那些。

#1


2  

Use "sudo gem cleanup" to remove all previously installed gems which respecting all the dependencies be it on old version of ruby. You can see all the gems that ll be removed with command "sudo gem cleanup -d"

使用“sudo gem cleanup”删除所有先前安装的gem,它将所有的依赖项都放在ruby的旧版本上。你可以看到所有的宝石将被移除,命令“sudo gem cleanup -d”

#2


1  

here is how you can remove a specific version of the gem:

以下是如何移除特定版本的gem:

gem uninstall (gem name here) --version (version number here)

#3


0  

Go to Gemfile.lock and delete all its content. Then you go to Gemfile and delete gems you do not want anymore. After, You type bundle install and it will install just the ones you want.

去Gemfile。锁定并删除其所有内容。然后进入Gemfile,删除不想要的gems。之后,您输入bundle install,它将安装您想要的那些。