Skip Navigation
Show nav
Heroku Dev Center Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
Heroku Dev Center Dev Center
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log in or Sign up
View categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
    • Buildpacks
  • Developer Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Working with Node.js
      • Troubleshooting Node.js Apps
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
        • Working with Rails
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • PHP Behavior in Heroku
      • Working with PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Working with AI
    • Heroku Inference
      • Inference Essentials
      • Inference API
      • AI Models
      • Heroku Inference Quick Start Guides
    • Tool Use
    • Vector Database
    • AI Integrations
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
    • Heroku AppLink
      • Getting Started with Heroku AppLink
      • Working with Heroku AppLink
      • Heroku AppLink Reference
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Other Salesforce Integrations
  • Troubleshooting & Support
  • Wrong Version of Ruby or Rake in App

Wrong Version of Ruby or Rake in App

English — 日本語に切り替える

Table of Contents [expand]

  • Bad binstubs
  • Bad PATH

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/env This is an absolute path to the env program. This is allows the contents that come after this to use a OS based PATH lookup.
  • ruby This tells the OS to execute the file with ruby where ruby is looked up on the PATH because 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.

Keep Reading

  • Heroku Error Codes
  • Request Timeout
  • Heroku Status
  • R14 - Memory Quota Exceeded in Ruby (MRI)
  • Error Pages

Or explore the Troubleshooting & Support category.

Feedback

Log in to submit feedback.

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices