I am an absolute beginner when it comes to Ruby - I just follow a step by step tutorial to install OpenProject.
Right now I have problems with the following line of command:
RAILS_ENV=production bundle exec rake db:create
It returns
Could not find rake-11.3.0 in any of the sources
When I check the ruby version with "ruby -v" it prints
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
Now, when I check for rake:
gem list | grep rake
the output is:
rake (12.0.0)
... so why is it complaining that it could not find rake-11.3.0 even tough version 12 is installed?
Thanks!
You application seems to have a hard dependency on rake 11.3.0, i.e. 12.0.0 is not acceptable to it.
Have you run Bundler first?
Run this command and it should install the version of rake you need, then your original command should work:
bundle
meaning you have to downgrade your rake version to version 11.3.0
you may try this command
bundle update rake
this will try to update just rake to follow your setting in your Gemfile
Related
I'm attempting (without much success) to run rake db:migrate on a rails project, however it returns:
Could not find rake-10.4.2 in any of the sources
Run bundle install to install missing gems.
I ran bundle install and worked fine - installed rake 10.4.2, however when I ran: rake --version (for some reason you can't do rake -v ???) and it shows: rake, version 0.9.6
I ran bundle update rake and returned my list of gems and then: Your bundle is updated!
Why isn't rake updating? Is there something I'm doing wrong (I'm new to rails btw - so this is probably really simple)
Any help is really appreciated
TL; DR: gem install rake -v '10.4.2'
So, I had this problem myself. I wanted to know why rails s would work yesterday and not today.
First I checked if I was in the correct directory, I was.
Then I re-ran bundle install to make sure rake was getting installed. It was, and I was able to see it in my Gemfile.lock
So I figured my gemset might be corrupt (I use RVM). rvm gemset empty then bundle install
Still, whenever I ran rails s, I got this error. bin/rails s worked, as well as bundle exec rails s. But I don't want a prefix, I want rails to work (It works in other rails projects)
Eventually I tried gem install rake and it worked! I recommend adding -v '10.4.2' to the command so that you get the correct rake version. Now when I which rake, I get the gemset for my project: "/Users/cm022291/.rvm/gems/ruby-2.2.1#project_gemset/bin/rake"
and when I run rails s the server starts successfully.
Try typing
bundle exec rake db:migrate
That will ensure that the Rake being invoked is the one you've bundled.
I am creating an application on ruby on rails:
After creating users, for validating users I am running below commands:
$ bundle exec rake db:migrate
$ bundle exec rake test:prepare
Both command are run properly on the rails commandLine, but when I run the below command:
$ bundle exec rspec spec/models/user_spec.rb
I am getting error below:
Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
And I am using 4.1.1 version of rails.
I don't understand why it comes.
Kindly suggest me, waiting for your reply.
Thanks.
More a note for posterity than anything, but this issue can also happen if you're using an older version of shoulda-matchers. You can see some discussion around this on their Github repo here, or on the rspec-rails repo here.
Update shoulda-matchers by running bundle update shoulda-matchers. You want the latest version (or at least 2.6.2) and this message should go away.
Include minitest gem in your 'Gemfile' and run bundle install
gem install 'minitest'
and then bundle install
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
Recently I installed jruby and put it in my home directory. This apparently hijacked rake:
$ which ruby
/usr/bin/ruby
$ which rake
/home/user/jruby-1.5.5/bin/rake
Which seemed to be causing problems. So I moved the jruby folder and reinstalled rake, which at first seemed to fix it:
$ which rake
/usr/bin/rake
But when I run rake it's still trying to use the one in jruby:
user#user-desktop:~/rails/appname$ rake db:migrate
bash: /home/user/jruby-1.5.5/bin/rake: No such file or directory
How do I fix this?
Try RVM. It is invaluable for isolating different Ruby versions. Once installed do
rvm install jruby
That gets you a separate environment for running JRuby. You can switch between versions with
rvm system
rvm jruby
I am running ROR 3.0.1 with Ruby 1.9.2p0 on a Mac Mini with Snow Leopard 10.6.4.
when I run rake db:migrate I get the following error
/usr/local/lib/ruby/1.9.1/rubygems.rb:340:in bin_path': can't find executable rake for rake-0.8.7 (Gem::Exception)
from /usr/local/bin/rake:19:in'
I have uninstalled and reinstalled rake but I still get the same error.
Thank you for your assistance!
When you're running the gem command, are you using "sudo"? Also, what do you get when you do "gem list rake"? And finally, what does "echo $PATH" give you? Check the return value of "which rake" while you're there in the terminal.
I had the same problem and my solution was to remove this file:
/usr/local/lib/ruby/gems/1.9.1/specifications/rake.gemspec
Apparently 1.9.2 comes with a version of rake internally, but has a problem finding it because of this gemspec file.