CSC315-DBS-and-CSC415-SE-Ruby-Gemfile-Issue: Difference between revisions

From HPC Docs
Jump to navigation Jump to search
No edit summary
No edit summary
Line 11: Line 11:
To resolve the issue, downrev the sqlite3 gem back to a version expected by the Rails demo.
To resolve the issue, downrev the sqlite3 gem back to a version expected by the Rails demo.


Follow these steps after running the rail new demo command but before trying to start it up.
Follow these steps after running the <code>rail new demo</code> command but before trying to start it up.


<pre>
<pre>

Revision as of 15:28, 22 August 2019

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 rail new demo command but before trying to start it up.

cd demo
nano Gemfile
<pre>

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)

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

Save the file and exit nano.

Now process the gem dependencies again by running this command in the demo directory (where you should still be).
<code>bundler</code>

You should see this in the output (near the end).
<pre>
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.