Desinstalar versiones antiguas de Ruby gems


Tengo varias versiones de una gema Ruby:

$ gem list
rjb (1.3.4, 1.3.3, 1.1.9)

¿Cómo puedo eliminar versiones antiguas pero mantener las más recientes?

 314
Author: Philippe Blayo, 2011-05-05

5 answers

# remove all old versions of the gem
gem cleanup rjb

# choose which ones you want to remove
gem uninstall rjb

# remove version 1.1.9 only
gem uninstall rjb --version 1.1.9

# remove all versions less than 1.3.4
gem uninstall rjb --version '<1.3.4'
 550
Author: Dylan Markow,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-12-28 23:39:12

Para eliminar versiones anteriores de todas las gemas instaladas, los siguientes 2 comandos son útiles:

 gem cleanup --dryrun

El comando anterior previsualizará qué gemas se eliminarán.

 gem cleanup

El comando anterior en realidad los eliminará.

 223
Author: ohho,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-12-14 07:41:57

Intenta algo como gem uninstall rjb --version 1.3.4.

 12
Author: Daniel O'Hara,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-05-05 18:33:45

gem cleanup utiliza comandos del sistema. Las gemas instaladas son solo directorios en el sistema de archivos. Si desea eliminar por lotes, utilice rm -R.

  1. gem environment y tenga en cuenta el valor de GEM PATHS
  2. cd <your-gem-paths>/gems
  3. ls -1 |grep rjb- |xargs rm -R
 8
Author: Anatoly,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-04-30 00:02:45

Manera de limpiar cualquier versión antigua de gemas.

sudo gem cleanup

Si solo desea ver una lista de lo que se eliminaría, puede usar:

sudo gem cleanup -d

También puede limpiar solo una gema específica especificando su nombre:

sudo gem cleanup gemname

Para eliminar la versión específica como 1.1.9 solo

gem uninstall gemname --version 1.1.9

Si todavía se enfrenta a alguna excepción para instalar gema, como:

Gema no válida: el paquete está dañado, excepción al verificar: undefined método 'tamaño' para nil: NilClass (NoMethodError) en /home / rails/.rvm/gems/ruby-2.1.1@project/cache/nokogiri-1.6.6.2.gem

El, puede eliminarlo de la caché:

rm /home/rails/.rvm/gems/ruby-2.1.1@project/cache/nokogiri-1.6.6.2.gem

Para más detalles:

Http://blog.grepruby.com/2015/04/way-to-clean-up-gem-or-remove-old.html

 8
Author: user3118220,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-15 07:14:00