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

From HPC Docs
Jump to navigation Jump to search
(Created page with "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....")
 
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
Issue Description
=== 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.
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.
<pre>
<pre>
#<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.>
#<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.>
<pre>
</pre>


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


Solution
=== Solution ===
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>rails new demo</code> command but before trying to start it up.


<pre>
<pre>
cd demo
cd demo
nano Gemfile
nano Gemfile
<pre>
</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)
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)
Line 24: Line 24:
#gem 'sqlite3'
#gem 'sqlite3'
gem 'sqlite3', '~> 1.3.6'
gem 'sqlite3', '~> 1.3.6'
<pre>
</pre>


Save the file and exit nano.
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).
Now process the gem dependencies again by running <code>bundler</code> in the demo directory (where you should still be).
<code>bundler</code>


You should see this in the output (near the end).
You should see this in the output (near the end).
Line 37: Line 36:


You should now be able to start your rails application again and connect to it with a browser.
You should now be able to start your rails application again and connect to it with a browser.
<code>rails server --binding=10.18.6.''x''<code>
 
Where the ''x'' above represents the last digit or your VM's IP address.
<code>rails server --binding=10.18.6.''x''</code>
 
Where the ''x'' above represents the last digit of your VM's IP address.

Latest revision as of 15:31, 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 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 of your VM's IP address.