0

By accident I ran rvm gemset empty default.

Can someone list all gems from gemset default for ruby-2.0.0-p247 so I can reinstall them manually?

Thanks!

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Alex Fedoseev
  • 1,135
  • 11
  • 18

2 Answers2

2

Don't worry, it's still possible to restore all your gems:

#!/usr/bin/env bash

CURRENT_GEMSET=$( rvm current )
CACHE_FOLDER=~/.rvm/gems/$CURRENT_GEMSET/cache
CACHED_GEMS=$CACHE_FOLDER/*.gem

for gem_file in $CACHED_GEMS
do
  GEM_FILES=$GEM_FILES' '$gem_file
done

gem install $GEM_FILES

You may take a look at ~/.rvm/gems/$( rvm current )/cache folder first. All gems should be there.

Edit:

rvm gemset empty

Removes all the installed gems for gemset. But gems are still in ~/.rvm/gems/$( rvm current )/cache folder(e.g. ~/.rvm/gems/ruby-2.0.0-p247/cache, ~/.rvm/gems/jruby-1.7.3@my_gemset/cache) and you are still able to install them.

A bit of explanations regarding script:

  1. rvm current Print the current Ruby version and the name of any gemset being used(from rvm usage current). You may invoke rvm gemset use first in order to choose gemset you want to restore.
  2. ~/.rvm/gems/$( rvm current )/cache is a cache folder for current gemset and is the same as $GEM_HOME/cache.
  3. ~/.rvm/gems/$( rvm current )/cache/*.gem is a regexp for gems in cache folder.
  4. Loop through the file names and concatenate them into a single string

    for gem_file in $CACHED_GEMS
    do
      GEM_FILES=$gem_file' '$GEM_FILES
    done
    
  5. gem install $GEM_FILES reinstalls you gems.

lifus
  • 8,074
  • 1
  • 19
  • 24
1

Do you mean this?

alexandr@alexandr-2pcdesktop:~/RailsWork/Achivity$ ruby -v
ruby 2.0.0dev (2013-01-07 trunk 38733) [i686-linux]
alexandr@alexandr-2pcdesktop:~/RailsWork/Achivity$ rvm @global do gem list
*** LOCAL GEMS ***
bundler (1.3.5)
bundler-unload (1.0.1)
rake (10.1.0)
rubygems-bundler (1.2.0)
rvm (1.11.3.8)

=====Updated======

alexandr@alexandr-2pcdesktop:~/RailsWork/Achivity$ rvm default do gem list
*** LOCAL GEMS ***
actionmailer (4.0.0, 3.2.13)
actionpack (4.0.0, 3.2.13)
actionpack-action_caching (1.0.0)
actionpack-page_caching (1.0.0)
activemodel (4.0.0, 3.2.13)
activerecord (4.0.0, 3.2.13)
activerecord-deprecated_finders (1.0.3)
activerecord-postgresql-adapter (0.0.1)
activeresource (3.2.13)
activesupport (4.0.0, 3.2.13)
arel (4.0.0, 3.0.2)
atomic (1.1.10)
bcrypt-ruby (3.0.1)
builder (3.1.4, 3.0.4)
bundler (1.3.5)
bundler-unload (1.0.1)
capybara (2.1.0)
childprocess (0.3.9)
climate_control (0.0.3)
cocaine (0.5.1)
coffee-rails (4.0.0, 3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.6.3, 1.6.2)
commonjs (0.2.6)
database_cleaner (1.0.1)
devise (3.0.0.rc, 2.2.4, 1.5.4)
diff-lcs (1.2.4)
erubis (2.7.0)
execjs (1.4.0)
factory_girl (4.2.0)
factory_girl_rails (4.2.1)
ffi (1.9.0)
hike (1.2.3)
i18n (0.6.4, 0.6.1)
jar_wrapper (0.1.7)
jbuilder (1.4.2)
journey (1.0.4)
jquery-rails (3.0.2, 3.0.1)
json (1.8.0)
less (2.3.2)
less-rails (2.3.3)
libv8 (3.11.8.17 x86-linux)
mail (2.5.4)
mime-types (1.23)
mini_portile (0.5.0)
minitest (4.7.5)
multi_json (1.7.7)
mysql2 (0.3.11)
nokogiri (1.6.0)
orm_adapter (0.4.0, 0.0.7)
paperclip (3.4.2)
pg (0.15.1)
polyglot (0.3.3)
protected_attributes (1.0.3)
rack (1.5.2, 1.4.5)
rack-cache (1.2)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (4.0.0)
rails-observers (0.1.1)
railties (4.0.0, 3.2.13)
rake (10.1.0)
rdoc (3.12.2)
ref (1.0.5)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
rspec-mocks (2.13.1)
rspec-rails (2.13.2)
rubygems-bundler (1.2.0)
rubyzip (0.9.9)
rvm (1.11.3.8)
sass (3.2.9)
sass-rails (4.0.0)
sdoc (0.3.20)
selenium (0.2.10)
selenium-webdriver (2.33.0)
shoulda-matchers (2.2.0)
sprockets (2.10.0, 2.2.2)
sprockets-rails (2.0.0)
sqlite3 (1.3.7)
therubyracer (0.11.4)
thor (0.18.1)
thread_safe (0.1.0)
tilt (1.4.1)
treetop (1.4.14)
turbolinks (1.2.0)
twitter-bootstrap-rails (2.2.7)
tzinfo (0.3.37)
uglifier (2.1.1)
warden (1.2.1)
websocket (1.0.7)
xpath (2.0.0)
zip (2.0.2)

But all of them are from Gemfile.

AKovtunov
  • 567
  • 1
  • 6
  • 21
  • It's from `global`. I remember that in `default` there were `json` and `bigdecimal` gems, maybe some more, but I'm not sure. – Alex Fedoseev Jul 31 '13 at 20:59
  • @AlexFedoseev as I can see, there are you own installed gems, that you installed with bundler. (In example, created Rails app and ran bundle install). But if you want, I can show you mine in updated version of post. – AKovtunov Jul 31 '13 at 21:02
  • @AlexFedoseev you can see it above. But I'm sure, that they are from my Gemfile. So you can do bundle install in your project and I think, that it will install all important gems. – AKovtunov Jul 31 '13 at 21:10
  • I found [this link](http://railsapps.github.io/installing-rails.html), the list of additional system gems in the middle of the page. – Alex Fedoseev Jul 31 '13 at 21:14