Forum: Ruby Run time error with multiple version of gems installed

Posted by Mallikarjuna Yaddala (mallikarjunece)
on 2013-01-02 07:52
Hi all,

I have installed two versions of rake for different projects.

Due to this i am getting the following error


rake aborted!
You have already activated rake 0.9.6, but your Gemfile requires rake
0.9.2.2. Using bundle exec may solve this.

Can any one help me , how to solve this without changing Gemfile/`bundle
exec` ?


FYI : I have two versions of gems


rake (0.9.6, 0.9.2.2)
    Author: Jim Weirich
    Rubyforge: http://rubyforge.org/projects/rake
    Homepage: http://rake.rubyforge.org
    Installed at (0.9.6): /usr/local/rvm/gems/ruby-1.9.3-p286
                 (0.9.2.2): /usr/local/rvm/gems/ruby-1.9.3-p286@global

    Ruby based make-like utility.


Thanks in advance ........
Posted by Bartosz DziewoƄski (matmarex)
on 2013-01-02 17:54
(Received via mailing list)
I'd have to see some of your code, but you probably have to add `gem 
'rake', '0.9.2.2'` before `require 'rake'` somewhere. Otherwise Rubygems 
will assume you want the newest version available.
Posted by D. Deryl Downey (ddd)
on 2013-01-02 18:10
Attachment: compose-unknown-contact.jpg (770 Bytes)
(Received via mailing list)
Add:
     gem 'rake', '0.9.2.2'

to your Gemfile, and rerun 'bundle install'

Then when you run:

     bundle exec rake <some_rake_command_here>

it will use the version specified in the Gemfile, as well as lock you to
that version
in the Gemfile.lock file.

Also, if you are creating a gem, you can:

     gem.add_dependency "rake", "0.9.2.2"

in your <gemname>.gemspec file and ensure that the last line in your
Gemfile says

     gemspec

which will then record the dependency, and enforce the version which
will automate
installing that version of rake when your gem is installed.

That last bit is *only* if you're making a gem. It has no application to
a regular project.

> Hi all,
> Can any one help me , how to solve this without changing Gemfile/`bundle
> Installed at (0.9.6): /usr/local/rvm/gems/ruby-1.9.3-p286
> (0.9.2.2): /usr/local/rvm/gems/ruby-1.9.3-p286@global
>
> Ruby based make-like utility.
>
>
> Thanks in advance ........
>

--
D. Deryl Downey

"The bug which you would fright me with I seek" - William Shakespeare - 
The Winter's Tale, Act III, Scene II - A court of Justice.
Posted by Dave Aronson (Guest)
on 2013-01-02 18:48
(Received via mailing list)
On Wed, Jan 2, 2013 at 1:52 AM, Mallikarjuna Yaddala
<lists@ruby-forum.com> wrote:

> I have installed two versions of rake for different projects.
>
> Due to this i am getting the following error
>
> rake aborted!
> You have already activated rake 0.9.6, but your Gemfile requires rake
> 0.9.2.2. Using bundle exec may solve this.

Look into rvm or rbenv.  These can be used to manage gemsets so you
can switch between them for different projects.  Also, when you start
your projects (there's probably a way to retrofit but I'm too lazy,
er, I mean, busy to go figure it out), do rails new your_project_name
--skip-bundle, followed by bundle install --path vendor --binstubs.
That will put the gems for this project in the vendor dir under the
project, making a neatly self-contained unit.  (The downside is
possible duplication, soaking up more disk space than reusing the same
copy of gems.)

-Dave
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.