无法在rails项目上获取我的ruby来创建数据库

Jan*_*ane 5 windows rake 64-bit gem ruby-on-rails

这可能是一个新手设置问题.但是这里......

机器设置

我有一台运行rails 4.0.0和ruby 2.0.0的Windows 7 64位机器我的路径中有以下内容

C:\Ruby200-x64\bin;C:\RubyDevKit\bin;C:\RubyDevKit\mingw\bin;
Run Code Online (Sandbox Code Playgroud)

项目设置

我正在从同事的工作存储库中的克隆git项目开始工作.

当我运行我的初始

rake db:migrate
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

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)
Run Code Online (Sandbox Code Playgroud)

我的Gemfile确实包含gem'sqlite3',如下所示

# Use sqlite3 as the database for Active Record
gem 'sqlite3' 
Run Code Online (Sandbox Code Playgroud)

完整的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!
Run Code Online (Sandbox Code Playgroud)

当我运行时,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!
Run Code Online (Sandbox Code Playgroud)

我什么时候bundle show 'sqlite3'得到

Could not find gem 'sqlite3'.
Did you mean sqlite3?
Run Code Online (Sandbox Code Playgroud)

我什么时候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
Run Code Online (Sandbox Code Playgroud)

在搜索了"无法转换"错误之后,我发现我可以在没有文档的情况下安装.所以,如果我这样做

gem install 'sqlite3' --no-doc 
Run Code Online (Sandbox Code Playgroud)

我明白了

Successfully installed sqlite3-1.3.8-x64-mingw32
1 gem installed
Run Code Online (Sandbox Code Playgroud)

然后当我这样做

rake db:migrate
Run Code Online (Sandbox Code Playgroud)

我还是得到的

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)
Run Code Online (Sandbox Code Playgroud)

那么,我错过了什么?

谢谢

在评论中建议的事情后更新:

作为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!
Run Code Online (Sandbox Code Playgroud)

由于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.
Run Code Online (Sandbox Code Playgroud)

所以仍然没有提到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)
Run Code Online (Sandbox Code Playgroud)

在回答Sachin Singh的问题时,输出是ruby -v command什么?

它说:

ruby 2.0.0p247 (2013-06-27) [x64-mingw32]
Run Code Online (Sandbox Code Playgroud)

和rails - 版本说

Rails 4.0.0
Run Code Online (Sandbox Code Playgroud)

普鲁斯万问在同一台机器上还有其他红宝石装置吗?

有三个 - 1.9.2,1.9.3和2.0.0后者是路径中的一个.我已经删除了另外两个.

Lui*_*ena 8

Bundler和64bits Ruby存在一个已知问题,即没有将x64-mingw32gem平台检测到bundle中,从而使其失败.

我相信这已在1.4.0预发布版本中得到修复,您可以通过执行以下操作来尝试:

gem update bundler --pre

bundle install
Run Code Online (Sandbox Code Playgroud)

64位版本可能会遇到其他问题.以下是我个人对此的建议:

除非您真的被迫工作或创建使用超过2GB RAM的应用程序(很可能不是Rails应用程序),否则我建议您使用32位版本的Ruby(和相应的DevKit)

虽然你有一个64位版本的Windows,但该系统能够毫无问题地运行32位应用程序.使用Rails开发Web应用程序时,没有明显的性能下降.

虽然Ruby 2.0.0已被标记为稳定且生产就绪,但并非所有gem和相关工具都已更新,无法正常使用它.还有一些需要解决的粗糙边缘,正如您在Bundler和64位Ruby的情况下所看到的那样.作为大多数开源软件,这是一项社区工作,可能需要帮助.

希望这可以帮助.