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

Unable to install gem at correct version (ruby 3.0.0): undefined method `request' for nil:NilClass #4338

Open
1 of 5 tasks
codeblooded opened this issue Feb 2, 2021 · 5 comments

Comments

@codeblooded
Copy link

I'm having a problem or would like to suggest a feature.

My current problem is an inability to install gems at a specific version. I am running Ruby 3.0.0 on 13" Macbook Pro (Apple Silicon, M1) using a Terminal with Rosetta. rbenv was installed with homebrew, ruby was installed with rbenv, ruby gems was updated using gem update --system.

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
3.2.7
$ ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]

I will abide by the code of conduct.

2021-02-02 00 04 30

@codeblooded codeblooded changed the title Gems installing at incorrect versions: undefined method `request' for nil:NilClass Unable to install gem at correct version: undefined method `request' for nil:NilClass Feb 2, 2021
@codeblooded codeblooded changed the title Unable to install gem at correct version: undefined method `request' for nil:NilClass Unable to install gem at correct version (ruby 3.0.0): undefined method `request' for nil:NilClass Feb 2, 2021
@codeblooded
Copy link
Author

I can confirm the installation works fine with ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20], so this appears to only be an issue with ruby gems and ruby 3.

@deivid-rodriguez
Copy link
Member

I can confirm this issue.

The underlying error is that cocoapods-generate at version 2.2.1 cannot be installed on ruby 3, because it depends on cocoapods-disable-podfile-validations ~> 0.1.1,and the only version of cocoapods-disable-podfile-validations satisfying that (0.1.1) needs ruby ~> 2.1.

The problem here is that rubygems is unable to properly explain this and crashes instead.

@deivid-rodriguez
Copy link
Member

Fixing this issue is more complicated than it seems. To show proper explanation for resolution errors like this, we need to add the current ruby (and rubygems) version as metadata dependencies to the resolution (like bundler does), so that when conflicts happen, they make sense and can explain the error to the user.

In #4110 I implemented a very basic approach of filtering out specs not matching the current ruby (and rubygems) version as they come from the API. However, that approach is not enough here.

I have a WIP branch but it needs a lot of work.

@iainbeeston
Copy link

I've added an example gem that has this issue too (although simply running gem install as above might be simpler) https://github.com/iainbeeston/gem_testcase

@BabyBusGitHub
Copy link

BabyBusGitHub commented Oct 13, 2021

$ gem install cocoapods-generate -v 2.0.1 --backtrace

ERROR:  While executing gem ... (NoMethodError)
    undefined method `request' for nil:NilClass
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/resolver/conflict.rb:47:in `conflicting_dependencies'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/exceptions.rb:32:in `conflicting_dependencies'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/exceptions.rb:26:in `initialize'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/resolver.rb:193:in `exception'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/resolver.rb:193:in `raise'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/resolver.rb:193:in `rescue in resolve'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/resolver.rb:191:in `resolve'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/request_set.rb:411:in `resolve'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/dependency_installer.rb:333:in `resolve_dependencies'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/commands/install_command.rb:198:in `install_gem'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/commands/install_command.rb:223:in `block in install_gems'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/commands/install_command.rb:216:in `each'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/commands/install_command.rb:216:in `install_gems'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/commands/install_command.rb:164:in `execute'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/command.rb:323:in `invoke_with_build_args'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/command_manager.rb:178:in `process_args'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/command_manager.rb:147:in `run'
	~/.rvm/rubies/ruby-3.0.0/lib/ruby/site_ruby/3.0.0/rubygems/gem_runner.rb:53:in `run'
	~/.rvm/rubies/ruby-3.0.0/bin/gem:15:in `<main>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants