简体   繁体   中英

RoR — NoMethodError: private method `open' called for Gem::Package:Class

Hey does anyone know what this error message means? I installed ruby from source then proceeded to install rubygems, and then installed rails via gem install rails

After creating a new project, I did a bundle install and got this error:

mark@mark-laptop:~/guide/first_app$ sudo bundle install Fetching source index for https://rubygems.org/

NoMethodError: private method open' called for Gem::Package:Class An error occured while installing rake (0.9.2.2), and Bundler cannot continue. Make sure that open' called for Gem::Package:Class An error occured while installing rake (0.9.2.2), and Bundler cannot continue. Make sure that gem install rake -v '0.9.2.2'` succeeds before bundling.

I did that command ( gem install rake -v '0.9.2.2' ) and it worked fine.. I'm rather confused

Try gem install bundler to install/update bundler after installing/updating rubygems.

It worked for me when I had your problem.

This appears to be a bug in the master branch of rubygems from GitHub. If you grab an archive of 1.8.24 from http://rubygems.org/pages/download instead, everything works fine.

I have rubygems 2.0.3 and I get the same error. I deleted gemfile.lock file in the project. Only change I got in error is From Make sure that gem install rake -v '0.9.2.2' succeeds before bundling. Changed to Make sure that gem install rake -v '10.0.3' succeeds before bundling. The new gem install rake also worked for me.

It's possible that you are using different ruby versions and gems when running commands with and without sudo. You can try running

sudo ruby -v

and

ruby -v

In addition you can check for different gem paths

gem env

and

sudo gem env
  1. gem update --system
  2. gem install bundler

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM