This is useful if you're working on a project with other developers and want to use different gems locally that you don't have to commit to the repository.
From this repository https://github.com/gerrywastaken/Gemfile.local. The rest the instructions here are mostly based on what is written there with some modifications.
First copy your Gemfile.lock
to Gemfile.local.lock
. Add your new gems to Gemfile.local
and run:
BUNDLE_GEMFILE="Gemfile.local" bundle install
You can run it with the BUNDLE_GEMFILE
variable set, for example:
BUNDLE_GEMFILE="Gemfile.local" bundle exec rails s
If you don't want to prefix all commands with this variable you can put this in your ~/.bashrc
# When entering a directory with Gemfile.local set it as default Gemfile
function cd
{
builtin cd "$@"
if [ -f "Gemfile.local" ]
then
export BUNDLE_GEMFILE="Gemfile.local"
else
export BUNDLE_GEMFILE=""
fi
}
Put Gemfile.local
and Gemfile.local.lock
in .gitignore