我的rails应用程序工作正常,然后我决定尝试将其从4.0更新到4.2,所以我可以把它放在Heroku上。我跟随的指南说更新RubyGems所以我运行了这个命令:
gem update --system
收到此警告:
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'
我忽略了警告并转到指南中的下一步。
我试图创建一个gemset
rvm use 2.0.0p353@rails4.0.2_myapp --create
然后我决定不更新,因为我害怕破坏我的应用程序。所以我只是尝试将应用程序推送到Heroku而不进行更新。
我跑了
heroku login
heroku create
git push heroku master
由于slu size尺寸太大,它未能推向Heroku。我去修理它然后我开始收到这个错误:
/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:应用程序正在运行。然后我运行了这些命令:
gem update --system
rvm use 2.0.0p353@rails4.0.2_myapp --create
heroku login
heroku create
git push heroku master
现在我收到了LoadError错误,无法运行我的应用程序。我怎样才能解决这个问题?当我跑步时,我假设有什么东西坏了
gem update --system
我读了这个问题no such file to load -- rubygems (LoadError),有人说检查你是否安装了2个ruby版本,所以我跑了:
which -a ruby
得到了
/Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
/usr/bin/ruby
但是我不知道该怎么做,或者它甚至是重要的,因为我的应用程序工作正常后我只运行了上面的命令。
如果重要的话,这是我的版本:
ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin12.5.0]
我无法运行rails -v
,因为我收到了LoadError。但在错误之前我得到了这个:
rails -v
Rails 4.0.2
错误之前(我认为在运行更新命令后更新到更新的版本):
gem -v
2.4.8
修改
尝试切换到旧版本的rubygems后:
rvm rubygems 2.4.8
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
然后在这里结束发生stringio错误
编辑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
答案 0 :(得分:2)
我最好猜测发生了什么:
最简单的解决方案是完全删除并重新安装rvm:
$ rm -rf ~/.rvm
bundle install
要确认在删除rvm之前确实存在这个问题,您可以在PATH中临时切换/usr/bin
(先放这个)和/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin
(以及之后)。此时,gem -v
仍然应该为您提供2.4.8,/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin/gem -v
应该可以正常运行并为您提供更新版本的RubyGems。
你可以尝试的其他(更简单的)是强制rvm重新安装旧版本的RubyGems,然后再次更新它(如果需要):
rvm rubygems 2.4.8
有关使用rvm管理RubyGems的更多详细信息,请查看here。