CSC315-DBS-and-CSC415-SE-Ruby-Gemfile-Issue

From HPC Docs
Revision as of 15:31, 22 August 2019 by Admin (talk | contribs)
Jump to navigation Jump to search

Issue Description

If you update your Ruby installation by running the installruby.sh script provided in your VM, it may break your ability to create the Ruby Rails demo app. You will see the error below.

#<LoadError: Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? can't activate sqlite3 (~> 1.3.6), already activated sqlite3-1.4.0. Make sure all dependencies are added to Gemfile.>

Cause

The gem sqlite3 installed is newer than the expected version in the Rails demo app causing it to fail.

Solution

To resolve the issue, downrev the sqlite3 gem back to a version expected by the Rails demo.

Follow these steps after running the rails new demo command but before trying to start it up.

cd demo
nano Gemfile

Edit these lines (insert a # before to the first gem sqlite line and add a new line specifying the version you want ... the ~ below is the tilde character not the minus sign)

# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
gem 'sqlite3', '~> 1.3.6'

Save the file and exit nano.

Now process the gem dependencies again by running bundler in the demo directory (where you should still be).

You should see this in the output (near the end).

Using sqlite3 1.3.13 (was 1.4.0)

You should now be able to start your rails application again and connect to it with a browser.

rails server --binding=10.18.6.x

Where the x above represents the last digit or your VM's IP address.