4

My Rails app was working fine and then I decided to try to update it from 4.0 to 4.2 so I could put it on Heroku. The guide I was following said to update RubyGems so I ran this command:

$ gem update --system

Got this warning:

Warning! `PATH` is not properly set up, '/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin'
is not at first place, usually this is caused by shell initialization
files - check them for 'PATH=...' entries, it might also help to re-add
RVM to your dotfiles: 'rvm get stable --auto-dotfiles', to fix temporarily
in this shell session run: 'rvm use ruby-2.0.0-p353'

I ignored the warning and went to the next step in the guide. I tried to create a gemset:

$ rvm use 2.0.0p353@rails4.0.2_myapp --create

Then I decided to not update because I was scared of breaking my app. So I just tried to push the app to Heroku without updating.

I ran

$ heroku login
$ heroku create
$ git push heroku master

It failed to push to Heroku because the slug size was too big. I went to fix it and then I started getting this error:

/Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:16:in `require': cannot load such file -- stringio (LoadError)
    from /Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:16:in `<top (required)>'
    from /Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems.rb:1228:in `require'
    from /Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems.rb:1228:in `<module:Gem>'
    from /Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems.rb:115:in `<top (required)>'
    from <internal:gem_prelude>:1:in `require'
    from <internal:gem_prelude>:1:in `<compiled>'

TLDR: App was working. Then I ran these commands:

$ gem update --system
$ rvm use 2.0.0p353@rails4.0.2_myapp --create
$ heroku login
$ heroku create
$ git push heroku master

Now I receive that LoadError error and can't run my app. How can I fix this? I'm assuming something broke when I ran

$ gem update --system

I read this question: no such file to load -- rubygems (LoadError), and someone says to check if you have two ruby versions installed so I ran:

$ which -a ruby
/Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
/usr/bin/ruby

but I don't know what to do after or if it even matters since I only ran those above commands after my app was working fine.

Here are my versions if it matters:

$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin12.5.0]

I can't run rails -v because I get the LoadError. But before the error I got this:

$ rails -v
Rails 4.0.2

Before error (I think this updated to a newer version after I ran the update command):

$ gem -v
2.4.8

EDIT

After trying to switch to old version of rubygems:

$ rvm rubygems 2.4.8

I got:

Warning! PATH is not properly set up, '/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin'
is not at first place, usually this is caused by shell initialization
files - check them for 'PATH=...' entries, it might also help to
re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles', to fix
temporarily in this shell session run: 'rvm use ruby-2.0.0-p353'.
ruby-2.0.0-p353 - #downloading rubygems-2.4.8
ruby-2.0.0-p353 - #extracting rubygems-2.4.8.....
ruby-2.0.0-p353 - #removing old rubygems..........
ruby-2.0.0-p353 - #installing rubygems-2.4.8.
Error running 'env GEM_HOME=/Users/devon/.rvm/gems/ruby-2.0.0-p353@global GEM_PATH= /Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -d /Users/devon/.rvm/src/rubygems-2.4.8/setup.rb --no-document',
showing last 15 lines of /Users/devon/.rvm/log/1452506634_ruby-2.0.0-p353/rubygems.install.log
[2016-01-11 05:03:54] /Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
current path: /Users/devon/.rvm/src/rubygems-2.4.8
GEM_HOME=/Users/devon/.rvm/gems/ruby-2.0.0-p353
PATH=/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin:/Users/devon/.rvm/gems/ruby-2.0.0-p353@global/bin:/Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin:/Users/devon/.rvm/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/devon/my_stuff/android/adt-bundle-mac-x86_64-20130729/sdk/platform-tools:/Users/devon/my_stuff/android/adt-bundle-mac-x86_64-20130729/sdk/tools
GEM_PATH=/Users/devon/.rvm/gems/ruby-2.0.0-p353:/Users/devon/.rvm/gems/ruby-2.0.0-p353@global
command(7): env GEM_HOME=/Users/devon/.rvm/gems/ruby-2.0.0-p353@global GEM_PATH= /Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -d /Users/devon/.rvm/src/rubygems-2.4.8/setup.rb --no-document

And then the stringio error occurs at the end here

EDIT 2:

$ echo $PATH
/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin:/Users/devon/.rvm/gems/ruby-2.0.0-p353@global/bin:/Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/devon/.rvm/bin:/Users/devon/my_stuff/android/adt-bundle-mac-x86_64-20130729/sdk/platform-tools:/Users/devon/my_stuff/android/adt-bundle-mac-x86_64-20130729/sdk/tools
ib.
  • 27,830
  • 11
  • 80
  • 100
theDazzler
  • 1,039
  • 2
  • 11
  • 27
  • naive question, but did you do `bundle` after updating rubygems? – hedgesky Jan 09 '16 at 23:17
  • Yes I did. It won't execute the command though because I get the same error after running it. ````require': cannot load such file -- stringio (LoadError)```` – theDazzler Jan 10 '16 at 04:46
  • Strange indeed. Maybe it's worth to try reinstalling ruby completely: https://rvm.io/rubies/removing. I have never encountered such problem but if I was in your shoes I would try clean installation of ruby and maybe upgrade rvm itself if nothing else helps. – hedgesky Jan 10 '16 at 08:35
  • Can you add the output of `echo $PATH`? – taglia Jan 11 '16 at 10:19
  • @taglia ok I added the output of ```echo $PATH``` – theDazzler Jan 11 '16 at 15:37
  • You should find out why `/usr/bin` comes before `/.rvm/gems/ruby...`, you are running the system ruby and that is the problem. You should move `/usr/bin` at the end; that should remove the warning on PATH. – taglia Jan 11 '16 at 15:41
  • @taglia I forgot to close the old terminal window after I did what you suggested. The correct PATH is shown above now. – theDazzler Jan 11 '16 at 16:17
  • If you have reasons not to remove and reinstall rvm I can try to reproduce this tonight at home, where I have OS X. Still, there are no guarantees that I'll get the same error. Otherwise I'd recommend you try to reinstall rvm (you can also backup your current rvm before removing it). – taglia Jan 12 '16 at 02:35

1 Answers1

2

My best guess of what's happening:

  1. The PATH warning that you received is because you updated the local rvm 'gem' command using the system ruby (in /usr/bin);
  2. When you created the gemset, rvm fixed the path, but after this RubyGems from your system ruby is being run using your rvm ruby, and I guess the two versions do not match.

The easiest solution would be to completely remove and reinstall rvm:

  1. $ rm -rf ~/.rvm
  2. Reinstall rvm
  3. Re-run bundle install

To confirm this is indeed the problem before deleting rvm, you can temporarily switch /usr/bin (put this first) and /Users/devon/.rvm/gems/ruby-2.0.0-p353/bin (and this after) in your PATH. At this point, gem -v should still give you 2.4.8, and /Users/devon/.rvm/gems/ruby-2.0.0-p353/bin/gem -v should work fine and give you the newer version of RubyGems.

Alternative solution

Something else (simpler) you could try is to force rvm to reinstall the older version of RubyGems, and then update it again (if required):

rvm rubygems 2.4.8

Have a look here for more details on managing RubyGems with rvm.

Community
  • 1
  • 1
taglia
  • 1,837
  • 2
  • 13
  • 16
  • Ok. I switched the PATH locations like you said and ran ```gem -v```. The command actually worked but I got ```1.3.6```. Does this change anything or should I just try reinstalling rvm like you suggested? – theDazzler Jan 11 '16 at 09:41
  • This pretty much confirms it, as the 2.4.8 must have been in rvm path. Have you tried to run the `rvm rubygems` command, after switching back the two paths in the PATH variable? – taglia Jan 11 '16 at 09:56
  • I made an EDIT in my question with the error results of running ```rvm rubygems 2.4.8```. I ran it after I switched the PATH locations back to the way it was before your doing what was in your answer. – theDazzler Jan 11 '16 at 10:16