Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR While executing gem - wrong number of arguments (given 1, expected 0) #2224

Closed
timherby opened this issue Mar 7, 2018 · 5 comments

Comments

@timherby
Copy link

commented Mar 7, 2018

I'm having a problem installing gems in Ruby 2.5.0 using RVM. Every time I try to install any gem, I get While executing gem - wrong number of arguments (given 1, expected 0). I have searched for answers elsewhere and in this project, but cannot seem to find anyone else with this issue. This also does not happen with Ruby 2.3.6 in the same machine.

This issue is related to:

  • Network problems
  • Installing a library
  • Publishing a library
  • The command line gem
  • Other

Here are my current environment details:

$ gem env version
2.1.11

Here is the full error:

tim$ gem install rake --backtrace
ERROR:  While executing gem ... (ArgumentError)
    wrong number of arguments (given 1, expected 0)
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:46:in `require'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/installer.rb:103:in `initialize'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/request_set.rb:93:in `new'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/request_set.rb:93:in `block in install'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/request_set.rb:84:in `each'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/request_set.rb:84:in `install'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/dependency_installer.rb:371:in `install'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/commands/install_command.rb:180:in `install_gem'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/commands/install_command.rb:194:in `block in install_gems'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/commands/install_command.rb:190:in `each'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/commands/install_command.rb:190:in `install_gems'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/commands/install_command.rb:146:in `execute'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/command.rb:305:in `invoke_with_build_args'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/command_manager.rb:167:in `process_args'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/command_manager.rb:137:in `run'
	/Users/tim/.rvm/rubies/ruby-2.5.0/lib/ruby/site_ruby/2.5.0/rubygems/gem_runner.rb:54:in `run'
	/Users/tim/.rvm/rubies/ruby-2.5.0/bin/gem:21:in `<main>'

@timherby timherby changed the title While executing gem - wrong number of arguments (given 1, expected 0) ERROR While executing gem - wrong number of arguments (given 1, expected 0) Mar 7, 2018

@segiddins

This comment has been minimized.

Copy link
Member

commented Mar 7, 2018

Did you manually install RubyGems 2.1.11 ? The default with 2.5.0 should have been something like 2.7

@segiddins

This comment has been minimized.

Copy link
Member

commented Mar 7, 2018

Aha! This is actually fixed in recent versions of rubygems, since they call Kernel.gem in Kernel.require directly. What's happening is that there's a require being called in a method that has a local variable called gem, which is shadowing the Kernel method. Updating rubygems should fix the issue!

@timherby

This comment has been minimized.

Copy link
Author

commented Mar 7, 2018

Thanks for the super quick reply @segiddins!

That did the trick. For the benefit of others, I ran the following to fix it:

rvm rubygems 2.7.6

And for reference, here is my upgrade to Ruby 2.5.0:

tim$ rvm reinstall 2.5.0
Removing /Users/tim/.rvm/src/ruby-2.5.0
Removing /Users/tim/.rvm/rubies/ruby-2.5.0
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.13/x86_64/ruby-2.5.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates in '/usr/local/etc/openssl/cert.pem' already are up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/tim/.rvm/rubies/ruby-2.5.0, this may take a while depending on your cpu(s)...
ruby-2.5.0 - #downloading ruby-2.5.0, this may take a while depending on your connection...
ruby-2.5.0 - #extracting ruby-2.5.0 to /Users/tim/.rvm/src/ruby-2.5.0
ruby-2.5.0 - #extracted to /Users/tim/.rvm/src/ruby-2.5.0
ruby-2.5.0 - #configuring..........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
ruby-2.5.0 - #post-configuration
ruby-2.5.0 - #compiling........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
ruby-2.5.0 - #installing.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Retrieving rubygems-2.1.11
Extracting rubygems-2.1.11 ...
Removing old Rubygems files...
Installing rubygems-2.1.11 for ruby-2.5.0.....

Looks like I just needed to force the upgrade of rubygems as well.

Thanks again for looking at this.

@ghost

This comment has been minimized.

Copy link

commented Mar 4, 2019

I'm getting this. I'm on 18.10, reinstalled ruby- followed above. 2.7.8 and I cant get bundler past installing rake though rake succeeds:

owner@slaptop:~/job-hunter$ bundler install
Fetching gem metadata from http://rubygems.org/............
Fetching gem metadata from http://rubygems.org/..
Resolving dependencies...
Fetching rake 11.1.2
Installing rake 11.1.2
ArgumentError: wrong number of arguments (given 1, expected 0)
An error occurred while installing rake (11.1.2), and Bundler
cannot continue.
Make sure that `gem install rake -v '11.1.2'` succeeds before bundling.

In Gemfile:
  turbolinks was resolved to 2.5.3, which depends on
    coffee-rails was resolved to 4.1.1, which depends on
      railties was resolved to 4.2.5.1, which depends on
        rake
owner@slaptop:~/job-hunter$ 
owner@slaptop:~/job-hunter$ gem install rake -v '11.1.2'
/usr/share/rvm/rubies/ruby-2.5.0/lib/ruby/gems/2.5.0/gems/gem-wrappers-1.4.0/lib/gem-wrappers/installer.rb:56: warning: Insecure world writable dir /home/owner/.rvm/gems in PATH, mode 040777
Successfully installed rake-11.1.2
Parsing documentation for rake-11.1.2
Done installing documentation for rake after 0 seconds
1 gem installed
owner@slaptop:~/job-hunter$ 
@a2ikm

This comment has been minimized.

Copy link

commented Aug 5, 2019

I got the same error.
Reinstalling ruby 2.5.3 with rbenv didn't fix it.

So I updated lib/rubygems/core_ext/kernel_require.rb directly like rubygems' commit, and updated rubygems with gem update --system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants
You can’t perform that action at this time.