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

'check_version_conflict': using 'rails new', with a version, when Rails 5.1.X installed #29113

Closed
roberts1000 opened this issue May 16, 2017 · 16 comments

Comments

@roberts1000
Copy link
Contributor

roberts1000 commented May 16, 2017

Steps to reproduce

Make sure Rails 5.0.3 is installed on the system. Uninstall Rails 5.1.0 and Rails 5.1.1 (along with all of their component gems). Run

rails _5.0.3_ new foo --skip-bundle

Everything works fine. Now install Rails 5.1.1. Run the same command

rails _5.0.3_ new foo --skip-bundle

Expected behavior

rails new should be to create a Rails 5.0.3 application.

Actual behavior

rails new crashes with the following error in the console

.../.rvm/rubies/ruby-2.3.4/lib/ruby/site_ruby/2.3.0/rubygems/specification.rb:2278:in `check_version_conflict': can't activate activesupport-5.1.1, already activated activesupport-5.0.3 (Gem::LoadError)

System configuration

Rails version: See above

Ruby version: Tested with Ruby 2.3.4 and 2.3.3.

@roberts1000 roberts1000 changed the title 'check_version_conflict' using rails new, with a version, when Rails 5.1.X installed 'check_version_conflict': using 'rails new', with a version, when Rails 5.1.X installed May 16, 2017
@deivid-rodriguez
Copy link
Contributor

Just run into this too. But it seems like a rubygems problem?

@djonasson
Copy link

I just had the same problem with Ruby 2.3.1-p112 but with 2.3.3-p222 it worked.

@ssaunier
Copy link

I just had this problem as well. I use rbenv on OSX. On Ruby 2.4.1 I get this error message:

$ gem list | grep "^rails ("                                                                                                                                          
rails (5.1.1, 5.0.2, 5.0.1)

$ rails _5.0.2_ new test-50                                                                                                                                           
/usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/specification.rb:2278:in `check_version_conflict': can't activate activesupport-5.1.1, already activated activesupport-5.0.2 (Gem::LoadError)
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/specification.rb:1404:in `activate'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:89:in `block in require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:88:in `each'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:88:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent.rb:15:in `<top (required)>'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.0.2/lib/active_support/logger_silence.rb:3:in `<top (required)>'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.0.2/lib/active_support/logger.rb:1:in `<top (required)>'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.0.2/lib/active_support.rb:27:in `<top (required)>'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/generators.rb:6:in `<top (required)>'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/commands/application.rb:1:in `<top (required)>'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/cli.rb:14:in `<top (required)>'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:68:in `require'
	from /usr/local/opt/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.0.2/exe/rails:9:in `<top (required)>'
	from /usr/local/opt/rbenv/versions/2.4.1/bin/rails:22:in `load'
	from /usr/local/opt/rbenv/versions/2.4.1/bin/rails:22:in `<main>'

@matthewd
Copy link
Member

Yeah, this seems to be a RubyGems problem.

AFAICS there are two things in play:

  • firstly, the "requirable file" cache doesn't get updated when a miss triggers a gem activation, so the file that originally triggered the gem to activate (in this case, concurrent/map) never gets the fast-path, and instead falls through to find_in_unresolved_tree. That seems to have some less-than-ideal performance implications, but only becomes a Real Problem here because:
  • secondly, find_in_unresolved_tree relies on has_conflicts? to filter plausible-sounding paths to the desired gem, and ends up choosing a path through a newer version of activesupport, even though another has already been activated, because has_conflicts? checks the dependencies of loaded gems, but doesn't check for a different version of that gem itself having already been loaded.

Throwing:

return true if already = Gem.loaded_specs[name] and not already.version == version

into has_conflicts? seems to make things happier for me, but I don't know enough about RubyGems to opine on the wider implications.

@a-barbieri
Copy link

Issue is closed, but I haven't understood how to solve to problem...

@kent
Copy link

kent commented Jun 8, 2017

Agreed, any reproducible fix?

@kent
Copy link

kent commented Jun 8, 2017

@a-barbieri I did the following and it worked.

Re-install rbenv distro you want (I chose 2.3.1)
cd apps
rbenv local 2.3.1
gem update --system
rails new whatever

So it could very well be an rbenv / rubygems issue. I tried just remove RubyGems and starting over and that didn't work. Only when I re-installed the rbenv distro did it work.

Hope that helps.

@a-barbieri
Copy link

Thanks @kent, I'm using RVM, but I guess this won't make any difference. I'll go through the re-installation process as soon as I have some spare time.

At the moment I simply avoided using rails new command and just copy/pasted Rails from another app.

@tfogg2
Copy link

tfogg2 commented Jun 13, 2017

A simple 'gem update rails' solved this problem for me.

@a-barbieri
Copy link

That did it for me as well.

@YaEvan
Copy link

YaEvan commented Jun 19, 2017

The same problom for me. I fix it by use
gem uninstall activesupport --version=5.1.1

@emekdahl
Copy link

'gem update rails' also worked for me!

@Liqiankun
Copy link

'gem update rails' does not work for me!

@Liqiankun
Copy link

@YaEvan It works for me!

@gglaine
Copy link

gglaine commented Oct 3, 2017

gem update rails - way to go !

@sophiav
Copy link

sophiav commented Nov 19, 2017

just tried gem update rails and it worked for me too..

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

No branches or pull requests