Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Gem::Ext::BuildError:错误:无法构建Gem本机扩展小牛_Ruby On Rails_Ruby_Rubygems_Bundler - Fatal编程技术网

Ruby on rails Gem::Ext::BuildError:错误:无法构建Gem本机扩展小牛

Ruby on rails Gem::Ext::BuildError:错误:无法构建Gem本机扩展小牛,ruby-on-rails,ruby,rubygems,bundler,Ruby On Rails,Ruby,Rubygems,Bundler,我正在使用这个网站学习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:错误:无法生成Gem本机扩展。 /

我正在使用这个网站学习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:错误:无法生成Gem本机扩展。

    /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>'

OS=Mavericks 10.9.5

看起来bundler没有写入文件系统的权限

权限被拒绝@rb_sysopen-/usr/local/ceral/ruby/2.1.2_3/bin/rake(Errno::EACCES)

尝试以sudo的身份运行命令:

sudo bundle install 

我不知道这是否能帮助人们解决这个问题,但我也犯了同样的错误。我最终做的是在我的gemfile中为应用程序注释掉sqlite gem。当然,我几分钟前刚做过这件事,所以我不知道我是否会遇到其他问题,但我使用Postgres,所以如果你也使用其他东西,应该不会有问题。希望这能帮助像我这样正在寻找答案的人。

我认为问题在于Gemfile.lock,它不允许您使用每个gems的最新版本

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

bundle update 

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

在运行sudo bundle install然后运行rails之后,我得到以下错误。有什么问题吗?感谢您刚刚意识到:您当前的ruby版本是2.1.2,但您的rubygems是2.2。您是否遵循了教程中的环境设置?它需要ruby 2.2,所以请尝试先更新或重新安装ruby,如这里所述
bundle update