Gem :: Ext :: BuildError:错误:无法构建gem原生扩展Mavericks

时间:2015-04-09 12:13:40

标签: ruby-on-rails ruby rubygems bundler

我正在使用这个网站http://tutorials.jumpstartlab.com/projects/blogger.html学习rails,每当我尝试使用rails服务器启动服务器时,我在终端上收到此错误

Could not find gem 'sqlite3 (>= 0) ruby' in the gems available on this machine.
Run `bundle install` to install missing gems.

运行命令bundle install后,出现错误:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/local/Cellar/ruby/2.1.2_3/bin/ruby extconf.rb
/Users/andrewmolo/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/executable-hooks-1.3.2/lib/executable-hooks/regenerate_binstubs_command.rb:71:in `initialize': Permission denied @ rb_sysopen - /usr/local/Cellar/ruby/2.1.2_3/bin/rake (Errno::EACCES)
    from /Users/UserX/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/executable-hooks-1.3.2/lib/executable-hooks/regenerate_binstubs_command.rb:71:in `open'
    from /Users/UserX/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/executable-hooks-1.3.2/lib/executable-hooks/regenerate_binstubs_command.rb:71:in `block in try_to_fix_binstubs'
    from /Users/UserX/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/executable-hooks-1.3.2/lib/executable-hooks/regenerate_binstubs_command.rb:69:in `map'
    from /Users/UserX/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/executable-hooks-1.3.2/lib/executable-hooks/regenerate_binstubs_command.rb:69:in `try_to_fix_binstubs'
    from /Users/UserX/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/executable-hooks-1.3.2/lib/executable-hooks/regenerate_binstubs_command.rb:46:in `block in execute_no_wrapper'
    from /Users/UserX/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/executable-hooks-1.3.2/lib/executable-hooks/regenerate_binstubs_command.rb:44:in `each'
    from /Users/UserX/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/executable-hooks-1.3.2/lib/executable-hooks/regenerate_binstubs_command.rb:44:in `execute_no_wrapper'
    from extconf.rb:19:in `<main>'
bundler 1.9.1
erubis 2.7.0
executable-hooks 1.3.2
nokogiri 1.6.6.2
rack 1.6.0
railties 4.2.1
rake 10.1.0

extconf failed, exit code 1


Gem files will remain installed in /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/executable-hooks-1.3.2 for inspection.
Results logged to /Users/UserX/.rvm/gems/ruby-2.2.0@global/extensions/x86_64-darwin-13/2.1.0/executable-hooks-1.3.2/gem_make.out

    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/ext/builder.rb:89:in `run'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/ext/ext_conf_builder.rb:38:in `block in build'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/tempfile.rb:324:in `open'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/ext/ext_conf_builder.rb:17:in `build'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/ext/builder.rb:161:in `block (2 levels) in build_extension'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/ext/builder.rb:160:in `chdir'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/ext/builder.rb:160:in `block in build_extension'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/ext/builder.rb:159:in `build_extension'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/ext/builder.rb:198:in `block in build_extensions'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `each'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/ext/builder.rb:195:in `build_extensions'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/specification.rb:1436:in `block in build_extensions'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/user_interaction.rb:45:in `use_ui'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/specification.rb:1434:in `build_extensions'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/stub_specification.rb:60:in `build_extensions'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/basic_specification.rb:56:in `contains_requirable_file?'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/specification.rb:925:in `block in find_inactive_by_path'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/specification.rb:924:in `each'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/specification.rb:924:in `find_inactive_by_path'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems.rb:185:in `try_activate'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:132:in `rescue in require'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/vendor/net/http/persistent.rb:12:in `<top (required)>'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/vendored_persistent.rb:11:in `<top (required)>'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    /usr/local/Cellar/ruby/2.1.2_3/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/fetcher.rb:1:in `<top (required)>'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/cli/install.rb:72:in `run'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/cli.rb:157:in `install'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/cli.rb:10:in `start'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/bin/bundle:20:in `block in <top (required)>'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/lib/bundler/friendly_errors.rb:7:in `with_friendly_errors'
    /Users/UserX/.rvm/gems/ruby-2.2.0@global/gems/bundler-1.9.1/bin/bundle:18:in `<top (required)>'
    /usr/local/bin/bundle:23:in `load'
    /usr/local/bin/bundle:23:in `<main>'

环境

Bundler   1.9.1
Rubygems  2.2.2
Ruby      2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
GEM_HOME  /Users/andrewmolo/.rvm/gems/ruby-2.2.0
GEM_PATH  /Users/andrewmolo/.rvm/gems/ruby-2.2.0:/Users/andrewmolo/.rvm/gems/ruby-2.2.0@global
RVM       1.26.10 (latest)
Git       1.8.5.2
rubygems-bundler (1.4.4)

OS = Mavericks 10.9.5

3 个答案:

答案 0 :(得分:2)

我不知道这是否可以帮助解决此问题的人,但我遇到了同样的错误。我最终做的修复是在我的gemfile中为应用程序注释掉sqlite gem。我只是在几分钟前就这样做了所以我不知道我是否会遇到任何其他问题,但是我使用Postgres,所以如果你也使用其他东西,那么应该没有问题。希望这有助于像我一样寻找答案的其他人。

答案 1 :(得分:0)

看起来Bundler无权写入您的文件系统。

  

许可被拒绝@ rb_sysopen - /usr/local/Cellar/ruby/2.1.2_3/bin/rake(Errno :: EACCES)

尝试以sudo运行命令:

sudo bundle install 

答案 2 :(得分:0)

我认为问题是Gemfile.lock不允许你使用每个宝石的最新版本。

要更新Gemfile.lock,请运行以下命令:

bundle update 

在与Gemfile.lock文件相同的目录中,然后再次尝试bundle install