0

从今天早上开始,我无法在我的 rails 项目上安装 sqlite3 gem ......

当我跑步时,gem install sqlite3我得到

Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3:
        ERROR: Failed to build gem native extension.

        /Users/Jonathan/.rvm/rubies/ruby-1.9.3-p194/bin/ruby 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
        --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=/Users/Jonathan/.rvm/rubies/ruby-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
/Users/Jonathan/.rvm/rubies/ruby-1.9.3-p194/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 /Users/Jonathan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
        from /Users/Jonathan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header'
        from /Users/Jonathan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
        from /Users/Jonathan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
        from /Users/Jonathan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from /Users/Jonathan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
        from /Users/Jonathan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from /Users/Jonathan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
        from /Users/Jonathan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
        from /Users/Jonathan/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:969:in `find_header'
        from extconf.rb:34:in `<main>'


Gem files will remain installed in /Users/Jonathan/.rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.6 for inspection.
Results logged to /Users/Jonathan/.rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out

搜索问题后,我发现解决了几乎类似的问题,gem install sqlite3 -- --with-sqlite3-dir=/opt/local但它告诉我 ERROR: While executing gem ... (Errno::EACCES) Permission denied - /Users/Jonathan/.rvm/gems/ruby-1.9.3-p194/gems/sqlite3-1.3.6/API_CHANGES.rdoc

我对编程/终端/等很陌生。所以我真的不知道该怎么办。我做了其他项目没有任何问题或错误,我认为我没有改变任何东西......我刚开始从 rails guide 做博客应用程序,并在运行时遇到了关于 sqlite3 的错误rake db:create

4

2 回答 2

3

作为 Ruby on Rails 的新手,我在 Windows 8 上遇到了同样的权限错误,因为我在尝试安装 sqlite3 gem 时让 rails 服务器处于运行状态。

  1. 如果它正在运行,则关闭 Rails 服务器
  2. gem install sqlite3再次运行
于 2013-01-12T20:24:17.183 回答
1

最后是一些权限问题等。没有找到解决方法,所以我只是通过运行 RailsInstaller 重新安装了我的所有环境,重新安装 Xcode 和命令行工具,并清除brew doctor告诉我要做什么。

现在它又可以工作了:)

于 2012-09-02T21:09:41.810 回答