Skip to content

Instantly share code, notes, and snippets.

@yorkxin
Last active May 24, 2022 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yorkxin/a65a1e78e25fb0d8cf57fc3a0e2a085f to your computer and use it in GitHub Desktop.
Save yorkxin/a65a1e78e25fb0d8cf57fc3a0e2a085f to your computer and use it in GitHub Desktop.
Config rbenv to use Homebrew-installed Ruby

A workaround for developers who cannot build Ruby from source code on their machine.

brew install ruby@<version>
ln -s $(brew --prefix ruby@<version>) ~/.rbenv/versions/<version>

For exmaple

brew install ruby@3.1
ln -s $(brew --prefix ruby@3.1) ~/.rbenv/versions/3.1

Caveats:

  • Homebrew always install the latest patch version of a given Ruby version. If your .ruby-version locks at the patch version (e.g. 3.1.2), change it to minor version (3.1) or change the symlink to 3.1.2.
  • Homebrew does not distribute dead versions of Ruby, such as 2.3 at the time of this writing. If you must use it, try build from tarball, ruby-build, ruby-install or rvm. Alternatively, try using a Docker container for development with RubyMine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment