Mongoid/activesupport version problem - ruby

I'm attempting to use Mongoid from a plain Ruby script (not via Rails or any other framework) and I think I'm running into some version dependency conflicts:
/opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': RubyGem version error: activesupport(3.0.0 not >= 2.2.2, < 3.0.pre) (Gem::LoadError)
from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
from /opt/local/lib/ruby/gems/1.8/gems/mongoid-1.9.1/lib/mongoid.rb:24
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from ./rubymongo.rb:4
My local Rails has been upgraded to 3.0.0 already, and if I read the error correctly, somewhere there's a requirement saying activesupport has to be < 3.0.pre, and 3.0.0 is too new?
Is this because Rails 3.0 is brand new and maybe Mongoid has a config option somewhere with 3.0.pre defined that I need to upgrade? Where would I do that?
I used to have the old Rails still installed too, but got a different error:
/opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:233:in `activate': can't activate activesupport (>= 2.2.2, < 3.0.pre, runtime) for [], already activated activesupport-3.0.0 for ["mongoid-1.9.1"] (Gem::LoadError)
from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
from /opt/local/lib/ruby/gems/1.8/gems/mongoid-1.9.1/lib/mongoid.rb:24
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from ./rubymongo.rb:4
If I go back to having an older activesupport installed, how do I make sure the newer one isn't being hit as well?
I'm still very new to Ruby, so please elaborate in your answer.
After upgrading to the Mongoid 2.0 beta per Simon's suggestion, I'm getting a new conflict about bson being too new:
/opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:233:in `activate': can't activate bson (= 1.0.4, runtime) for ["mongoid-2.0.0.beta.17"], already activated bson-1.0.7 for ["mongo-1.0.7", "mongoid-2.0.0.beta.17"] (Gem::LoadError)
from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:249:in `activate'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `each'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:35:in `require'
from ./rubymongo.rb:4
Why is bson 1.0.4 already loaded? Is something else trying to load it explicitly? All my simple .rb script requires is rubygems and mongoid at this point.
Here's all the gems I use that sound relevant:
actionpack (3.0.0, 2.3.8)
activemodel (3.0.0)
activerecord (3.0.0)
activeresource (3.0.0)
activesupport (3.0.0)
bson (1.0.7, 1.0.4)
bson_ext (1.0.7)
mongo (1.0.8, 1.0.7)
mongo_ext (0.19.3)
mongoid (2.0.0.beta.17)
rails (3.0.0, 2.3.8)

I think I came across the same problem. It does seem to be caused by a dependency clash. mongo 1.0.8 will pull in bson 1.0.7 but mongoid depends on bson 1.0.4 which leads to the clash. I think it all comes down to the very specific dependencies that the mongoid beta has.
I managed to get this combination of gems working together:
activemodel (3.0.0)
activesupport (3.0.0)
rails (3.0.0)
mongo (1.0.7)
mongoid (2.0.0.beta.18)
bson (1.0.4)
This meant that I had to explicitly install mongo 1.0.7 and bson 1.0.4 and uninstall the latest versions (mongo 1.0.8 and bson 1.0.7). I was then able to run a simple script.

Indeed there's a Gem version conflict.
There are two versions of mongoid available right now:
* 1.9.1 stable
* 2.0.0 beta
Both should work well with Rails 3. Even mongoid 1.9.1, which is a little bit more old, depends on activesupport <= 3.0.0 which means Rails 3 is a valid dependency.
Perhaps, you're still working with Rails 3 RC.
I suggest you to:
Make sure you changed your Gemfile to use Rails 3, regenerated your Gemfile.lock and reinstalled the dependencies
gem "rails", 3.0.0"
$ bundle update
$ bundle install
If the problem persist, try upgrading to mongoid 2.0.0 beta.

Related

Bundler could not find compatible versions for gem activesupport with specific versions

I am trying to do a bundle install but am getting the following error:
Bundler could not find compatible versions for gem "activesupport":
In Gemfile:
***private gem*** was resolved to 0.4.2, which depends on
activesupport (~> 5.0)
***private gem*** was resolved to 1.0, which depends on
activesupport (~> 4)
What does this mean?
I have searched through the internet and getting answers such as do a bundle update, or remove the Gemfile.lock, but none has been working for me.
I have also tried doing a gem install activesupport -v 4.0 and gem install activesupport -v 5.0
Thanks in advance

Bundler could not find compatible versions for gem "actionpack"

When I'm trying to bundle update i get this error:
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
actionpack (>= 4.2.5, ~> 4.2)
railties (>= 4.2.5, ~> 4.2) was resolved to 4.2.5, which depends on
actionpack (= 4.2.5)
railties (>= 4.2.5, ~> 4.2) was resolved to 4.2.5, which depends on
actionpack (= 4.2.5)
railties (>= 4.2.5, ~> 4.2) was resolved to 4.2.5, which depends on
actionpack (= 4.2.5)
strong_parameters (~> 0.2.3) was resolved to 0.2.3, which depends on
actionpack (~> 3.0)
This problem can arise if you update the Rails version (for example from 4 to 5), and you have included certain gems locked to a specific version which still depend on an old ActionPack version from the old Rails version. Then bundler says..
Bundler could not find compatible versions for gem "actionpack"
..because the new rails version wants to use the new ActionPack gem, but one of the gems wants to use the old ActionPack gem.
You should've include the Gemfile in the question.
Anyway, in Rails 4.x strong_parameters gem is not required. If you have that in your gemfile, remove it and try again.
You don't need the strong_parameters gem. Strong parameters is part of rails 4, the gem allows that feature to be backported to rails 3.x
This is partly to help rails 3.x users to migrate to rails 4 and I think it may have been used earlier to prototype how strong parameters should work (by allowing people to use it without switching to rails edge)

Error while installing spree

Bundler could not find compatible versions for gem "railties":
In Gemfile:
rails (= 3.2.8) ruby depends on
railties (= 3.2.8) ruby
sass-rails (~> 4.0.0) ruby depends on
railties (4.0.0)
This error occured, how can i fix this error.
I do not know railties and sass-rails version.
If you're using Rails 3.2 you should use all gems with that branch too, i.e.:
Gemfile:
gem https://github.com/rails/sass-rails.git, branch: '3-2-stable'
You can see branches listed on GH next to green compare button (with new layout).
What if specific gem doesn't have branches? Well, you can fork it, modify the gemspec,see what fails and fix it.

Trying to update to gem 3.0.20 and install a DevKit

Heroku advised updating to this gem because of a security patch but it has caused me all kinds of headaches and now my local environment isn't working correctly. They suggested doing this as a security precaution. They suggested going into my app, changing the gemfile version and simply running 'bundle update rails'. Here was the output:
$ bundle update rails
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.20)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.20)
Using erubis (2.6.6)
Using rack (1.2.8)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.37)
Using actionpack (3.0.20)
Using mime-types (1.21)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.2.19)
Using actionmailer (3.0.20)
Using arel (2.0.10)
Using activerecord (3.0.20)
Using activeresource (3.0.20)
Using bundler (1.0.22)
Installing json (1.7.7) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
c:/Ruby192/bin/ruby.exe extconf.rb
creating Makefile
make
'make' is not recognized as an internal or external command,
operable program or batch file.
Gem files will remain installed in c:/Ruby192/lib/ruby/gems/1.9.1/gems/json-1.7.7 for inspection.
Results logged to c:/Ruby192/lib/ruby/gems/1.9.1/gems/json-1.7.7/ext/json/ext/generator/gem_make.out
An error occured while installing json (1.7.7), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.7'` succeeds before bundling
Then they pointed to a thread on here of someone having a similar problem. It involved downloading a Devkit etc. I tried following the instructions but now everything is just broke. I'm familiar working with Ruby on Rails but never had to install it (was already set up on my work computer) and I find it hard to believe that updating it is this difficult when the whole philosophy behind ruby on rails is simplicity. I've got to be missing something or not using the proper resource.
The current version of ruby on my machine is ruby 1.9.2p0 (2010-08-18) [i386-mingw32]
$rails --version
Rails 3.0.3
And the DevKit I downloaded is
DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe
from http://rubyinstaller.org/downloads
I then tried to walk through the installation steps on this site https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
It always comes back to a 'make' error or 'json' error.
Maybe I have different versions conflicting??
Now I get the following error when I just try to start WEBrick to run my app:
$ rails s
c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/rubygems_integrat
ion.rb:183:in `stub_source_index170': uninitialized constant Gem::SourceIndex (N
ameError)
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/ruby
gems_integration.rb:303:in `stub_rubygems'
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/ruby
gems_integration.rb:246:in `replace_entrypoints'
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runt
ime.rb:14:in `setup'
from c:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler.rb:1
10:in `setup'
from c:/rails/thumb/costrecovery/config/boot.rb:8:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from script/rails:5:in `<main>'
Any advice is greatly appreciated.

Ruby gems fighting for two separate versions of activesupport?

I'm trying to run the resque server from the command line using:
rake resque:work
and ruby is complaining as follows:
Bundler could not find compatible versions for gem "activesupport":
In Gemfile:
daemon-kit (>= 0) ruby depends on
activesupport (< 3.2.0, >= 2.3.5) ruby
actionpack (>= 0) ruby depends on
activesupport (3.2.12)
How do I resolve these dependencies? Can I install two versions of activesupport in the same RVM gemset?
You'll need to downgrade your version of activesupport to a version that supports daemonkit - or look for an updated version of daemonkit. Your current version of rails / activesupport is newer than the version supported by your version of daemon-kit.
You can have multiple versions of activesupport in a single gemset, but only one of them can be activated at once.

Resources