Global Gemfile in the user's home directory using rbenv: good idea?


I am using rbenv to manage my gems, locally in my projects but also globally, on a Linux box.

When I bump my global ruby version (set in ~/.rbenv/version), I always forget to install some of my utility gems, that I need for development mainly.
Examples are rubocop for linting, minitest for some scripts I have scattered in my files, etc.
Using my package manager is not a really flexible solution (not so up-to-date, many gems are not packaged etc).

How should I proceed to keep a list of these gems I want to always have globally accessible, whatever the project I am currently working on? Should I have a Gemfile and a Gemfile.lock in my home directory? How could I hide them then (.Gemfile/.Gemfile.lock)?

So that once I change the global ruby version, then a

$ gem install bundler
$ bundle

and I have everything up and running? In this case would I have to prepend every command with bundle exec?

Is there a better way to manage this problem that I am not aware of?

Show source
| ruby   | rubygems   | rbenv   | bundler   2017-01-03 21:01 1 Answers

Answers ( 1 )

  1. 2017-01-03 21:01

    I would suggest to use rbenv-default-gems.

    Just install it into rbenv's plugins folder:

    git clone $(rbenv root)/plugins/rbenv-default-gems

    Place a file named default-gems into your rbenv's root folder:

    touch $(rbenv root)/default-gems

    Specify gems in $(rbenv root)/default-gems by name, one per line. You may optionally specify a version string after the name, or --pre to install a prerelease version. For example:

    bcat ~>0.6
    rails --pre
◀ Go back