Wrong version of Ruby or Rake in App
Last updated 07 March 2017
When trying to run a command on your app such as
$ heroku run bash ~$ rails c
You may get an error such as:
Could not find rake-12.0.0 in any of the sources Run bundle install to install missing gems.
This does not mean that your specifed version of the gem is not installed on the dyno—it usually points to a path or configuration problem.
In recent versions of Rails the commands are in the form of “binstubs” these are files in the
bin directory of your app. So when you run
bin/rails c you should be able to start a console. There may be a problem with the code in your binstubs, you can update it by running this command locally:
$ bundle exec rake rails:update:bin
Then commit the results. Depending on your version of rails and the installed gems you should get a directory that looks something like this:
$ ls bin bundle puma pumactl rails rake setup spring update
Make sure that
rake are all present. This is an example of what a
bin/rails file looks like in Rails 5.0.1
$ cat bin/rails #!/usr/bin/env ruby APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands'
In UNIX like systems the
PATH is how your operating system finds the correct file to execute. When you type a command like
rake it searches each location on the
PATH to see if it has an executable file by that name and then executes it. You can see where the file lives by executing
which <command> such as
We highly recommend you do not modify your
PATH environment variable, this should be maintained for you by our buildpack and build system
Check that you do not have a path config var set, it is not needed and can be actively harmful to the sytem:
$ heroku config # ...
If you see
GEM_PATH please remove them with
heroku config:unset PATH GEM_PATH.