Working with chruby and nvm on Ubuntu

| ruby | ubuntu | programming |

I am setting up a new Ubuntu 16.04 dev environment. I wanted to take some notes on my progress. I am trying out chruby after it being highly recommended by the ruby gurus Eric and Zach. A natural place to start would be to get this Jekyll blog running locally. I ran into a few stumbling blocks.

Installing chruby and a Ruby version

There are many different ways to do this, I chose the method below.
  1. Download and Install chruby
    wget -O chruby-0.3.9.tar.gz
    tar xf chruby-0.3.9.tar.gz
    cd chruby-0.3.9/
    sudo make install
  2. Add chruby to your .bashrc
    source /usr/local/share/chruby/
    source /usr/local/share/chruby/
  3. Install dependencies
    sudo apt-get install -y build-essential bison zlib1g-dev \
    libyaml-dev libssl-dev libgdbm-dev libreadline-dev \
    libncurses5-dev libffi-dev
  4. Install Ruby 2.3.1 This will work for any version of Ruby, but 2.3.1 is the one that I needed.
    tar xf ruby-2.3.1.tar.bz2
    cd ruby-2.3.1/
    ./configure --prefix=/opt/rubies/ruby-2.3.1
    sudo make install
  5. Install Gems for Jekyll Now that we have Ruby installed, we can install bundler and install all of our Gems.
    chruby 2.3.1
    gem install bundle
    bundle install
Once everything had been installed I tried to start up jekyll, and of course it did not work since I do not yet have node installed.
`rescue in block (2 levels) in require': There was an error while trying to load
the gem 'jekyll-coffeescript'. (Bundler::GemRequireError)
Gem Load Error is: Could not find a JavaScript runtime. See for a list of available runtimes.
Since I often work with many different versions of node, I took the opportunity to install nvm rather than the version of node that is available in the Ubuntu repositories.

Installing nvm

nvm is a really nice tool for working with various versions of node.
  1. Run the installer script
    curl -o- | bash
    This will install nvm and add the appropriate lines to your ~/.bashrc file in order to load properly.
  2. Install the latest version of node
    nvm install node
  3. Source NVM To get nvm working in the same terminal, you can run source ~/.bashrc, alternatively you can open a new terminal and nvm will automatically be sourced since the installer script added the appropriate bits for us.
You can now load jekyll with jekyll -s. Not only do we have Jekyll running like a charm, we also are ready to work with any version of Ruby or Node with chruby and nvm.

Thank you for reading! Share your thoughts with me on mastodon or via email.

Check out some more stuff to read down below.

Most popular posts this month

Recent Favorite Blog Posts

This is a collection of the last 8 posts that I bookmarked.

Articles from blogs I follow around the net

Today in heavy-handed metaphors

Sam Altman is the owner of a massive, invasive, parasitical toxic sludge that respects no boundaries and ruins everything it touches, and that he thinks someone else should clean up. Also his new house has mold. OpenAI CEO's $27 million San Francisco ma…

via jwz July 19, 2024

Weeknotes: GPT-4o mini, LLM 0.15, sqlite-utils 3.37 and building a staging environment

Upgrades to LLM to support the latest models, and a whole bunch of invisible work building out a staging environment for Datasette Cloud. GPT-4o mini and LLM 0.15 Today's big news was the release of GPT-4o mini, which I wrote about here. If you build ap…

via Simon Willison's Weblog: Entries July 19, 2024

ESM3: A simplified primer to the model's architecture

A short primer explaining the architecture of the ESM3 model

via Emmanuel Blogs July 18, 2024

Generated by openring