Anytime I try running the following basic rails commands, e.g. rails g model or rails console, I encounter the following error;
Could not find rake-12.3.1 in any of the sources
Run bundle install to install missing gems.
I've already looked through the forums for solutions and haven't found anything that solves my problem.
My gem file includes the necessary gem and I already ran bundle install.
Thanks in advance for your help.
This is because you have two versions of rake instaled.
Sometimes you have two rails projects with different rake versions and you did bundle install in one and after in another. (now you have two rake versions)
try gem uninstall rake
This command above will show you two these rake versions. You have to type the number that you want to unistall.
Related
I have a gem installed in my rails app, and it has some migrations in
/db/migrate
how can I run them?
I've tried running
bundle exec rails g gem-name:install
but I get an error saying could not find generator gem-name:install.
I've run up against this problem with 3 different Gems this morning. What am I missing?
Old question, so sorry for the bump, but you were actually pretty dang close.
the correct command would be rails gem_name:install:migrations
I am trying to freeze my Rails gem version as, day by day, some or the other gem version gets updated and sometimes I need to update the code.
I tried rake rails:freeze:gems but this gave me error:
rake aborted!
Don't know how to build task 'rails:freeze:gems'
This locks and then caches the gems into ./vendor/cache.
$ bundle package
Refer this link
rake rails:freeze:gems is an old Rails 2 way of doing it. I think you want to use Bundler's bundle install vendor/gems
"How do I freeze gems into a Rails 3 application?" seem to answer it better.
Background:
I get errors whenever I run rake in an older project. (uninitialized constant Rake::DSL).
The rails project in question is an old project that was started with Rails 2.1 (I think), and since then I've updated the OS on my laptop a couple of times, and made updates along the way to make it run.
Right now, the rails app works fine, provided I have RAILS_GEM_VERSION set to 2.3.5. I'm not sure if the app was completely updated to Rails 2.3.5.
There is no Gemfile in my older project.
If I create a brand-new rails project (and unset RAILS_GEM_VERSION), rake runs fine.
My question: To troubleshoot, I'd like to try newer versions of rake. I'd like to know how to force one specific version to be used, since it appears I have multiple versions installed.
Info on my environment:
$ gem list rake
*** LOCAL GEMS ***
rake (0.9.2.2, 0.9.2, 0.8.7, 0.8.3)
$ rake --version
rake, version 0.8.7
So it looks like it's picking up the 0.8.7 version.
All the help files online seem to tell me to specify the rake version in the Gemfile, but there isn't one in this project. (Maybe it predates gemfiles?)
If I unset the RAILS_GEM_ENVIRONMENT variable altogether, and try to run rake, I get:
rake aborted!
can't activate rails (= 2.3.5, runtime) for [], already activated rails-3.2.8 for []
None of the environment config files in my older project set that variable either.
This may be of help. Have you tried the underscore solution?
Example:
rake _0.9.2_
you can run rake specific version by using this
bundle exec rake ...
more detail see this - bundle exec, rake
You can uninstall the current version of rake and install another desired version using commands similar to the following:
gem uninstall rake 12.3.1
gem install rake 10.5.0
(Note: you might need to run as sudo for permissions)
I had a problem where I received the following error while trying to install rake 10.5.0:
Could not find a valid gem '0.8.7' (>= 0) in any repository
I resolved this problem by adding the following line to my Gemfile:
gem 'rake', ' <11.0'
After editing Gemfile I was able to successfully downgrade rake by updating my gems:
bundle update
I'm brand new to rails and am trying to dive in to my first project on my Mac, but am running in to an issue when I run Rake -T inside my project's root dir:
Could not find rake-0.9.2.2 in any of the sources
Run 'bundle install' to install missing gems.
After I run 'bundle install' I get:
Your bundle is complete! It was installed into ./rake
But I still get the same error when I call Rake again. My gemfile lists rake as:
gem 'rake', '0.9.2.2'
If I run 'bundle list' I can see:
* rake (0.9.2.2)
I've looked at other posts on stackoverflow and google, but none of the solutions have worked for me. I'd also really appreciate any background on what's going on here, for instance, should rake be installed in to the project directory like this?
I'm not sure what else I should include to help troubleshoot?
Thank you!
Go to https://rvm.io
instal rvm, rvm install 1.9.3, rvm use 1.9.3 --default
then you can manage your gems through rvm
It is the best solution to manage your gems.
please check if rvm is configured correctly - read about .rvmrc and setup_and_load_paths.rb http://blog.ninjahideout.com/posts/the-path-to-better-rvm-and-passenger-integration, also check lines at your nginx(i suppose you use it, cause, i just had exactly same problem) configs passenger_root and passenger_ruby (this one should include smth like output of which ruby + #your_gem_set)
good luck
Have you tried Gem install rake ?
Bundle will not install anything to your path I do not think but you may also get it working by bundle exec rake. If that doesn't work, try bundle exec rake -v0.9.2.2.2
I don't fully understand how bundle works either as running Rails commands on my computer runs Rails 3.2.2 while the bundle runs Rails 3.1.1
My question has already been asked here, but I am trying to understand the reasons behind it as opposed to how to work around it.
The error I got was;
You have already activated rspec-core 2.7.1, but your Gemfile requires rspec-core 2.6.4. Using bundle exec may solve this. (Gem::LoadError)
Now I have been given various solutions like using "mpapis-bundler", or to create a shorthand for "bundle exec", but I was under the impression that that was what
$bundle install --binstubs
was for.
More specifically, since I have no version numbers stated in my gemfile for rspec-rails, why do I have this incompatibility? My error also occurred when I tried
$rake db:migrate
telling me that
You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.9.2. Consider using bundle exec.
Any explanations would be appreciated.
EDIT:
All my gems for my app are in a gemset, and I have updated my gems again. Should an update not make sure that related gems are compatible?
This happens when you install more recent gems in your system than the one in your Rails app.
Bundler simply tells ou that you must stick with those your Gemfile states.
This is the purpose of running:
bundle exec rake db:migrate
-> running the very same rake version your Gemfile provides.
Concerning updating gems from gemfile, simply do:
bundle update
The easiest way to avoid this kind of boring stuff is to isolate your gems by creating gemsets. I use RVM for this purpose.
Regarding the rake version 0.9.2.2, either ways to do is create a new gemset for the project and maintain the gem version matching your Gemfile.
For instance if there are two rake gem containing versions 0.9.2 and 0.9.2.2, specifying rake version '0.9.2' though installs, but does not run any tasks apart from blowing error saying
'You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.9.2. Using bundle exec may solve this.'
I expect bundle install to lock the gem version in Gemfile.lock and pick the rake 0.9.2, but it looks in the gemset, where by default rake 0.9.2.2 is enabled.
Just reminding the purpose of bundle install from agile web development with rails book,
'bundle install will use the Gemfile.lock as a starting point, and install only the
versions of the various gems as specified in this file. For this reason, it is
important that this file gets checked into your version control system, as this
will ensure that your colleagues and deployment targets will all be using the
exact same configuration.'
but it doesn't work that way,
The better is to uninstall rake 0.9.2.2 and use rake 0.9.2 or, use bundle update rake, that updates the rake version in Gemfile.lock to 0.9.2.2
As #apneadiving said, running "$bundle install" updates all your bunldes. However, after running "$bundle install --binstubs" I still got errors for incompatible gems whenever I omitted the "bundle exec" part.
Subsequently I needed to update my Gemfile as I added another gem, and now they work. I'm assuming the incompatibilities were solved by the gem creators.