5

This is probably a newbie setup problem. But here goes...

Machine setup

I have a Windows 7 64 bit machine running rails 4.0.0 and ruby 2.0.0 I have the following in my Path

C:\Ruby200-x64\bin;C:\RubyDevKit\bin;C:\RubyDevKit\mingw\bin;

Project setup

I am working from a cloned git project from a colleague's working repository.

When I run my initial

rake db:migrate

I get the following error

rake aborted!
Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 's
qlite3'` to your Gemfile.
C:/Working/mynewproject/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

My Gemfile does contain gem 'sqlite3' as follows

# Use sqlite3 as the database for Active Record
gem 'sqlite3' 

The complete Gemfile is

source 'https://rubygems.org'

ruby '2.0.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
gem 'rails_12factor', group: :production

# Use sqlite3 as the database for Active Record
gem 'sqlite3' 

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Twitter Bootstrap for styling
gem 'bootstrap-sass'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

gem 'protected_attributes' # should probably use strong parameters!

When I run bundle install I get the following list - note the absence of sqlite3

Using rake (10.1.0)
Using i18n (0.6.5)
Using minitest (4.7.5)
Using multi_json (1.7.9)
Using atomic (1.1.13)
Using thread_safe (0.1.2)
Using tzinfo (0.3.37)
Using activesupport (4.0.0)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0)
Using mime-types (1.25)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.0)
Using activemodel (4.0.0)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.0)
Using activerecord (4.0.0)
Using sass (3.2.10)
Using bootstrap-sass (2.3.2.2)
Using coffee-script-source (1.6.3)
Using execjs (2.0.1)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.0)
Using coffee-rails (4.0.0)
Using hike (1.2.3)
Using jbuilder (1.5.1)
Using jquery-rails (3.0.4)
Using json (1.8.0)
Using protected_attributes (1.0.3)
Using bundler (1.3.5)
Using tilt (1.4.1)
Using sprockets (2.10.0)
Using sprockets-rails (2.0.0)
Using rails (4.0.0)
Using rails_serve_static_assets (0.0.1)
Using rails_stdout_logging (0.0.2)
Using rails_12factor (0.0.2)
Using rdoc (3.12.2)
Using sass-rails (4.0.0)
Using sdoc (0.3.20)
Using turbolinks (1.3.0)
Using uglifier (2.2.1)
Your bundle is complete!

When I do bundle show 'sqlite3' I get

Could not find gem 'sqlite3'.
Did you mean sqlite3?

When I do gem install 'sqlite3' I get

Successfully installed sqlite3-1.3.8-x64-mingw32
Parsing documentation for sqlite3-1.3.8-x64-mingw32
unable to convert "\x90" from ASCII-8BIT to UTF-8 for lib/sqlite3/2.0/sqlite3_native.so, skipping
1 gem installed

Having searched about to see about that "unable to convert" error, I found that I could install without documentation. So, if I do

gem install 'sqlite3' --no-doc 

I get

Successfully installed sqlite3-1.3.8-x64-mingw32
1 gem installed

and then when I do

rake db:migrate

I still get

rake aborted!
Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 's
qlite3'` to your Gemfile.
C:/Working/mynewproject/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

So, what have I missed?

Thanks

Update after doing things suggested in the comments:

As a result of Doon's comment I have put the gemfile contents in the description of the problem above

In response to techvineet's comment I have ran bundle install several times with consistent outputs.

As a result of zrl3dx's comment I have now ran bundle exec bundle and get the same output, i.e.

Using rake (10.1.0)
Using i18n (0.6.5)
Using minitest (4.7.5)
Using multi_json (1.7.9)
Using atomic (1.1.13)
Using thread_safe (0.1.2)
Using tzinfo (0.3.37)
Using activesupport (4.0.0)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0)
Using mime-types (1.25)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.0)
Using activemodel (4.0.0)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.0)
Using activerecord (4.0.0)
Using sass (3.2.10)
Using bootstrap-sass (2.3.2.2)
Using coffee-script-source (1.6.3)
Using execjs (2.0.1)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.0)
Using coffee-rails (4.0.0)
Using hike (1.2.3)
Using jbuilder (1.5.1)
Using jquery-rails (3.0.4)
Using json (1.8.0)
Using protected_attributes (1.0.3)
Using bundler (1.3.5)
Using tilt (1.4.1)
Using sprockets (2.10.0)
Using sprockets-rails (2.0.0)
Using rails (4.0.0)
Using rails_serve_static_assets (0.0.1)
Using rails_stdout_logging (0.0.2)
Using rails_12factor (0.0.2)
Using rdoc (3.12.2)
Using sass-rails (4.0.0)
Using sdoc (0.3.20)
Using turbolinks (1.3.0)
Using uglifier (2.2.1)
Your bundle is complete!

As a result of Sachin Singh's comment I deleted Gemfile.lock and ran bundle install. The results were pretty much the same:

Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.0)
Using i18n (0.6.5)
Using minitest (4.7.5)
Using multi_json (1.7.9)
Using atomic (1.1.13)
Using thread_safe (0.1.2)
Using tzinfo (0.3.37)
Using activesupport (4.0.0)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0)
Using mime-types (1.25)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.0)
Using activemodel (4.0.0)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.0)
Using activerecord (4.0.0)
Using sass (3.2.10)
Using bootstrap-sass (2.3.2.2)
Using bundler (1.3.5)
Using coffee-script-source (1.6.3)
Using execjs (2.0.1)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.0)
Using coffee-rails (4.0.0)
Using hike (1.2.3)
Using jbuilder (1.5.1)
Using jquery-rails (3.0.4)
Using json (1.8.0)
Using protected_attributes (1.0.3)
Using tilt (1.4.1)
Using sprockets (2.10.0)
Using sprockets-rails (2.0.0)
Using rails (4.0.0)
Using rails_serve_static_assets (0.0.1)
Using rails_stdout_logging (0.0.2)
Using rails_12factor (0.0.2)
Using rdoc (3.12.2)
Using sass-rails (4.0.0)
Using sdoc (0.3.20)
Using turbolinks (1.3.0)
Using uglifier (2.2.1)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

so still no mention of sqlite3 and rake db:migrate still results in

rake aborted!
Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 's
qlite3'` to your Gemfile.
C:/Working/its-a-disaster/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

In response to Sachin Singh's question what is the output of ruby -v command?

It says:

ruby 2.0.0p247 (2013-06-27) [x64-mingw32]

and rails --version says

Rails 4.0.0

Prusswan asked are there other ruby installations on the same machine?

There were three - 1.9.2, 1.9.3 and 2.0.0 The latter is the one in the path. The other two I have since removed.

Community
  • 1
  • 1
Jane
  • 1,953
  • 1
  • 20
  • 27
  • post your Gemfile, where is the sqlite3 gem specified? Is it in the development group? – Doon Sep 03 '13 at 11:59
  • Have you run bundle install again after specifying it in there? Just include it in your bundle like gem 'sqlite3' and run bundle install again – techvineet Sep 03 '13 at 11:59
  • @Doon - updated to add gemfile in question – Jane Sep 03 '13 at 12:01
  • @techvineet yes, several times to no avail – Jane Sep 03 '13 at 12:01
  • Try `bundle exec bundle`. – zrl3dx Sep 03 '13 at 12:02
  • @zrl3dx thanks, just tried that, the output from bundle exec bundle is the same as bundle install – Jane Sep 03 '13 at 12:04
  • @Jane, delete Gemfile.lock, and then do bundle install – Sachin Singh Sep 03 '13 at 12:05
  • http://www.youtube.com/watch?v=VZ20Lh4zbRo – beck03076 Sep 03 '13 at 12:07
  • @SachinSingh Thanks, just tried that, still no sqlite3 mentioned – Jane Sep 03 '13 at 12:15
  • @beck03076 ran through that video, have a working sqlite3 command line, can create a database, can insert a row, can view rows – Jane Sep 03 '13 at 12:23
  • Is there any difference between `rake db:migrate` and `bundle exec rake db:migrate` output? – zrl3dx Sep 03 '13 at 12:23
  • 1
    are there other ruby installations on the same machine? – prusswan Sep 03 '13 at 12:25
  • what is the output of `ruby -v` command? – Sachin Singh Sep 03 '13 at 12:58
  • @zrl3dx no difference at all – Jane Sep 03 '13 at 13:27
  • @prusswan I have three versions of ruby installed - Ruby192, Ruby193 and Ruby200-x64. My Path only refers to Ruby200-x64 – Jane Sep 03 '13 at 13:28
  • @SachinSingh the output of ruby -v is ruby 2.0.0p247 (2013-06-27) [x64-mingw32] – Jane Sep 03 '13 at 13:28
  • Do you have sqlite3 installed ok? At a DOS prompt can you type `sqlite3`? –  Sep 03 '13 at 13:59
  • just to make sure, did you run `rake db:create` before running your `migrate`? – davegson Sep 03 '13 at 14:06
  • @GraemeMcLean I hadn't put it on the path, but it was installed. Have since added it to the path and rebooted. Same results. – Jane Sep 03 '13 at 14:12
  • @TheChamp good point, I get the same `Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 's qlite3'` to your Gemfile.` result for either `rake db:create` or `rake db:migrate` – Jane Sep 03 '13 at 14:13
  • @Jane try doing `bundle update sqlite3`. – Sachin Singh Sep 03 '13 at 14:26
  • @SachinSingh I get the same output as if I do `bundle update` - nothing sqlite3 specific – Jane Sep 03 '13 at 14:36
  • Sounds like the install failed (albeit silently) because it couldn't find sqlite to build the extensions. Maybe this can help `https://www.ruby-forum.com/topic/4413168`. –  Sep 03 '13 at 14:51
  • @GraemeMcLean I'd just spotted the same article so am trying that now. I'm wondering if it's a 64bit related problem. – Jane Sep 03 '13 at 15:38
  • Ok, sorted it - I needed to hand edit my gemfile.lock file to change sqlite3 (1.3.8-x86-mingw32) to sqlite3 (1.3.8-x64-mingw32) as per http://stackoverflow.com/questions/15480381/how-do-i-install-sqlite3-for-ruby-on-windows - so it do seem to be a 64 bit vs 32 bit problem – Jane Sep 03 '13 at 15:46
  • Same problem as this question? http://stackoverflow.com/questions/16514449/rails-4-0rc1-app-not-running-due-to-missing-sqlite3-gem – jemminger Sep 03 '13 at 22:32
  • Note that this is a relatively new problem as x64 ruby was not available on Windows until recently – prusswan Sep 04 '13 at 01:01
  • @jemminger similar, but not quite - the solution they have didn't work for me unfortunately – Jane Sep 04 '13 at 08:33
  • @prusswan I wasn't aware of that, thanks for the extra information. I'll bear this in mind as I progress! – Jane Sep 04 '13 at 08:35
  • Silly question but, are you sure that you are in the correct directory? – rhernando Sep 04 '13 at 10:40
  • @rhernando yup :) but it's always worth asking the silly question :) – Jane Sep 04 '13 at 15:36

1 Answers1

8

There is a known problem with Bundler and 64bits Ruby, which is not detecting x64-mingw32 gem platforms into the bundle, thus making it fail.

I believe this has been fixed in the 1.4.0 pre-release versions, and you can try that by doing:

gem update bundler --pre

bundle install

There are other issues you might encounter with the 64bits version. The following is my personal recommendation about it:

Unless you're really forced to work or create applications that uses more than 2GB of RAM (most likely not a Rails application), I recommend you use the 32bits version of Ruby (and the respective DevKit)

While you have a 64bits version of Windows, the system is quite capable of running 32bits applications without issues. There is no performance degradation that can be noticeable when developing Web applications with Rails.

While Ruby 2.0.0 has been marked as stable and production ready, not all the gems and related tools has been updated to work properly with it. There are still some rough edges that needs to be ironed out, as you can see on the case of Bundler and 64bits Ruby. As most of the open-source software, this is a community effort and help might be required.

Hope this helps.

Luis Lavena
  • 10,348
  • 1
  • 37
  • 39
  • Thanks Luis. That command worked and saved me having to do a manual replace of -x86-mingw32 with -x64-mingw32 – Jane Sep 04 '13 at 16:23
  • Happy to hear @Jane, but keep in mind the other recommendations. You might encounter other problems with some gems that do not work quite as nice they do in the 32bits version. – Luis Lavena Sep 06 '13 at 16:12