Install Ruby 3 and Bundler
1. Install Ruby
Install Ruby and dev headers.
$ sudo apt-get update $ sudo apt-get install ruby ruby-dev
$ ruby --version ruby 3.0.1p64 ...
For more info, also my gist instructions to set up Ruby, Bundler and a project-level Jekyll on macOS Catalina and higher.
$ brew install email@example.com $ # OR $ brew install firstname.lastname@example.org
Add to your PATH in Bash config (
.bashrc) or ZSH config (
.zshrc) to make the Brew install of Ruby accessible.
Start a new terminal tab.
$ ruby --version ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-darwin19]
As recommended on the Ruby homepage, download and run this installer:
- RubyInstaller homepage
2. Install Bundler
The instructions below are macOS/Linux.
Note that you might already have Bundler installed with your system Ruby.
$ /usr/bin/bundler --version Bundler version 1.17.2
But you might prefer to use a user-level Bundler. Especially since from macOS Catalina, the system Ruby and gems (like Bundler) are locked, to protect you from yourself.
$ /usr/local/opt/ruby/bin/bundler --version Bundler version 2.2.15
See two options below for installing.
Install Bundler at the user level, so it can be used across projects.
$ gem install bundler --user-install
Or upgrade it.
$ gem install bundler --user-install --update
With the user install flag, you will install for your user in one of these locations:
- Ruby 2
- Ruby 3
For Ruby 3, this part is unnecessary as Bundler gets installed for you.
To install system-wide, you can do this:
$ gem install bundler
If you lack permissions to install here, you'll get an error. Then you'll have to install with root access, which you should avoid in general unless you really know what you are doing. Anyway here it is:
$ sudo gem install bundler
Or set the permissions of the target directory owned by
root to be
755, so that all users can edit it. Then install into it, without
$ sudo chmod o+w /usr/local/ $ gem install bundler
--user-install flag will install to directory owned by
root but that is shared i.e. intended for all users on the machine to read.
3. Add gems directory to PATH
This step is not needed for Windows or if you don't install gems at the user level
If you used the
--user-install flag, then you installed to a user gem directory which is not in your PATH yet.
Therefore add this to your shell config. This will use Ruby itself to figure out what the appropriate path such as:
Use this to figure out that path for you and add it to your
if which ruby > /dev/null && which gem > /dev/null; then GEM_PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin" export PATH="$GEM_PATH:$PATH" fi
Then start a new terminal tab.
Check that Bundler is accessible.
$ which bundle $ bundle --version
Now you can work in a Ruby or Jekyll project and install gems in the project using Bundler.