When I run this command (step 5 of Redmine installation):
bundle exec rake generate_secret_token
I get this error message:
bundler: command not found: rake
Install missing gem executables with `bundle install`
But rake is already installed.
Can somebody help me?
Thanks a lot.
Notes:
1) 'bundle install --local' works fine
2) 'rake' didn't exist originally (what quite surprised me as I took the original redmine Gemfile), so I added the line. Same effect, sadly.
3) 'rake' alone works fine. It's when I write the whole command that I get this message
You should run bundle install. It will download and install all gems required for running application.
Related
I'm trying to make a new project with Ruby on Rails and I'm installing all the required gems. Everything looks right but when I run foreman start I get a list of errors
I tried reinstalling the gems and updating them but I always get this.
Thanks for the help!
Probably, webpack cannot be found.
Try to run:
npm install or yarn install
bundle install
bundle exec rake webpacker:install
I am running bundle install --local and getting the following error:
Your bundle is locked to rake (11.2.2), 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 (11.2.2) has removed it. You'll need to update your
bundle to a different version of rake (11.2.2) that hasn't been removed in order to install.
Unable to decipher as to what needs to be done.
Any help would be highly appreciated.
Try running these commands
gem install rubygems-bundler
gem regenerate_binstubs
I encountered this problem also while using Jenkins, so here is what helped me:
First go through console to your job directory:
cd /var/lib/jenkins/workspace/<your-job-name>
If you are not sure where Jenkins stores your project, use pwd command inside your bash script.
In this directory, find your Gemfile.lock and delete it
rm Gemfile.lock
then try running bundle as you would usually do from console
bundle install
And see your bundle working. Hope it helps someone to solve the issue.
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'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
What does bundle exec rake db:migrate mean? Or just bundle exec rake <command> in general?
I understand that bundle takes care of maintaining things in the Gemfile. I know what the word "exec" means. I understand that rake maintains all the different scripty things you can do, and I know that db:migrate is one of those. I just don't know what all these words are doing together. Why should bundle be used to execute rake to execute a database migrate?
bundle exec is a Bundler command to execute a script in the context of the current bundle (the one from your directory's Gemfile). rake db:migrate is the script where db is the namespace and migrate is the task name defined.
So bundle exec rake db:migrate executes the rake script with the command db:migrate in the context of the current bundle.
As to the "why?" I'll quote from the bundler page:
In some cases, running executables without bundle exec may work, if the executable happens to be installed in your system and does not pull in any gems that conflict with your bundle.
However, this is unreliable and is the source of considerable pain. Even if it looks like it works, it may not work in the future or on another machine.
You're running bundle exec on a program. The program's creators wrote it when certain versions of gems were available. The program Gemfile specifies the versions of the gems the creators decided to use. That is, the script was made to run correctly against these gem versions.
Your system-wide Gemfile may differ from this Gemfile. You may have newer or older gems with which this script doesn't play nice. This difference in versions can give you weird errors.
bundle exec helps you avoid these errors. It executes the script using the gems specified in the script's Gemfile rather than the systemwide Gemfile. It executes the certain gem versions with the magic of shell aliases.
See more on the man page.
Here's an example Gemfile:
source 'http://rubygems.org'
gem 'rails', '2.8.3'
Here, bundle exec would execute the script using rails version 2.8.3 and not some other version you may have installed system-wide.
This comes up a lot when your gemfile.lock has different versions of the gems installed on your machine. You may get a warning after running rake (or rspec or others) such as:
You have already activated rake 10.3.1, but your Gemfile requires rake 10.1.0. Prepending "bundle exec" to your command may solve this.
Prepending bundle exec tells the bundler to execute this command regardless of the version differential. There isn't always an issue, however, you might run into problems.
Fortunately, there is a gem that solves this: rubygems-bundler.
$ gem install rubygems-bundler
$ $ gem regenerate_binstubs
Then try your rake, rspec, or whatever again.
It should probably be mentioned, that there are ways to omit bundle exec (they are all stated in chapter 3.6.1 of Michael Hartls Ruby on Rails Tutorial book).
The simplest is to just use a sufficiently up-to-date version of RVM (>= 1.11.x).
If you're restricted to an earlier version of RVM, you can always use this method also mentioned by calasyr:
$ rvm get head && rvm reload
$ chmod +x $rvm_path/hooks/after_cd_bundler
$ bundle install --binstubs=./bundler_stubs
The bundler_stubs directory should then also be added to the .gitignore file.
A third option is to use the rubygems-bundler gem if you're not using RVM:
$ gem install rubygems-bundler
$ gem regenerate_binstubs
When you directly run the rake task or execute any binary file of a gem, there is no guarantee that the command will behave as expected. Because it might happen that you already have the same gem installed on your system which have a version say 1.0 but in your project you have higher version say 2.0. In this case you can not predict which one will be used.
To enforce the desired gem version you take the help of bundle exec command which would execute the binary in context of current bundle. That means when you use bundle exec, bundler checks the gem version configured for the current project and use that to perform the task.
I have also written a post about it which also shows how we can avoid using it using bin stubs.
I have not used bundle exec much, but am setting it up now.
I have had instances where the wrong rake was used and much time wasted tracking down the problem. This helps you avoid that.
Here's how to set up RVM so you can use bundle exec by default within a specific project directory:
https://thoughtbot.com/blog/use-bundlers-binstubs
It means use rake that bundler is aware of and is part of your Gemfile over any rake that bundler is not aware of and run the db:migrate task.