Always install Bundler alongside Ruby with rbenv

Here’s a quick tip for anyone who uses rbenv and ruby-build to manage installing and switching Ruby versions.
When installing a new version of Ruby I cannot think of a situation in which I wouldn’t want Bundler installed too. The good news is that you …


This content originally appeared on Phil Nash and was authored by Phil Nash

Here's a quick tip for anyone who uses rbenv and ruby-build to manage installing and switching Ruby versions.

When installing a new version of Ruby I cannot think of a situation in which I wouldn't want Bundler installed too. The good news is that you can get rbenv to install Bundler, or any other gem you like, as soon as you install a new version of Ruby. All you need is the default-gems plugin.

Default gems

If you installed rbenv with Homebrew, like me, then you can install default-gems with Homebrew too.

$ brew install rbenv-default-gems

Then you need to make a list of gems that you want installed. First create a file named default-gems in your $(rbenv root) directory. Mine is located at ~/.rbenv/default-gems. Add the names of the gems you want to install, one per line. You can include an optional version or the option --pre for a prerelease version. For Bundler you will want the latest release, so the default-gems file would look like this:

bundler

Now when you install a new version of Ruby, Bundler will be installed as well.

<figure class="post-image post-image-outside"> <img src="/posts/install_ruby_bundler.png" alt="A terminal window shows the result of running rbenv install 2.4.0. Not only is Ruby 2.4.0 installed, but so is the latest version of Bundler." loading="lazy" /> </figure>

You can add other gems that you always use too. If you're a fan of pry, for example, then add a line for it in default-gems and you'll never have to remember to install it yourself.

rbenv plugins

There are a number of rbenv plugins which you can check out, but default-gems has always been a must have for me.

Are there any tools or plugins you use that make your Ruby development easier? I'd love to hear about them! Please share your tips with me on Twitter.


This content originally appeared on Phil Nash and was authored by Phil Nash


Print Share Comment Cite Upload Translate Updates
APA

Phil Nash | Sciencx (2017-03-22T00:00:00+00:00) Always install Bundler alongside Ruby with rbenv. Retrieved from https://www.scien.cx/2017/03/22/always-install-bundler-alongside-ruby-with-rbenv-2/

MLA
" » Always install Bundler alongside Ruby with rbenv." Phil Nash | Sciencx - Wednesday March 22, 2017, https://www.scien.cx/2017/03/22/always-install-bundler-alongside-ruby-with-rbenv-2/
HARVARD
Phil Nash | Sciencx Wednesday March 22, 2017 » Always install Bundler alongside Ruby with rbenv., viewed ,<https://www.scien.cx/2017/03/22/always-install-bundler-alongside-ruby-with-rbenv-2/>
VANCOUVER
Phil Nash | Sciencx - » Always install Bundler alongside Ruby with rbenv. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2017/03/22/always-install-bundler-alongside-ruby-with-rbenv-2/
CHICAGO
" » Always install Bundler alongside Ruby with rbenv." Phil Nash | Sciencx - Accessed . https://www.scien.cx/2017/03/22/always-install-bundler-alongside-ruby-with-rbenv-2/
IEEE
" » Always install Bundler alongside Ruby with rbenv." Phil Nash | Sciencx [Online]. Available: https://www.scien.cx/2017/03/22/always-install-bundler-alongside-ruby-with-rbenv-2/. [Accessed: ]
rf:citation
» Always install Bundler alongside Ruby with rbenv | Phil Nash | Sciencx | https://www.scien.cx/2017/03/22/always-install-bundler-alongside-ruby-with-rbenv-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.