Installing Ruby On Rails 3 on Ubuntu 12.4 Precise Pangolin with rbenv

by Steven J. Owens (unless otherwise attributed)

So, I'm working on my little android project, and it has a web-based part.

Initially I'd cobbled together something extremely rudimentary in PHP, but I was looking at dealing with a lot of boilerplate, so I started looking into PHP frameworks. Symfony looks cool, but it reminds me a lot of ruby on rails, and that's when the lightbulb lit up - this is a very conventional and pretty simple, little, web app, so why not do it in RoR as a learning project?

I already have a mysql schema I've roughed out, and the rest is just some simple forms and queries for viewing/editing the database. I'll keep the schema and sample data and do the rest from scratch.

Step one, I need ruby. Normally I'd start down the path of using apt to install ruby, etc, but I remember that during my last stab at this, various conflicts and version issues reared their ugly heads. It looks like the ruby community doesn't give much love to debian/ubuntu repos, and vice versa. That appears to still be true, sigh.

Last time I ended up manually installing the prerequisites for RVM, the ruby environment manager, and then using that to install ruby and rails:

http://www.darksleep.com/notablog/articles/Installing_Rails_On_Ubuntu

This time there's rbenv, which is supposed to be somewhat better, not to mention easier to install, so I'm going to give that a try.

Based on:

https://gist.github.com/2706272 http://deangerber.com/blog/2012/05/30/install-ruby-on-ubuntu-using-rbenv/

I'm doing all of the following inside my "overweb" project directory. Overweb is my hokey working title for the project. Shell prompts are in blue, everything I actually type is in bold.

Let's start by pre-installing the dependencies for ruby and rails.


Note: in the line below you should also include more packages to support whichever database you want to use: libmysqlclient-dev libyaml-dev for mysql and sqlite3 libsqlite3-dev. Note that these are in addition to installing the mysql server if you want to use mysql. I already had mysql installed, so I don't have to install it.

I'm leaving the error in here because a) I don't feel like ripping it all out and re-running this command with the extra two packages and b) so that people who run into this problem and hit google can find this page, but the full command should read:

puff@redbitter:~/overweb$ sudo aptitude install build-essential libreadline-dev libssl-dev zlib1g-dev libxml2-dev libxslt-dev git-core gitg tmux sqlite3 libsqlite3-dev libmysqlclient-dev libyaml-dev

TL;DR: If you're cut-and-pasting, don't use the aptitude install command immediately below, use the one immediately above. And then you can skip over all the mysql/sqlite3 error stuff below.


We now return you to your regularly scheduled error:

puff@redbitter:~/overweb$ sudo aptitude install build-essential libreadline-dev libssl-dev zlib1g-dev libxml2-dev libxslt-dev git-core gitg tmux
Note: selecting "libxslt1-dev" instead of the
      virtual package "libxslt-dev"
The following NEW packages will be installed:
  git-core gitg libreadline-dev libreadline6-dev{a} libtinfo-dev{a} 
  libxml2-dev libxslt1-dev tmux 
0 packages upgraded, 8 newly installed, 0 to remove and 143 not upgraded.
Need to get 515 kB/2,252 kB of archives. After unpacking 8,259 kB will be used.
Do you want to continue? [Y/n/?] y
Get: 1 http://us.archive.ubuntu.com/ubuntu/ precise/main tmux amd64 1.6-1ubuntu1 [224 kB]
Get: 2 http://us.archive.ubuntu.com/ubuntu/ precise/main git-core all 1:1.7.9.5-1 [1,384 B]
Get: 3 http://us.archive.ubuntu.com/ubuntu/ precise/universe gitg amd64 0.2.4-0ubuntu1 [290 kB]
Fetched 515 kB in 0s (719 kB/s)
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
Selecting previously unselected package tmux.
(Reading database ... 716728 files and directories currently installed.)
Unpacking tmux (from .../tmux_1.6-1ubuntu1_amd64.deb) ...
Selecting previously unselected package git-core.
Unpacking git-core (from .../git-core_1%3a1.7.9.5-1_all.deb) ...
Selecting previously unselected package gitg.
Unpacking gitg (from .../gitg_0.2.4-0ubuntu1_amd64.deb) ...
Selecting previously unselected package libtinfo-dev.
Unpacking libtinfo-dev (from .../libtinfo-dev_5.9-4_amd64.deb) ...
Selecting previously unselected package libreadline6-dev.
Unpacking libreadline6-dev (from .../libreadline6-dev_6.2-8_amd64.deb) ...
Selecting previously unselected package libreadline-dev.
Unpacking libreadline-dev (from .../libreadline-dev_6.2-8_amd64.deb) ...
Selecting previously unselected package libxml2-dev.
Unpacking libxml2-dev (from .../libxml2-dev_2.7.8.dfsg-5.1ubuntu4.3_amd64.deb) ...
Selecting previously unselected package libxslt1-dev.
Unpacking libxslt1-dev (from .../libxslt1-dev_1.1.26-8ubuntu1.2_amd64.deb) ...
Processing triggers for man-db ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
Processing triggers for hicolor-icon-theme ...
Processing triggers for gnome-menus ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf.index...
Processing triggers for desktop-file-utils ...
Processing triggers for libglib2.0-0 ...
Processing triggers for install-info ...
Processing triggers for doc-base ...
Processing 1 added doc-base file...
Registering documents with scrollkeeper...
Setting up tmux (1.6-1ubuntu1) ...
Setting up git-core (1:1.7.9.5-1) ...
Setting up gitg (0.2.4-0ubuntu1) ...
Setting up libtinfo-dev (5.9-4) ...
Setting up libreadline6-dev (6.2-8) ...
Setting up libreadline-dev (6.2-8) ...
Setting up libxml2-dev (2.7.8.dfsg-5.1ubuntu4.3) ...
Setting up libxslt1-dev (1.1.26-8ubuntu1.2) ...
                                    
puff@redbitter:~/overweb$ ssh-keygen -t rsa -C "youremail@yourdomain.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/puff/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): Your passphrase here
 
Enter same passphrase again: Your passphrase here
 
Your identification has been saved in /home/puff/.ssh/id_rsa.
Your public key has been saved in /home/puff/.ssh/id_rsa.pub.
The key fingerprint is:
a6:fe:ca:d5:70:22:02:54:94:d7:81:89:23:61:55:79	myemail@mydomain.com
The key's randomart image is:
+--[ RSA 2048]----+
|  +=++.=..       |
| o. + = E        |
|  .. o .         |
|   .             |
|    . . S .      |
|     . + =       |
|      . . .      |
|     o .         |
|      +o.        |
+-----------------+
puff@redbitter:~/overweb$ git config --global user.name "Steven J. Owens"
puff@redbitter:~/overweb$ git config --global user.email myemail@mydomain.com
puff@redbitter:~/overweb$ git config --global core.editor emacs
puff@redbitter:~/overweb$ git config --global color.ui true
git config --global color.status.changed yellow
git config --global color.status.added green
git config --global color.status.untracked red
puff@redbitter:~/overweb$ 
puff@redbitter:~/overweb$ git config --list
user.name=Steven J. Owens
user.email=myemail@mydomain.com
core.editor=emacs
color.ui=true
color.status.changed=yellow
color.status.added=green
color.status.untracked=red
puff@redbitter:~/overweb$ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
Cloning into '/home/puff/.rbenv'...
remote: Counting objects: 1456, done.        
remote: Compressing objects: 100% (616/616), done.        
remote: Total 1456 (delta 938), reused 1306 (delta 811)        
Receiving objects: 100% (1456/1456), 209.16 KiB, done.
Resolving deltas: 100% (938/938), done.
puff@redbitter:~/overweb$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
puff@redbitter:~/overweb$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
puff@redbitter:~/overweb$ exec $SHELL
puff@redbitter:~/overweb$ mkdir -p ~/.rbenv/plugins
puff@redbitter:~/overweb$ cd ~/.rbenv/plugins
puff@redbitter:~/.rbenv/plugins$ git clone git://github.com/sstephenson/ruby-build.git
Cloning into 'ruby-build'...
remote: Counting objects: 1453, done.        
remote: Compressing objects: 100% (636/636), done.        
remote: Total 1453 (delta 758), reused 1351 (delta 665)        
Receiving objects: 100% (1453/1453), 161.29 KiB, done.
Resolving deltas: 100% (758/758), done.
puff@redbitter:~/.rbenv/plugins$ rbenv install 1.9.3-p194
Downloading yaml-0.1.4.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/36c852831d02cf90508c29852361d01b
Installing yaml-0.1.4...
Installed yaml-0.1.4 to /home/puff/.rbenv/versions/1.9.3-p194
 
Downloading ruby-1.9.3-p194.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/bc0c715c69da4d1d8bd57069c19f6c0e
Installing ruby-1.9.3-p194...
Installed ruby-1.9.3-p194 to /home/puff/.rbenv/versions/1.9.3-p194
 
puff@redbitter:~/.rbenv/plugins$ cd ~/overweb
puff@redbitter:~/overweb$ rbenv versions
  1.9.3-p194
puff@redbitter:~/overweb$ rbenv global 1.9.3-p194
puff@redbitter:~/overweb$ irb
irb(main):001:0> quit
puff@redbitter:~/overweb$ 

Okay, so now I have rbenv and ruby, now I need to install rails.

https://gist.github.com/2980504
puff@redbitter:~/overweb$ gem i bundler rails
Fetching: bundler-1.2.3.gem (100%)
Successfully installed bundler-1.2.3
Fetching: i18n-0.6.1.gem (100%)
Fetching: multi_json-1.5.0.gem (100%)
Fetching: activesupport-3.2.11.gem (100%)
Fetching: builder-3.0.4.gem (100%)
Fetching: activemodel-3.2.11.gem (100%)
Fetching: rack-1.4.4.gem (100%)
Fetching: rack-cache-1.2.gem (100%)
Fetching: rack-test-0.6.2.gem (100%)
Fetching: journey-1.0.4.gem (100%)
Fetching: hike-1.2.1.gem (100%)
Fetching: tilt-1.3.3.gem (100%)
Fetching: sprockets-2.2.2.gem (100%)
Fetching: erubis-2.7.0.gem (100%)
Fetching: actionpack-3.2.11.gem (100%)
Fetching: arel-3.0.2.gem (100%)
Fetching: tzinfo-0.3.35.gem (100%)
Fetching: activerecord-3.2.11.gem (100%)
Fetching: activeresource-3.2.11.gem (100%)
Fetching: mime-types-1.19.gem (100%)
Fetching: polyglot-0.3.3.gem (100%)
Fetching: treetop-1.4.12.gem (100%)
Fetching: mail-2.4.4.gem (100%)
Fetching: actionmailer-3.2.11.gem (100%)
Fetching: rack-ssl-1.3.3.gem (100%)
Fetching: thor-0.17.0.gem (100%)
Fetching: railties-3.2.11.gem (100%)
Fetching: rails-3.2.11.gem (100%)
Successfully installed i18n-0.6.1
Successfully installed multi_json-1.5.0
Successfully installed activesupport-3.2.11
Successfully installed builder-3.0.4
Successfully installed activemodel-3.2.11
Successfully installed rack-1.4.4
Successfully installed rack-cache-1.2
Successfully installed rack-test-0.6.2
Successfully installed journey-1.0.4
Successfully installed hike-1.2.1
Successfully installed tilt-1.3.3
Successfully installed sprockets-2.2.2
Successfully installed erubis-2.7.0
Successfully installed actionpack-3.2.11
Successfully installed arel-3.0.2
Successfully installed tzinfo-0.3.35
Successfully installed activerecord-3.2.11
Successfully installed activeresource-3.2.11
Successfully installed mime-types-1.19
Successfully installed polyglot-0.3.3
Successfully installed treetop-1.4.12
Successfully installed mail-2.4.4
Successfully installed actionmailer-3.2.11
Successfully installed rack-ssl-1.3.3
Successfully installed thor-0.17.0
Successfully installed railties-3.2.11
Successfully installed rails-3.2.11
28 gems installed
Installing ri documentation for bundler-1.2.3...
Installing ri documentation for i18n-0.6.1...
Installing ri documentation for multi_json-1.5.0...
Installing ri documentation for activesupport-3.2.11...
Installing ri documentation for builder-3.0.4...
Installing ri documentation for activemodel-3.2.11...
Installing ri documentation for rack-1.4.4...
Installing ri documentation for rack-cache-1.2...
Installing ri documentation for rack-test-0.6.2...
Installing ri documentation for journey-1.0.4...
Installing ri documentation for hike-1.2.1...
Installing ri documentation for tilt-1.3.3...
Installing ri documentation for sprockets-2.2.2...
Installing ri documentation for erubis-2.7.0...
Installing ri documentation for actionpack-3.2.11...
Installing ri documentation for arel-3.0.2...
Installing ri documentation for tzinfo-0.3.35...
Installing ri documentation for activerecord-3.2.11...
Installing ri documentation for activeresource-3.2.11...
Installing ri documentation for mime-types-1.19...
Installing ri documentation for polyglot-0.3.3...
Installing ri documentation for treetop-1.4.12...
Installing ri documentation for mail-2.4.4...
Installing ri documentation for actionmailer-3.2.11...
Installing ri documentation for rack-ssl-1.3.3...
Installing ri documentation for thor-0.17.0...
Installing ri documentation for railties-3.2.11...
Installing ri documentation for rails-3.2.11...
file 'lib' not found
Installing RDoc documentation for bundler-1.2.3...
Installing RDoc documentation for i18n-0.6.1...
Installing RDoc documentation for multi_json-1.5.0...
Installing RDoc documentation for activesupport-3.2.11...
Installing RDoc documentation for builder-3.0.4...
Installing RDoc documentation for activemodel-3.2.11...
Installing RDoc documentation for rack-1.4.4...
Installing RDoc documentation for rack-cache-1.2...
Installing RDoc documentation for rack-test-0.6.2...
Installing RDoc documentation for journey-1.0.4...
Installing RDoc documentation for hike-1.2.1...
Installing RDoc documentation for tilt-1.3.3...
Installing RDoc documentation for sprockets-2.2.2...
Installing RDoc documentation for erubis-2.7.0...
Installing RDoc documentation for actionpack-3.2.11...
Installing RDoc documentation for arel-3.0.2...
Installing RDoc documentation for tzinfo-0.3.35...
Installing RDoc documentation for activerecord-3.2.11...
Installing RDoc documentation for activeresource-3.2.11...
Installing RDoc documentation for mime-types-1.19...
Installing RDoc documentation for polyglot-0.3.3...
Installing RDoc documentation for treetop-1.4.12...
Installing RDoc documentation for mail-2.4.4...
Installing RDoc documentation for actionmailer-3.2.11...
Installing RDoc documentation for rack-ssl-1.3.3...
Installing RDoc documentation for thor-0.17.0...
Installing RDoc documentation for railties-3.2.11...
Installing RDoc documentation for rails-3.2.11...
file 'lib' not found
puff@redbitter:~/overweb$ rbenv rehash

Okay, so now it's time to try out rails. I'm going to make a "version3" subdirectory (version1 and version2 were crude php scripts) and create it in there.

puff@redbitter:~/overweb$ mkdir version3
puff@redbitter:~/overweb$ cd version3/
puff@redbitter:~/overweb/version3$ rails new overshare
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.gitkeep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Installing rake (10.0.3) 
Using i18n (0.6.1) 
Using multi_json (1.5.0) 
Using activesupport (3.2.11) 
Using builder (3.0.4) 
Using activemodel (3.2.11) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.4) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.2.2) 
Using actionpack (3.2.11) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.12) 
Using mail (2.4.4) 
Using actionmailer (3.2.11) 
Using arel (3.0.2) 
Using tzinfo (0.3.35) 
Using activerecord (3.2.11) 
Using activeresource (3.2.11) 
Using bundler (1.2.3) 
Installing coffee-script-source (1.4.0) 
Installing execjs (1.4.0) 
Installing coffee-script (2.2.0) 
Using rack-ssl (1.3.3) 
Installing json (1.7.6) with native extensions 
Installing rdoc (3.12) 
Using thor (0.17.0) 
Using railties (3.2.11) 
Installing coffee-rails (3.2.2) 
Installing jquery-rails (2.2.0) 
Using rails (3.2.11) 
Installing sass (3.2.5) 
Installing sass-rails (3.2.6) 
Installing sqlite3 (1.3.7) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
 
        /home/puff/.rbenv/versions/1.9.3-p194/bin/ruby extconf.rb 
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
 
Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/home/puff/.rbenv/versions/1.9.3-p194/bin/ruby
	--with-sqlite3-dir
	--without-sqlite3-dir
	--with-sqlite3-include
	--without-sqlite3-include=${sqlite3-dir}/include
	--with-sqlite3-lib
	--without-sqlite3-lib=${sqlite3-dir}/lib
	--enable-local
	--disable-local
 
 
Gem files will remain installed in /home/puff/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7 for inspection.
Results logged to /home/puff/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7/ext/sqlite3/gem_make.out
An error occurred while installing sqlite3 (1.3.7), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.7'` succeeds before bundling.

Well, the problem here is that a) rails is defaulting to sqlite3 and b) sqlite3 isn't installed and c) I didn't tell rails I wanted overshare to use mysql.

I'm going to use mysql, but first let's install sqlite3 anyway, so we can play around with sqlite3 rails apps if we want to.

puff@redbitter:~/overweb$ sudo aptitude install sqlite3
The following NEW packages will be installed:
  sqlite3 
0 packages upgraded, 1 newly installed, 0 to remove and 143 not upgraded.
Need to get 26.8 kB of archives. After unpacking 174 kB will be used.
Get: 1 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main sqlite3 amd64 3.7.9-2ubuntu1.1 [26.8 kB]
Fetched 26.8 kB in 0s (130 kB/s)
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
Selecting previously unselected package sqlite3.
(Reading database ... 716179 files and directories currently installed.)
Unpacking sqlite3 (from .../sqlite3_3.7.9-2ubuntu1.1_amd64.deb) ...
Processing triggers for man-db ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
Setting up sqlite3 (3.7.9-2ubuntu1.1) ...
                                          
puff@redbitter:~/overweb$ 

Now let's make a test rails sqlite3 app, just to see if that fixed the problem. It has to be "test1" because "test" is a reserved rails word and rails won't let you use a reserved word for a project name:

puff@redbitter:~/overweb/tmp$ rails new test1
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.gitkeep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.0.3) 
Installing i18n (0.6.4) 
Using multi_json (1.6.1) 
Using activesupport (3.2.11) 
Using builder (3.0.4) 
Using activemodel (3.2.11) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.5) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Installing tilt (1.3.4) 
Using sprockets (2.2.2) 
Using actionpack (3.2.11) 
Using mime-types (1.21) 
Using polyglot (0.3.3) 
Using treetop (1.4.12) 
Using mail (2.4.4) 
Using actionmailer (3.2.11) 
Using arel (3.0.2) 
Installing tzinfo (0.3.36) 
Using activerecord (3.2.11) 
Using activeresource (3.2.11) 
Using bundler (1.2.3) 
Installing coffee-script-source (1.6.1) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.3) 
Using json (1.7.7) 
Installing rdoc (3.12.2) 
Using thor (0.17.0) 
Using railties (3.2.11) 
Using coffee-rails (3.2.2) 
Using jquery-rails (2.2.1) 
Using rails (3.2.11) 
Using sass (3.2.6) 
Using sass-rails (3.2.6) 
Installing sqlite3 (1.3.7) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/home/puff/.rbenv/versions/1.9.3-p194/bin/ruby extconf.rb checking for sqlite3.h... no sqlite3.h is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite-devel' and check your shared library search path (the location where your sqlite3 shared library is located). ** extconf.rb failed ** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/home/puff/.rbenv/versions/1.9.3-p194/bin/ruby --with-sqlite3-dir --without-sqlite3-dir --with-sqlite3-include --without-sqlite3-include=${sqlite3-dir}/include --with-sqlite3-lib --without-sqlite3-lib=${sqlite3-dir}/lib --enable-local --disable-local

Gem files will remain installed in /home/puff/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7 for inspection. Results logged to /home/puff/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7/ext/sqlite3/gem_make.out An error occurred while installing sqlite3 (1.3.7), and Bundler cannot continue. Make sure that `gem install sqlite3 -v '1.3.7'` succeeds before bundling. puff@redbitter:~/overweb/tmp$

Okay, some googling indicates we need libsqlite3-dev:

puff@redbitter:~/overweb/tmp$  sudo aptitude install libsqlite3-dev
The following NEW packages will be installed:
  libsqlite3-dev 
0 packages upgraded, 1 newly installed, 0 to remove and 12 not upgraded.
Need to get 459 kB of archives. After unpacking 1,340 kB will be used.
Get: 1 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libsqlite3-dev amd64 3.7.9-2ubuntu1.1 [459 kB]
Fetched 459 kB in 0s (659 kB/s)
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
Selecting previously unselected package libsqlite3-dev.
(Reading database ... 742439 files and directories currently installed.)
Unpacking libsqlite3-dev (from .../libsqlite3-dev_3.7.9-2ubuntu1.1_amd64.deb) ...puff@redbitter:~/overweb/tmp$  

Now let's delete the old test1 and try again:

puff@redbitter:~/overweb/tmp$  rm -rf test1
puff@redbitter:~/overweb/tmp$  rails new test1 
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.gitkeep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.0.3) 
Using i18n (0.6.4) 
Using multi_json (1.6.1) 
Using activesupport (3.2.11) 
Using builder (3.0.4) 
Using activemodel (3.2.11) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.5) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.4) 
Using sprockets (2.2.2) 
Using actionpack (3.2.11) 
Using mime-types (1.21) 
Using polyglot (0.3.3) 
Using treetop (1.4.12) 
Using mail (2.4.4) 
Using actionmailer (3.2.11) 
Using arel (3.0.2) 
Using tzinfo (0.3.36) 
Using activerecord (3.2.11) 
Using activeresource (3.2.11) 
Using bundler (1.2.3) 
Using coffee-script-source (1.6.1) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.3) 
Using json (1.7.7) 
Using rdoc (3.12.2) 
Using thor (0.17.0) 
Using railties (3.2.11) 
Using coffee-rails (3.2.2) 
Using jquery-rails (2.2.1) 
Using rails (3.2.11) 
Using sass (3.2.6) 
Using sass-rails (3.2.6) 
Installing sqlite3 (1.3.7) with native extensions 
Using uglifier (1.3.0) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
puff@redbitter:~/overweb/tmp$ 

Yay! It works!

Time to get back to the job at hand, let's create the new rails app as a mysql app:

puff@redbitter:~/overweb/tmp$ cd ..
puff@redbitter:~/overweb$ rails new overshare -d mysql
       exist  
   identical  README.rdoc
   identical  Rakefile
   identical  config.ru
   identical  .gitignore
    conflict  Gemfile
Overwrite /home/puff/overweb/overshare/Gemfile? (enter "h" for help) [Ynaqdh] y
       force  Gemfile
       exist  app
   identical  app/assets/images/rails.png
   identical  app/assets/javascripts/application.js
   identical  app/assets/stylesheets/application.css
   identical  app/controllers/application_controller.rb
   identical  app/helpers/application_helper.rb
   identical  app/views/layouts/application.html.erb
   identical  app/mailers/.gitkeep
   identical  app/models/.gitkeep
       exist  config
   identical  config/routes.rb
   identical  config/application.rb
   identical  config/environment.rb
       exist  config/environments
   identical  config/environments/development.rb
   identical  config/environments/production.rb
   identical  config/environments/test.rb
       exist  config/initializers
   identical  config/initializers/backtrace_silencers.rb
   identical  config/initializers/inflections.rb
   identical  config/initializers/mime_types.rb
    conflict  config/initializers/secret_token.rb
Overwrite /home/puff/overweb/overshare/config/initializers/secret_token.rb? (enter "h" for help) [Ynaqdh] y
       force  config/initializers/secret_token.rb
   identical  config/initializers/session_store.rb
   identical  config/initializers/wrap_parameters.rb
       exist  config/locales
   identical  config/locales/en.yml
   identical  config/boot.rb
    conflict  config/database.yml
Overwrite /home/puff/overweb/overshare/config/database.yml? (enter "h" for help) [Ynaqdh] Y
       force  config/database.yml
       exist  db
   identical  db/seeds.rb
       exist  doc
   identical  doc/README_FOR_APP
       exist  lib
       exist  lib/tasks
   identical  lib/tasks/.gitkeep
       exist  lib/assets
   identical  lib/assets/.gitkeep
       exist  log
   identical  log/.gitkeep
       exist  public
   identical  public/404.html
   identical  public/422.html
   identical  public/500.html
   identical  public/favicon.ico
   identical  public/index.html
   identical  public/robots.txt
       exist  script
   identical  script/rails
       exist  test/fixtures
   identical  test/fixtures/.gitkeep
       exist  test/functional
   identical  test/functional/.gitkeep
       exist  test/integration
   identical  test/integration/.gitkeep
       exist  test/unit
   identical  test/unit/.gitkeep
   identical  test/performance/browsing_test.rb
   identical  test/test_helper.rb
       exist  tmp/cache
       exist  tmp/cache/assets
       exist  vendor/assets/javascripts
   identical  vendor/assets/javascripts/.gitkeep
       exist  vendor/assets/stylesheets
   identical  vendor/assets/stylesheets/.gitkeep
       exist  vendor/plugins
   identical  vendor/plugins/.gitkeep
         run  bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.0.3) 
Using i18n (0.6.1) 
Using multi_json (1.5.0) 
Using activesupport (3.2.11) 
Using builder (3.0.4) 
Using activemodel (3.2.11) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.4) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.2.2) 
Using actionpack (3.2.11) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.12) 
Using mail (2.4.4) 
Using actionmailer (3.2.11) 
Using arel (3.0.2) 
Using tzinfo (0.3.35) 
Using activerecord (3.2.11) 
Using activeresource (3.2.11) 
Using bundler (1.2.3) 
Using coffee-script-source (1.4.0) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.3) 
Using json (1.7.6) 
Using rdoc (3.12) 
Using thor (0.17.0) 
Using railties (3.2.11) 
Using coffee-rails (3.2.2) 
Using jquery-rails (2.2.0) 
Installing mysql2 (0.3.11) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
 
        /home/puff/.rbenv/versions/1.9.3-p194/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
 
Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/home/puff/.rbenv/versions/1.9.3-p194/bin/ruby
	--with-mysql-config
	--without-mysql-config
	--with-mysql-dir
	--without-mysql-dir
	--with-mysql-include
	--without-mysql-include=${mysql-dir}/include
	--with-mysql-lib
	--without-mysql-lib=${mysql-dir}/lib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-mlib
	--without-mlib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-zlib
	--without-zlib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-socketlib
	--without-socketlib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-nsllib
	--without-nsllib
	--with-mysqlclientlib
	--without-mysqlclientlib
	--with-mygcclib
	--without-mygcclib
	--with-mysqlclientlib
	--without-mysqlclientlib
 
 
Gem files will remain installed in /home/puff/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11 for inspection.
Results logged to /home/puff/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.
puff@redbitter:~/overweb$ 

The mysql2 bit is misleading, that's the name of the mysql gem for rails, not mysql itself. We need the mysql client dev packages so we'll have headers, so ruby can build the mysql2 gem, which is the ruby adapter for mysql.

puff@redbitter:~/overweb$ sudo aptitude install libmysqlclient-dev libyaml-dev
The following NEW packages will be installed:
  libmysqlclient-dev libyaml-dev 
The following packages will be upgraded:
  libmysqlclient18 mysql-common 
2 packages upgraded, 2 newly installed, 0 to remove and 141 not upgraded.
Need to get 2,424 kB of archives. After unpacking 5,897 kB will be used.
Do you want to continue? [Y/n/?] y
Get: 1 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main mysql-common all 5.5.29-0ubuntu0.12.04.1 [13.5 kB]
Get: 2 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libmysqlclient18 amd64 5.5.29-0ubuntu0.12.04.1 [946 kB]
Get: 3 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libmysqlclient-dev amd64 5.5.29-0ubuntu0.12.04.1 [1,394 kB]
Get: 4 http://us.archive.ubuntu.com/ubuntu/ precise/main libyaml-dev amd64 0.1.4-2 [69.9 kB]
Fetched 2,424 kB in 1s (1,705 kB/s)
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
(Reading database ... 716184 files and directories currently installed.)
Preparing to replace mysql-common 5.5.28-0ubuntu0.12.04.3 (using .../mysql-common_5.5.29-0ubuntu0.12.04.1_all.deb) ...
Unpacking replacement mysql-common ...
Preparing to replace libmysqlclient18 5.5.28-0ubuntu0.12.04.3 (using .../libmysqlclient18_5.5.29-0ubuntu0.12.04.1_amd64.deb) ...
Unpacking replacement libmysqlclient18 ...
Selecting previously unselected package libmysqlclient-dev.
Unpacking libmysqlclient-dev (from .../libmysqlclient-dev_5.5.29-0ubuntu0.12.04.1_amd64.deb) ...
Selecting previously unselected package libyaml-dev.
Unpacking libyaml-dev (from .../libyaml-dev_0.1.4-2_amd64.deb) ...
Processing triggers for man-db ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
Setting up mysql-common (5.5.29-0ubuntu0.12.04.1) ...
Setting up libmysqlclient18 (5.5.29-0ubuntu0.12.04.1) ...
Setting up libmysqlclient-dev (5.5.29-0ubuntu0.12.04.1) ...
Setting up libyaml-dev (0.1.4-2) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

Current status: 141 updates [-2]. puff@redbitter:~/overweb$

Okay, so it should work this time. First let's clean up the leftovers from the last attempt:

puff@redbitter:~/overweb$ cd version3
puff@redbitter:~/overweb/version3$ rm -rf overshare
puff@redbitter:~/overweb/version3$ 

And now let's try yet again.

puff@redbitter:~/overweb/version3$ rails new overshare -d mysql
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.gitkeep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.0.3) 
Using i18n (0.6.1) 
Using multi_json (1.5.0) 
Using activesupport (3.2.11) 
Using builder (3.0.4) 
Using activemodel (3.2.11) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.4) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.2.2) 
Using actionpack (3.2.11) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.12) 
Using mail (2.4.4) 
Using actionmailer (3.2.11) 
Using arel (3.0.2) 
Using tzinfo (0.3.35) 
Using activerecord (3.2.11) 
Using activeresource (3.2.11) 
Using bundler (1.2.3) 
Using coffee-script-source (1.4.0) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.3) 
Using json (1.7.6) 
Using rdoc (3.12) 
Using thor (0.17.0) 
Using railties (3.2.11) 
Using coffee-rails (3.2.2) 
Using jquery-rails (2.2.0) 
Installing mysql2 (0.3.11) with native extensions 
Using rails (3.2.11) 
Using sass (3.2.5) 
Using sass-rails (3.2.6) 
Installing uglifier (1.3.0) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
puff@redbitter:~/overweb/version3$ 

Yay, it worked. That's enough for now, next time I'll start actually building a ruby app.

* Comparing Rails sqlite3 and mysql

Okay, just to see, let's compare a sqlite3 and a mysql rails app.

Since I don't want a zillion differences in the project names, I'll make two subdirectories, named sqlite3 and mysql, move the sqlite3 test1 app I created above into the sqlite3 subdirectory, and create a second, mysql rails app named test1 in the mysql subdirectory.

puff@redbitter:~/overweb/tmp$  mkdir sqlite3
puff@redbitter:~/overweb/tmp$  mkdir mysql
puff@redbitter:~/overweb/tmp$  mv test1 sqlite3
puff@redbitter:~/overweb/tmp$  cd mysql
puff@redbitter:~/overweb/tmp/mysql$  rails new test1 -d mysql
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.gitkeep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.0.3) 
Using i18n (0.6.4) 
Using multi_json (1.6.1) 
Using activesupport (3.2.11) 
Using builder (3.0.4) 
Using activemodel (3.2.11) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.5) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.4) 
Using sprockets (2.2.2) 
Using actionpack (3.2.11) 
Using mime-types (1.21) 
Using polyglot (0.3.3) 
Using treetop (1.4.12) 
Using mail (2.4.4) 
Using actionmailer (3.2.11) 
Using arel (3.0.2) 
Using tzinfo (0.3.36) 
Using activerecord (3.2.11) 
Using activeresource (3.2.11) 
Using bundler (1.2.3) 
Using coffee-script-source (1.6.1) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.3) 
Using json (1.7.7) 
Using rdoc (3.12.2) 
Using thor (0.17.0) 
Using railties (3.2.11) 
Using coffee-rails (3.2.2) 
Using jquery-rails (2.2.1) 
Using mysql2 (0.3.11) 
Using rails (3.2.11) 
Using sass (3.2.6) 
Using sass-rails (3.2.6) 
Using uglifier (1.3.0) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
puff@redbitter:~/overweb/tmp/mysql$  cd ..
puff@redbitter:~/overweb/tmp$ 

And now let's do a recursive diff and compare the two rails apps. First let's just --brief so diff just tells us files are different:

puff@redbitter:~/overweb/tmp$  diff --brief -r sqlite3/ mysql/ 
Files sqlite3/test1/config/database.yml and mysql/test1/config/database.yml differ
Files sqlite3/test1/config/initializers/secret_token.rb and mysql/test1/config/initializers/secret_token.rb differ
Files sqlite3/test1/Gemfile and mysql/test1/Gemfile differ
Files sqlite3/test1/Gemfile.lock and mysql/test1/Gemfile.lock differ
puff@redbitter:~/overweb/tmp$  

Okay, to see all the differences you just re-run the diff command without the --brief:

puff@redbitter:~/overweb/tmp$  diff -r sqlite3/ mysql/

But I'm going to break up the output by file and look at each one.

For stars, we can skip secret_token.rb, obviously each app will have a different generated secret toke value.

The Gemfile and Gemfile.lock seem straightforward enough; of course the two different types of apps need different gems for sqlite3 vs mysql:

diff -r sqlite3/test1/Gemfile mysql/test1/Gemfile
8c8
< gem 'sqlite3'
---
> gem 'mysql2'
diff -r sqlite3/test1/Gemfile.lock mysql/test1/Gemfile.lock
55a56
>     mysql2 (0.3.11)
92d92
<     sqlite3 (1.3.7)
108a109
>   mysql2
111d111
<   sqlite3

Besides that, the big difference is in the database.yml:

diff -r sqlite3/test1/config/database.yml mysql/test1/config/database.yml
1,2c1,4
< # SQLite version 3.x
< #   gem install sqlite3
---
> # MySQL.  Versions 4.1 and 5.0 are recommended.
> # 
> # Install the MYSQL driver
> #   gem install mysql2
4,5c6,10
< #   Ensure the SQLite 3 gem is defined in your Gemfile
< #   gem 'sqlite3'
---
> # Ensure the MySQL gem is defined in your Gemfile
> #   gem 'mysql2'
> #
> # And be sure to use new-style password hashing:
> #   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
v7,8c12,15
<   adapter: sqlite3
<   database: db/development.sqlite3
---
>   adapter: mysql2
>   encoding: utf8
>   reconnect: false
>   database: test1_development
10c17,19
<   timeout: 5000
---
>   username: root
>   password:
>   socket: /var/run/mysqld/mysqld.sock
16,17c25,28
<   adapter: sqlite3
<   database: db/test.sqlite3
---
>   adapter: mysql2
>   encoding: utf8
>   reconnect: false
>   database: test1_test
19c30,32
<   timeout: 5000
---
>   username: root
>   password:
>   socket: /var/run/mysqld/mysqld.sock
22,23c35,38
<   adapter: sqlite3
<   database: db/production.sqlite3
---
>   adapter: mysql2
>   encoding: utf8
>   reconnect: false
>   database: test1_production
25c40,42
<   timeout: 5000
---
>   username: root
>   password:
>   socket: /var/run/mysqld/mysqld.sock

So, nothing revolutionary, but it's nice to see how well rails insulates you from the two different databases.


See original (unformatted) article

Feedback

Verification Image:
Subject:
Your Email Address:
Confirm Address:
Please Post:
Copyright: By checking the "Please Post" checkbox you agree to having your feedback posted on notablog if the administrator decides it is appropriate content, and grant compilation copyright rights to the administrator.
Message Content: