sqlite - gem 安装 sqlite3-ruby 在 cygwin 上失败

标签 sqlite ruby-on-rails-3.2 cygwin sqlite3-ruby

我正在尝试在 cygwin 上的 Rails 上安装 ruby​​,但在创建测试应用程序时遇到了障碍,例如,

rails new my_test_app

看起来我的安装( ruby 1.9.3p429 (2013-05-15) [i386-cygwin], rails 3.2.13, gem 2.0.6, rake 10.1.0 )缺少一个 gem -> sqlite3-ruby。现在找不到头文件( sqlite3.h ),并且我无法指定 gem 理解的配置选项。有人可以帮我吗?

$ rails new test_ror_app1
      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/..
Resolving dependencies...
Using rake (10.1.0)
Using i18n (0.6.1)
Using multi_json (1.7.7)
Using activesupport (3.2.13)
Using builder (3.0.4)
Using activemodel (3.2.13)
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.3)
Using tilt (1.4.1)
Using sprockets (2.2.2)
Using actionpack (3.2.13)
Using mime-types (1.23)
Using polyglot (0.3.3)
Using treetop (1.4.14)
Using mail (2.5.4)
Using actionmailer (3.2.13)
Using arel (3.0.2)
Using tzinfo (0.3.37)
Using activerecord (3.2.13)
Using activeresource (3.2.13)
Using bundler (1.3.5)
Using coffee-script-source (1.6.3)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.3)
Using json (1.8.0)
Using rdoc (3.12.2)
Using thor (0.18.1)
Using railties (3.2.13)
Using coffee-rails (3.2.2)
Using jquery-rails (3.0.4)
Using rails (3.2.13)
Using sass (3.2.10)
Using sass-rails (3.2.6)
Installing sqlite3 (1.3.7)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.

    /usr/bin/ruby.exe extconf.rb
checking for sqlite3.h... *** 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}/
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/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}/
        --enable-local
        --disable-local
/usr/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an
executable file. (RuntimeError)
You have to install development tools first.
        from /usr/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
        from /usr/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header'
        from /usr/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
        from /usr/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
        from /usr/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from /usr/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
        from /usr/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from /usr/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
        from /usr/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
        from /usr/lib/ruby/1.9.1/mkmf.rb:969:in `find_header'
        from extconf.rb:34:in `<main>'


Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7 f
or inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.7/ext/sqlite3/gem_ma
ke.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.

这已成功完成,如下所示:

$ gem install sqlite3 -v '1.3.7'
Successfully installed sqlite3-1.3.7-x86-mswin32-60
1 gem installed

当我重试创建新的测试应用程序时,重复出现与上面(第一个)相同的错误。

请帮我解决这个问题。 TIA。

更新 [1]:mkmf.log 揭示了这一点: /usr/lib/gcc/i686-pc-cygwin/4.7.3/../../../../i686-pc-cygwin/bin/ld: cannot find -lcrypt

最佳答案

如果您通过 Rubygems 安装,终端上的输出可能会提示无法找到 sqlite3.h。这是误导性的。如果您检查mkmf.log 文件,您可能会发现实际上缺少一个完全不同的头文件。一般可以通过相应的Cygwin包来安装头文件。就我而言,我确保安装了以下各项:

  • libcrypt-devel
  • libsqlite3-devel
  • libgmp-devel

关于sqlite - gem 安装 sqlite3-ruby 在 cygwin 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17938144/

相关文章:

bash - 如何从 Cygwin 调用 bat/cmd 文件并继承变量?

android - 如何在 Android 服务中使用 SQLite?

ruby-on-rails - ruby 1.8 和 1.9 之间的字符串长度差异

Ruby 似乎引用一个变量而不是处理它的值

ruby-on-rails-3.2 - 从 rails_admin 中排除属性

windows - 没有 Cygwin 的 Windows 上的 Git?

shell - CYGWIN 终端 : FTP Connection (Password Input doesn't end)

python - 如何从表中选择 2 个不同的随机行?

javascript - Chrome 的 HTML5 Web 数据库在某些 Windows 配置上非常慢

c++ - Windows 预缓存 SQLite 问题