Could not find rake with bundle exec - ruby-on-rails

When I try execute 'bundle exec rake anything', I get error:
Could not find rake-10.1.0 in any of the sources.
Run `bundle install` to install missing gems.
But when I execute simple 'rake anything', rake is working.
Of cause, I tried setup gem any way, which I know:
gem install rake -v=10.1.0
Wrote "gem 'rake', '10.1.0'" in Gemfile, then execute bundle install
I installed gem for all rvm: rvm all do gem install rake -v 10.1.0
This situation really frustration, because simple rake works, but with bundle exec doesn't want.
I need execute rake with bundle exec
Really need your help!

I had the same issue, with exactly the same error message, with the same Ruby version yesterday. I solved it by removing this line from .bundle/config in my repository:
BUNDLE_DISABLE_SHARED_GEMS: '1'

I have the same problem and my solution was:
Delete my gemfile.lock
rm Gemfile.lock
donwgrade rake in my gemfile
gem 'rake', '10.0.2'
finally
bundle install

I had this problem with an AWS instance, managed by OpsWorks. I was logged in as ec2user. I switched over to the deploy user via sudo su - deploy and ran the bundle command again and it completed without error

I got a similar error when I tried running 'bundle exec $EXECUTABLE' without running 'bundle install' first :|

Related

Your bundle is locked to rake (12.0.0), but that version could not be found in any of the sources listed in your Gemfile.

I get the following error message when starting the rails server:
Your bundle is locked to rake (12.0.0), but that version could not be found in any of the sources listed in your Gemfile. If you haven't changed sources, that means the author of rake (12.0.0) has removed it. You'll need to update your bundle to a different version of rake (12.0.0) that hasn't been removed in order to install.
I specified gem 'rake', '12.0.0' in the gemfile but that doesn't fix it. I tried bundle update rake, deleting the Gemfile.lock and generating it with bundle exec bundle install. I also prepended `bundle exec1 to al my commands which does nothing.
My Gemfile.lock already specifies rake version 12.0.0, and there are no other versions installed.
See my gemfile:
http://pastebin.com/L4tVFWz9
And rakefile:
http://pastebin.com/K7p2ajsE
I tried the solutions suggested in Already activated rake version different than what Gemfile requires prevents rake commands
Different methods to solve this issue,
Step1:
gem install rubygems-bundler
gem regenerate_binstubs
Step2:
Remove the vendor/bundle directory.
Run bundle install to rebuild it
Step3:
Try, gem update bundler
Here is a link where the issue got solved. Check this is very useful
Try:
gem install rubygems-bundler
gem regenerate_binstubs
Not really a fundamental solution, but if you really have to run some Rails commands urgently and needs a temporary fix, try bundle exec rails c rather than bin/rails c.
Enter command :-
bundle update rake

Bundle install failing on production server

I am trying to get a rails app up in production. I have uploaded it to the server, and ssh'ed into it without a problem. When I try to run: rake db:migrate RAILS_ENV=production, I get the following error:
Could not find rake-10.0.4 in any of the sources
Run `bundle install` to install missing gems.
So, I run bundle install and get the following error:
Gem::Exception: Cannot load gem at [/usr/local/lib/ruby/gems/1.9.1/cache/rake-10.0.4.gem] in /home/root/myapp
An error occurred while installing rake (10.0.4), and Bundler cannot continue.
Make sure that `gem install rake -v '10.0.4'` succeeds before bundling.
From here, I ran gem install rake -v '10.0.4' --no-rdoc --no-ri, and it succeeded:
Yet still, bundle install fails with the same error. What can I do to fix this?
Thanks for all the help guys!
I ended up redeploying after running bundle package, and then ran bundle install --deployment on the server, and now it works.
It looks like I/bundle needed to be more explicit about where to look for the gem files :)
Bundler will try to run Rake that is in your gemfile. You need to run bundle exec rake db:migrate RAILS_ENV=production
Obviously your installation is faulty. I suggest you re-do it from scratch, and if you'd like you better use rbenv
Please check this answer Install Ruby on Rails on Ubuntu 12.04 LTS
my suggestion will you please try. if you are not root user and running this rake commmad may be it will give error. why not you try to login as root user and then place and navigate to your code. home/root/myapp to var/yourfolder/yourapp then. check which version or ruby you are using ruby -v it should be 1.9 or above and the same for rails which version of rails you are using.

ROR can't fine rake 10.0.4 despite being in vendor/cache

So this is annoying. When I put
bundle exec rake db:migrate
into terminal, the following error occurs:
Could not find rake-10.0.4 in any of the sources
Run `bundle install` to install missing gems.
So I check with bundle show rakeand it's there in:
/rails_projects/principia_app/vendor/cache/ruby/1.8/gems/rake-10.0.4.
I've tried deleting the gemfile.lock and running bundle install --path vendor/cache and the same error occurs.
Also, I've tried doing it using gem 'rake','10.0.4' in the gemfile and without yielding the same results. I've updated all my gems too.
I haven't had any issues until now, and for some reason is happing today. Any ideas? Thanks!!

Can't install ffi gem, Rails fail

While creating creating an integration test via rails generate integration_test foo it declined with
Could not find ffi-1.0.9 in any of the sources
Run `bundle install` to install missing gems.
I ran bundle install to install missing gems, but with no success. Still the same error. I have gem 'ffi' in my Gemfile.
I switched the gemfile line to gem 'ffi', :git => 'git://github.com/ffi/ffi.git' and bundle installed again. It did all sort of stuff and wrote "Your bundle is complete" at the end.
However when I run the rails generate... command again I get:
git://github.com/ffi/ffi.git (at master) is not checked out. Please run 'bundle install'
What the hell is going on with this ffi?
I ran into the same problem and solved it by removing the Gemfile.lock and re-run bundle install.
Perhaps try 'bundle exec rails generate...'
bundle install was failing because it could ffi failed with NoMethodError for spec.
Removing Gemfile.lock, empty the gemset and doing bundle install worked.

is not checked out... bundle install does NOT fix help!

https://github.com/intridea/omniauth.git (at master) is not checked out. Please run `bundle install` (Bundler::GitError)
So what do I do? bundle install works on development, but when I push and deploy to my production server. I get this error, even after running bundle install on my production server.
You're probably running Passenger. This is the issue with some solutions - http://code.google.com/p/phusion-passenger/issues/detail?id=505
Try running bundle install --deployment
This error can be related to the spring gem. Regenerating spring binstubs worked for me.
bundle exec spring binstub --all
https://github.com/rails/spring/issues/387
for the guys that stuck with "bundle & git repo " problems.
1. $ bundle pack
2. $ bundle install --path vendor/cache
more details, please refer to https://stackoverflow.com/a/5268534/445908
For me it was just a matter of adding this to gemfile:
source 'http://gems.github.com'
When your computer never restarts, Spring might be the problem. Spring was running for 350 hours and caused caching the outdated TEST environment. I had this problem in my cucumber test environment in Rubymine. Strange this was that from (mac) the command prompt there was no problem.
spring status
spring stop
and voila! It all worked again.
Ran into this problem after upgrading to ruby 2.7.0
Looks like maybe there has been changes to deprecate the use of the business company focused:github => to the actual software platform focused :git =>. Maybe better for easier code logic maintainability.
Change the following:
gem 'devise', :github => 'plataformatec/devise'
to the following:
gem 'devise', :git => 'git://github.com/plataformatec/devise'
An alternative is you may still reference :github as your git_source at the top of your Gemfile and just reference to the Gems as normal like so:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
...
gem 'devise'
If you run bundle install and then on attempt to run anything you see "... github.com ... is not yet checked out. Run bundle install first."
- that means you need to use bundle exec before your command, e.g.:
bundle exec rails s
Installing gem locally in project directory fix it for me.
$ bundle install --path vendor/bundle
This solution
$ bundle install --path vendor/bundle
has fixed my issue with running multiple rails app via foreman.
Note: Don't forget to execute rbenv rehash after if you are using rbenv.
And add /vendor/bundle in your .gitignore if not yet added.
My problem was that i had no access to github
try ssh -vT git#github.com and see if you get
git#github.com: Permission denied (publickey).
Then see https://help.github.com/articles/error-permission-denied-publickey/
For anyone here in 2021, the accepted answer is outdated as --deployment flag is deprecated.
Use this instead:
bundle config set --local deployment 'true'
It is a permission error. The following worked
Environment : RVM with Apache
RVM user:group : rvm:rvm
Apache user:group : apache:apache
You need to add apache user to RVM group
usermod -a -G rvm apache
What finally helped me once and forever:
Reinstalling everything as Galen suggested (all the steps from https://github.com/carlhuda/bundler/blob/master/ISSUES.md)
Using bundle instead of rvmsudo bundle
Update your Gemfile as follows;
gem 'activeadmin', github: 'activeadmin/active_admin', branch: '0-6-stable'
and then,
bundle install
Iif still error occurs (because of you have tried 'bundle install --deployment', then try running)
bundle install --no-deployment
Restarting bash session helped for me
Another solution, that helped me when I was getting same issue while installing private gem from my Github repo, in Docker (my gems are in volume /gems):
# Add known host
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts
RUN bundle config set path /gems # this fixes issue with private repos DON'T USE ENV BUNDLE_PATH /gems
RUN --mount=type=ssh bundle install
To forward SSH, build using this command:
docker build --ssh default .
Recently I got the error message on Circle CI:
#!/bin/bash -eo pipefail
bundle exec rails db:setup
https://github.com/randym/axlsx.git (at c8ac844#c8ac844) is not yet checked out. Run `bundle install` first.
Exited with code exit status 1
CircleCI received exit code 1
This error happened when gem dependencies can not be resolved.
So I switched back to pre release version in my Gemfile to fix it
-gem 'axlsx', github: 'randym/axlsx', ref: 'c8ac844572b25fda358cc01d2104720c4c42f450'
+gem 'axlsx', '3.0.0.pre'
and run update to update the gem dependencies
bundle update axlsx

Resources