Table of Contents [expand]
Last updated November 05, 2025
When trying to deploy, you may get a “missing gems” error like this:
remote: -----> Compiling Ruby/Rails
remote: Installing rake 13.2.1
remote: ...
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote:
remote: Could not find rake-13.2.1 in any of the sources
remote: Run bundle install to install missing gems.
In the output, you can see that the correct version of rake was installed, so why couldn’t it be found to run the rake command? This could be due to an incorrect or invalid binstub that is causing your rake command to use the wrong version of Ruby. This can happen due to bad binstubs.
Bad binstubs
In Rails, 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
brakeman docker-entrypoint rails thrust
bundler-audit importmap rake
ci jobs rubocop
dev kamal setup
Ensure that bundle, rails, and rake are all present. This is an example of what a bin/rails file looks like in Rails 8.1:
$ cat bin/rails
#!/usr/bin/env ruby
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
The above binstub works due to the first line #!/usr/bin/env ruby. Here is what each part does:
#!This is called the “shebang” line it tells the OS that it can execute it with the following expression./usr/bin/envThis is an absolute path to theenvprogram. This is allows the contents that come after this to use a OS based PATH lookup.rubyThis tells the OS to execute the file withrubywhererubyis looked up on thePATHbecause it comes after/usr/bin/env.
With that line at the top of the binstub, calling ./bin/rails is the rough equivalent of calling ruby ./bin/rails and using the ruby version to execute the contents.
Bad PATH
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>:
$ which rake
/app/bin/rake
Calling which -a will return all found executables on the PATH, listed in order from top to bottom:
$ which -a rake
/app/bin/rake
/app/vendor/bundle/bin/rake
/app/vendor/bundle/ruby/3.2.0/bin/rake
bin/rake
/app/bin/rake
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 system:
$ heroku config
# ...
If you see PATH or GEM_PATH please remove them with heroku config:unset PATH GEM_PATH.