Bridgetown on Ubuntu

Install Ruby via rbenv

The version of Ruby available via Ubuntu’s package manager is often out of date, so the best option is to install Ruby via rbenv. People often use rbenv anyway to manage multiple Ruby versions, which comes in handy when you need to run a specific Ruby version on a project.

First, update your package list:

sudo apt update

Next, install the dependencies required to install Ruby:

sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev

(If on an older Ubuntu version, libgdbm6 won’t be available. Try installing libgdbm5 instead.)

Once the dependencies download, you can install rbenv itself. Clone the rbenv repository from GitHub into the directory ~/.rbenv:

git clone https://github.com/rbenv/rbenv.git ~/.rbenv

Next, add ~/.rbenv/bin to your $PATH so that you can use the rbenv command line utility. Do this by altering your ~/.bashrc file so that it affects future login sessions:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc

Then add the command eval "$(rbenv init -)" to your ~/.bashrc file so rbenv loads automatically:

echo 'eval "$(rbenv init -)"' >> ~/.bashrc

Next, apply the changes you made to your ~/.bashrc file to your current shell session:

source ~/.bashrc

Verify that rbenv is set up properly by using the type command, which will display more information about the rbenv command:

type rbenv

Your terminal window will display the following:

rbenv is a function

Next, install the ruby-build plugin. This plugin adds the rbenv install command which simplifies the installation process for new versions of Ruby:

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

Now you can install a new Ruby version. At the time of this writing, Ruby 3.0.1 is the latest stable version. (Note: the installation may take a few minutes to complete.)

rbenv install 3.0.1
rbenv global 3.0.1

ruby -v
> ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [aarch64-linux]

(If for some reason bundler isn’t installed automatically, just run gem install bundler -N)

And that’s it! Check out rbenv command references to learn how to use different versions of Ruby in your projects.

Install Node and Yarn

Node is a JavaScript runtime that can execute on a server or development machine. Yarn is a package manager for Node packages. You’ll need Node and Yarn in order to install and use Webpack, the frontend asset compiler that runs alongside Bridgetown. Yarn is also used along with Concurrently and Browsersync to spin up a live-reload development server.

curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt remove cmdtest # this is so we can install Yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install -y nodejs yarn

Install Bridgetown

Now all that is left is to install Bridgetown!

gem install bridgetown -N

Create a new Bridgetown site at ./mysite, as well as run bundle install and yarn install automatically:

bridgetown new mysite

cd mysite

Now you should be able to build the site and run a live-reload server:

$ yarn start

Try opening the site up in http://localhost:4000. See something? Awesome, you’re ready to roll! If not, try revisiting your installation and setup steps, and if all else fails, reach out to the Bridgetown community for support.

Back to Installation