我在Mac OS 10.9.2上运行Rails v4.0.2,我把一切顺利。突然之间,当我尝试rails server
时,我发现一个错误,说宝石丢失了。我运行bundle install,这是输出:
Fetching gem metadata from https://rubygems.org/.......
Fetching additional metadata from https://rubygems.org/..
Using rake 10.1.1
Using i18n 0.6.9
Using minitest 4.7.5
Using multi_json 1.9.0
Using atomic 1.1.16
Using thread_safe 0.2.0
Using tzinfo 0.3.39
Using activesupport 4.0.2
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.2
Using mime-types 1.25.1
Using polyglot 0.3.4
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.0.2
Using activemodel 4.0.2
Using activerecord-deprecated_finders 1.0.3
Using arel 4.0.2
Using activerecord 4.0.2
Using encryptor 1.3.0
Using attr_encrypted 1.3.2
Using awesome_print 1.2.0
Using bcrypt 3.1.7
Using bcrypt-ruby 3.1.5
Using net-ssh 2.8.0
Using net-scp 1.1.2
Using tins 1.0.0
Using term-ansicolor 1.3.0
Using sshkit 1.3.0
Using capistrano 3.1.0
Using capistrano-bundler 1.1.2
Using capistrano-rails 1.1.1
Using climate_control 0.0.3
Using cocaine 0.5.3
Using coderay 1.1.0
Using coffee-script-source 1.7.0
Using execjs 2.0.2
Using coffee-script 2.2.0
Using thor 0.18.1
Using railties 4.0.2
Using coffee-rails 4.0.1
Using columnize 0.3.6
Using currencies 0.4.2
Using countries 0.9.3
Using debugger-linecache 1.2.0
Using debugger-ruby_core_source 1.3.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/aaronpardes/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
*** 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}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/aaronpardes/.rvm/rubies/ruby-2.1.2/bin/ruby
/Users/aaronpardes/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:1573:in `stat': No such file or directory @ rb_file_s_stat - ./212/ruby_debug.h (Errno::ENOENT)
from /Users/aaronpardes/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:1573:in `block in fu_each_src_dest'
from /Users/aaronpardes/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:1587:in `fu_each_src_dest0'
from /Users/aaronpardes/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:1571:in `fu_each_src_dest'
from /Users/aaronpardes/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:399:in `cp'
from extconf.rb:83:in `block in <main>'
from extconf.rb:82:in `each'
from extconf.rb:82:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/aaronpardes/.rvm/gems/ruby-2.1.2@ocx/gems/debugger-1.6.6 for inspection.
Results logged to /Users/aaronpardes/.rvm/gems/ruby-2.1.2@ocx/extensions/x86_64-darwin-13/2.1.0-static/debugger-1.6.6/gem_make.out
An error occurred while installing debugger (1.6.6), and Bundler cannot continue.
Make sure that `gem install debugger -v '1.6.6'` succeeds before bundling.
当我尝试运行gem install debugger -v '1.6.6'
时,我得到以下输出:
Building native extensions. This could take a while...
ERROR: Error installing debugger:
ERROR: Failed to build gem native extension.
/Users/aaronpardes/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb
*** 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}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/Users/aaronpardes/.rvm/rubies/ruby-2.1.2/bin/ruby
/Users/aaronpardes/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:1573:in `stat': No such file or directory @ rb_file_s_stat - ./212/ruby_debug.h (Errno::ENOENT)
from /Users/aaronpardes/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:1573:in `block in fu_each_src_dest'
from /Users/aaronpardes/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:1587:in `fu_each_src_dest0'
from /Users/aaronpardes/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:1571:in `fu_each_src_dest'
from /Users/aaronpardes/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/fileutils.rb:399:in `cp'
from extconf.rb:83:in `block in <main>'
from extconf.rb:82:in `each'
from extconf.rb:82:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/aaronpardes/.rvm/gems/ruby-2.1.2@ocx/gems/debugger-1.6.6 for inspection.
Results logged to /Users/aaronpardes/.rvm/gems/ruby-2.1.2@ocx/extensions/x86_64-darwin-13/2.1.0-static/debugger-1.6.6/gem_make.out
我很困惑为什么这个错误突然出现了。几个星期以来,我一直没有问题。我尝试用rvm创建一个新的gemset,但仍然遇到同样的问题。在搜索之后,我找到了首先更新依赖项的建议,然后尝试bundle install
,但这并没有解决问题。
答案 0 :(得分:29)
答案 1 :(得分:24)
只需替换
gem "debugger"
与
gem "byebug"
在您的Gemfile中并运行bundle install
。
即使是调试器 gem的维护者也提出了这个建议。 GitHub上的调试器 gem的自述文件具有以下note:
- 仅支持1.9.2和1.9.3。对于2.X红宝石,请考虑使用byebug。
维护者无意修复此问题;他解决了问题debugger can't be installed on ruby 2.X不固定,解释说调试器从未正确支持Ruby 2.X,他现在推荐 byebug 。
此外,调试器的维护者自2014年6月以来没有推送提交甚至回复拉取请求。此时宝石似乎是放弃软件。
Rails本身已采用 byebug 作为{2.}}的Ruby 2.X的官方调试器,从Rails 4.2.0开始,运行rails new my_new_app_name
时创建的Gemfile对于Ruby 2.X用户,将引用byebug
而不是debugger
。
调试器已经死了。使用 byebug 。
答案 2 :(得分:13)
这个命令的怪异最终为我做了诀窍:
gem install debugger-ruby_core_source && ARCHFLAGS="-I$(dirname -- "$(gem which debugger/ruby_core_source/ruby-$(ruby -v | awk '{sub(/p/, "-p", $2); print $2}')/vm_core.h)") -include vm_core.h" bundle install
道歉。
打破它:
首先,安装Ruby标头。
gem install debugger-ruby_core_source
现在,如果成功,我们想运行bundle install
,但它需要能够找到那些Ruby标头。打算gem contents debugger-rebuy_core_source
的输出,我们发现它为Ruby的不同补丁级别安装了一堆不同的标题:
$ gem contents debugger-ruby_core_source | grep vm_core.h
/Users/andrew/.gem/ruby/2.0.0/gems/debugger-ruby_core_source-1.3.2/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vm_core.h
/Users/andrew/.gem/ruby/2.0.0/gems/debugger-ruby_core_source-1.3.2/lib/debugger/ruby_core_source/ruby-1.9.2-p318/vm_core.h
/Users/andrew/.gem/ruby/2.0.0/gems/debugger-ruby_core_source-1.3.2/lib/debugger/ruby_core_source/ruby-1.9.2-p320/vm_core.h
...
目前的补丁级别是什么?
$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
要将其转换为ruby-2.0.0-p318
gem使用的debugger-ruby_core_source
格式,我们使用awk
仅打印该版本字符串的第二个字段,并更改p
到-p
:
$ ruby -v | awk '{sub(/p/, "-p", $2); print $2}'
2.0.0-p481
现在我们运行bundle install
,ARCHFLAGS
设置为将包含ruby标头的目录添加到包含文件搜索路径,并预加载vm_core.h
:
gem install debugger-ruby_core_source \
&& ARCHFLAGS="-I$(dirname -- \
"$(gem which debugger/ruby_core_source/ruby-$(ruby -v | awk '{sub(/p/, "-p", $2); print $2}')/vm_core.h)") \
-include vm_core.h" \
bundle install
即,
gem install debugger-ruby_core_source \
&& ARCHFLAGS="-I<path-to-dir_containing_vm_core.h> -include vm_core.h" \
bundle install
答案 3 :(得分:5)
对于使用gem 'pry-debugger'
的用户,只需将其更改为gem 'pry-byebug'
中的Gemfile
。
答案 4 :(得分:4)
不幸的是没有答案解决了这个问题。正如nickh之前所回答的,“调试器不支持Ruby 2.1.2。”
我发现了一个允许我安装此宝石的日文帖子,但我不承担任何责任,因为它不是正式版本。这样做需要您自担风险:
git clone https://github.com/mekishizufu/debugger.git
cd debugger
git checkout ca451a9bdf
gem build debugger.gemspec
gem install debugger-1.6.6.gem
答案 5 :(得分:-1)
**Step 1** gilchristiano@rails-intro:~/workspace (master) $ rails --version Could not find debugger-1.6.6 in any of the sources Run `bundle install` to install missing gems. **Step 2** gilchristiano@rails-intro:~/workspace (master) $ debugger-1.6.6 bash: debugger-1.6.6: command not found **Step 3** gilchristiano@rails-intro:~/workspace (master) $ gem install debugger -v '1.6.6' Building native extensions. This could take a while... Successfully installed debugger-1.6.6 1 gem installed **Step 4** gilchristiano@rails-intro:~/workspace (master) $ bundle install