机器设置
我有一台运行rails 4.0.0和ruby 2.0.0的Windows 7 64位机器。 我在我的路径中有以下内容:
C:\Ruby200-x64\bin;C:\RubyDevKit\bin;C:\RubyDevKit\mingw\bin;
项目设置
我正在使用同事的工作库克隆的 git 项目中工作。
当我运行初始命令时:
rake db:migrate
我得到了以下错误信息:
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)
我的Gemfile中包含了如下的gem 'sqlite3'
。# Use sqlite3 as the database for Active Record
gem 'sqlite3'
完整的Gemfile如下:
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!
当我运行
bundle install
时,我得到了以下列表-请注意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!
当我运行
bundle show 'sqlite3'
时,会得到以下结果:Could not find gem 'sqlite3'.
Did you mean sqlite3?
当我执行
gem install 'sqlite3'
命令时,我会得到以下结果: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
在搜索了关于“无法转换”的错误后,我发现可以不安装文档进行安装。因此,如果我这样做,
gem install 'sqlite3' --no-doc
I get
Successfully installed sqlite3-1.3.8-x64-mingw32
1 gem installed
然后当我执行
rake db:migrate
我仍然收到
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)
那么,我错过了什么?
谢谢
在根据评论中提供的建议进行操作后更新:
由于 Doon 的评论,我将gemfile的内容放在了上面的问题描述中。
针对techvineet的评论,我运行了多次bundle install
并获得了一致的输出结果。
由于zrl3dx的评论,我现在运行了bundle exec bundle
并且获得相同的输出,即:
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!
由于Sachin Singh的评论,我删除了Gemfile.lock并运行了bundle install
。结果基本相同:
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.
尚未提及sqlite3,运行rake db:migrate
仍然会产生以下结果:
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)
作为对 Sachin Singh 的问题“
ruby -v command
命令的输出是什么?”的回答:输出为:
ruby 2.0.0p247 (2013-06-27) [x64-mingw32]
rails --version会显示:
Rails 4.0.0
Prusswan问:同一台机器上是否有其他的ruby安装?
有三个版本 - 1.9.2,1.9.3和2.0.0。 后者是路径中的版本。其他两个我已经删除了。