I have numerous gems that I use across all Rails projects, but that aren't part of the projects' Gems, for example powder for managing POW.
It would make sense to me to manage these with a global Gemfile, but I can't see any examples of this.
How should I manage global Gems that I don't want in my project gemfiles? It would be good to have a single point of install for when I set up a new machine etc.
I'm using chruby alongside ruby-install to manage my Ruby versions.
The Gemfile is wherever you want it to be - usually in the main directory of your project and the name of the file is Gemfile . It's convenient to have one because it allows you to use Bundler to manage which gems and which versions of each your project needs to run.
The Gemfile is where you specify which gems you want to use, and lets you specify which versions. The Gemfile. lock file is where Bundler records the exact versions that were installed. This way, when the same library/project is loaded on another machine, running bundle install will look at the Gemfile.
Gemfile. lock is automatically generated when you run bundle install or bundle update . It should never be edited manually.
A gemfile is automatically created when you start a new rails application. type rails new appName and then it will be generated automatically. It will also be populated with some gems.
Make a Gemfile as usual, and place it in any folder. It does not need to be a project folder. Then you can just do:
bundle install --system
This will install the gems in the Gemfile system-wide, and will ask for the root password if you do not have access to the system folder.
--system: Installs the gems in the bundle to the system location. This overrides any previous remembered use of --path.
You can also name your Gemfile(s), if you want to organize them in some way:
bundle install --system --gemfile=/path/to/my_special_gemfile
As an addition to @Casper's answer:
I created a directory for my system Gem files.
I then added a dir for each version of ruby I wanted to install system gems for. I added a Gemfile to each dir and a .ruby-version file with the correct version. I can now install system gems for a ruby version using:
$ cd path/to/system_gems_dir/1.9.3-p484
$ bundle install --system
or
$ cd cd path/to/system_gems_dir/2.0.0-p353
$ bundle install --system
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With