My setup: Rails 3.0.9, Ruby 1.9.2
I want to check the gem version for my app through the Rails console. In my gemfile, I have
gem 'rack', '1.2.3'
Ran bundle install after. In the Rails console,
>> Rack.version
=> "1.1"
Any idea why?
UPDATE
Gemfile.lock
GEM
remote: http://rubygems.org/
specs:
actionpack (3.0.9)
...
rack (~> 1.2.1)
...
rack (1.2.3)
rack-mount (0.6.14)
rack (>= 1.0.0)
warden (1.0.4)
rack (>= 1.0)
DEPENDENCIES
...
rack (= 1.2.3)
...
There are several rack versions listed in gemfile.lock.
Rack.version
will return the protocol version,
Rack.release
is probably what you are you looking for.
https://github.com/rack/rack/blob/master/lib/rack.rb#L14
Otherwise:
Gem.loaded_specs["rack"]
Example:
Gem.loaded_specs["rack"]
# => #<Gem::Specification name=rack version=1.3.2>
Gem.loaded_specs["rack"].version
# => #<Gem::Version "1.3.2">
Gem.loaded_specs["rack"].version.to_s
# => "1.3.2"
Every gem has ::VERSION constant..
so just use Rack::VERSION or OpenSSL::VERSION in console which should give you the version of gem loaded in that console.
we can use bundle list or bundle show to list all Gems included by the bundle.
Maybe you have multiple version of rack installed, try running gem uninstall rack and see if it offers you two options to choose from, Rack 1.1 and Rack 1.2.3. If so, choose to uninstall Rack 1.1.
If this still does not work, just uninstall Rack and try running bundle update.
I had this problem when I was using multiple rake versions 0.8.7 and 0.9.2, this helped me.
Related
I have tried to rebuild my gemlock file by removing it and running bundle install.
I have tried to remove the gem rack 1.6.1 and got this message:
You have requested to uninstall the gem:
rack-1.6.1
actionpack-4.2.1 depends on rack (~> 1.6)
I have done bundle update but it only updates rack to version 1.5.5
How can I resolve this conflict?
I turns out that I was using Rails 4.1.2 which used Rack 1.5.5. When I updated my Rails app to use Rails 4.2.6 the later version of rack was loaded and this conflict in the gems was solved.
When I try to install friendly_id :version => "~> 3.0.6" with rails 2.3.3 wtih ruby 1.8.7 getting error for Ruby version
ERROR: Error installing friendly_id: activesupport requires Ruby version >= 1.9.3.
Current version of Rails is 2.3.3 and Ruby is 1.8.7
I have goggled but couldn't find any solution, Please help me for resolving it.
my gems are:
and gem list
* LOCAL GEMS *
actionmailer (2.3.3)
actionpack (2.3.3)
activerecord (2.3.3)
activeresource (2.3.3)
activesupport (2.3.18, 2.3.3)
atomic (1.1.14)
authlogic (2.1.9)
bundler (1.3.5)
bundler-unload (1.0.1)
crummy (1.7.2)
currencies (0.4.2)
declarative_authorization (0.5.7)
exceptional (2.0.6)
geoip (1.3.0)
geokit (1.6.7)
geonames (0.3.3)
god (0.13.3)
i18n (0.6.5)
json (1.8.0)
minitest (4.7.5)
multi_json (1.8.0)
rack (1.0.1)
rails (2.3.3)
rake (10.1.0)
rdoc (4.0.1)
rdoc-data (4.0.1)
rubygems-bundler (1.2.2)
rubygems-update (1.4.2)
rvm (1.11.3.8)
SystemTimer (1.1.3)
thread_safe (0.1.3)
tzinfo (1.1.0, 0.3.37)
validates_timeliness (2.3.2)
Please help me how to install friendly_id with rails2.3.3 and Ruby 1.8.7
I think you need to check exactly what friendly_id version you are attempting to install outside of Gemfile specifications.
According to friendly_id documentation here:
For (Active Record) 2.3 support, you can use FriendlyId 3.x, which will continue to be
maintained until people don't want it any more.
So, 3.0.6 should work for you, if that is what you are installing. Use "gem list friendly_id" to see what you have locally, which should be nothing. Use "gem list friendly_id -r" to see what is available remotely. It will try to install the highest level available by default. What I got was friendly_id (4.0.10.1).
Do you have 3.0.6 downloaded to your system? If you do, are you using gem build/gem install to build and install it? At what point do you get the error message? The gem install will install the locally built version by default if you are in its directory...
If all of this still fails, post the Gemspec file from it so that we can review the requirements. You may need to update these before the build/install. However, YMMV and you must test it fully before you can trust it if you change Gemspec.
However, let me reiterate the recommendation to upgrade to current supported software, especially if you are making extensive changes. As you indicated, you may face having to upgrade both your local code and the installed gems. That is the price you pay for support and advanced features.
Out of the blue, I started getting the following error message:
(in /Users/me/.rvm/gems/ruby-1.9.3-p125#mysql2/gems/rails-0.9.5)
rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/Users/me/.rvm/gems/ruby-1.9.3-p125#mysql2/gems/rails-0.9.5/Rakefile:3:in `<top (required)>'
When I do rails s (in my development environment terminal - Mac Mountain Lion). This application is in production, so I went to the production environment, did a bundle show, and modified my Gemfile, to harcode the gems versions.
Here's what I have now on my my local development environment (what's producing the error message).
actionmailer (3.2.3)
actionpack (3.2.3)
activemodel (3.2.3)
activerecord (3.2.3)
activeresource (3.2.3)
activesupport (3.2.3)
annotate (2.4.1.beta1)
arel (3.0.2)
bcrypt-ruby (3.0.1)
bootstrap-datepicker-rails (0.6.15)
bootstrap-sass (2.0.2)
builder (3.0.4)
bundler (1.1.3)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.6.1)
commonjs (0.2.6)
devise (2.0.4)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.4.0)
factory_girl (3.2.0)
factory_girl_rails (3.2.0)
hike (1.2.1)
i18n (0.6.4)
journey (1.0.4)
jquery-rails (2.0.2)
json (1.7.1)
less (2.2.2)
less-rails (2.2.6)
libv8 (3.3.10.4)
mail (2.4.4)
mime-types (1.21)
multi_json (1.6.1)
mysql2 (0.3.11)
nokogiri (1.5.6)
orm_adapter (0.0.7)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.3)
railties (3.2.3)
rake (10.0.3)
rdoc (3.4)
rest-client (1.6.7)
rspec (2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
sass (3.2.7)
sass-rails (3.2.5)
sprockets (2.1.3)
stripe (1.7.0)
therubyracer (0.10.1)
thor (0.14.6)
tilt (1.3.5)
tinymce-rails (3.4.8)
treetop (1.4.12)
twitter-bootstrap-rails (2.1.0)
tzinfo (0.3.37)
uglifier (1.2.4)
warden (1.1.1)
webrat (0.7.1)
I researched Stackoverflow and the web, and none of the suggestions worked (changing the rake gem version to something different. like 0.8.7, etc., editing my app Rakefile to suppress deprecation errors, etc.). I also added rdoc and in my Rakefile, I required 'rdoc/task'
Still, the same error.
Just to help anyone else who has had this hassle.
If you are like me, then your problem is that the current version of rails is 4 and you are wanting to use an older version like 3.0.7
If you install rails fresh to learn it ,say, and the tutorial you are using is for a 3.0.x version of rails OR your job requires the use of the older version of rails.. then you can get into this hole.
In my case I got a 3.0.7 rails project dumped on me and was told to learn rails and make some enhancements to this code.
so, I just started learning rails and was following the tutorial until I got this error when doing a 'rake db:migrate'
rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/Users/pj/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.0.7/lib/rails/tasks/documentation.rake:1:in `require'
/Users/pj/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.0.7/lib/rails/tasks/documentation.rake:1:in `<top (required)>'
/Users/pj/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.0.7/lib/rails/tasks.rb:15:in `load'
/Users/pj/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.0.7/lib/rails/tasks.rb:15:in `block in <top (required)>'
This happened cos I was using an older version of rails.. in my case 3.0.7
If you run a 'bundle show', like I did then, you may see that you are using the rake version 10.0.0 or something like that...and you need to be running rake 0.9.2 ... which is where the problem is coming from..
The solution for me was to (a) add a gem to my gemfile and (b) to a bundle install
So, in my gemfile I added:
gem 'rake', '0.9.2'
Then did a
'bundle install'
Got this message:
You have requested:
rake = 0.9.2
The bundle currently has rake locked at 10.1.0.
Try running `bundle update rake`
And so I did that...
bundle update rake.
And that went fine.
then when I did the'rake db:migrate' it just worked.
Hope this helps somebody.
Vida.
PS: if you are new to rails, like me, and you inherit an older rails app then for gods sake NEVER run 'bundle update' or you will enter a world of pain. That command updates all your gems to the very latest versions and you end up with a load of problems with incompatibilities. The only way out of it is if you are lucky enough to have git installed and can do a 'git checkout' to go back...
I struck with this same problem when try to install gems by the command rake gems:install my rails version is rails2.3.2 and i have rvm installed.
my gem list is,
actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
bundler (1.3.5)
rails (2.3.2)
rake (10.0.4)
rubygems-bundler (1.1.1)
rvm (1.11.3.7)
so uninstalled the rake by the command
rvm use ruby-1.8.7-p371#global && gem uninstall rake -v 10.0.4
then i installed rake of older version
rvm use ruby-1.8.7-p371#global && gem install rake -v 0.8.7
now rake gems:install works fine
hope it may help some one!
Upgrading to rails 4.0.0 I got the same error.
rails -v
(in /Users/oma/.rvm/gems/ruby-2.0.0-p247/gems/rails-0.9.5)
rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/Users/oma/.rvm/gems/ruby-2.0.0-p247/gems/rails-0.9.5/Rakefile:3:in `<top (required)>'
(See full trace by running task with --trace)
To upgrade, I removed the version number in Gemfile
source 'https://rubygems.org'
gem 'rails' # NO VERSION
and did bundle update as I thought this would pick the last. But somehow, I got rails 0.9.5. It feels like some practical joke, really, lol
$ gem list rails
rails (4.0.1.rc2, 4.0.0, 0.9.5)
I can't tell you with 100% certainty that this was the cause, but we were two people, working on the same branch and seeing the same error. The fix worked for both of us. Simply
specify rails version!
$gem uninstall rails -v 0.9.5
Gemfile
source 'https://rubygems.org'
gem 'rails', '4.0.0'
then bundle, run rails -v, giggle (or cry) and get back to producing
Take a look at similar problem solution on StackOverflow
Another option is to use (example taken from Redmine Rakefile)
require 'rdoc'
require 'rdoc/task'
Instead of
require 'rake/testtask'
require 'rake/rdoctask'
The following works for me using ruby 1.9.3p448 (2013-06-27 revision 41675):
1) Use rake version 10.1.0 (put following in your Gemfile):
gem 'rake', '10.1.0'
(Note you can likely use another version, but the line number below might change.)
2) Comment line 54 of your Rakefile and replace it as follows:
#require 'rake/rdoctask'
gem 'rdoc', ">= 2.4.2"
require 'rdoc/task'
3) Test
$ bundle install
$ bundle exec rake
How can I use rack 1.3.0 with rails. I tried putting gem 'rack', '1.3.0' in Gemfile and did bundle update rack but it says
Bundler could not find compatible versions for gem "rack":
In Gemfile:
rails (= 3.0.9) depends on
rack (~> 1.2.1)
rack (1.3.0)
I am having issues with rack version <= 1.2.3 here lib/rack/utils.rb#L495. I don't see this in rack 1.3.0, so wanted to give a try. But clearly rails is not allowing to use rack 1.3.
Is there any workaround?
The short answer is: you can't use rack 1.3 with Rails 3.0. As the error states, Rails 3.0.9 depends on Rack 1.2.x with x >= 1.
If you need rack 1.3, you should try Rails 3.1 which currently depends on rack ~> 1.3.2 (i.e. 1.3.x with x >= 2). An alternative could be to change the actionpack gemspec locally to require rack 1.3. But then you are on your own and there will probably be grues coming out of holes and eating all your loved ones...
Ok i keep getting this error
Could not find tzinfo-0.3.24 in any of the sources (Bundler::GemNotFound)
I am using rvm and i just created a gemset and i have this
gem list
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.3)
actionpack (3.0.3)
activemodel (3.0.3)
activerecord (3.0.3)
activeresource (3.0.3)
activesupport (3.0.3)
arel (2.0.7)
bcrypt-ruby (2.1.4)
builder (2.1.2)
bundler (1.0.7)
devise (1.1.5)
erubis (2.6.6)
i18n (0.5.0)
mail (2.2.14)
mime-types (1.16)
mysql (2.8.1)
paperclip (2.3.8)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack-test (0.5.7)
rails (3.0.3)
railties (3.0.3)
rake (0.8.7)
riddle (1.2.2)
thinking-sphinx (2.0.0)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.24)
warden (1.0.3)
will_paginate (3.0.pre2)
and my Gemfile is
source 'http://rubygems.org'
gem 'rails', '3.0.3'
gem 'mysql'
gem 'devise'
gem 'thinking-sphinx', '2.0.0', :require => 'thinking_sphinx'
gem "paperclip", "~> 2.3"
gem "will_paginate", "~> 3.0.pre2"
any ideas...it was working fine till today
Try including tzinfo-0.3.24 in your Gemfile and doing bundle exec with the command that gives you the error. Alternatively you could bundle install --development to get the Gems in the vendor folder. Let us know how you get on.
After DLL Hell we have Gem Hell. It looks like we have the same dependency hell in Ruby as in other communities. Welcome :-)
The gem tzinfo with the right version 0.3.24 seems to be missing, or it is not referenced correctly in your Gemfile. Check your Gemfile and your Gemfile.lock. The latter is useful to find out dependencies, and it should be updated if the Gemfile is changed (by running a bundle install).
If you have installed the gems locally, by using gem install --user-install gemname or bundle install --path ~/.gem, then you maybe have multiple gems in multiple locations. Check out the GEM PATHS by calling a gem env command from the command line.
And by the way, you seem to use Rails 3.0.x with the old mysql gem. The mysql2 gem is now the default in Rails 3. I would recommend to use the mysql2 gem instead by adding gem 'mysql2' to the GemFile and by using using the mysql2 adapter in your database.yml.