Ruby-on-rails Gem 安装调试器错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24395453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Gem Install Debugger Error
提问by apardes
I am running Rails v4.0.2 on Mac OS 10.9.2 and I had everything smoothly. All of a sudden I'm getting an error saying gems are missing when I try rails server. I run bundle install and this is the output:
我在 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.
When I try to run gem install debugger -v '1.6.6'I get the following output:
当我尝试运行时,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
I am very confused why this error came up all of a sudden. I have been up and running without issue for weeks. I've tried creating a new gemset with rvm and still encounter the same issue. After searching around I found recommendations to update dependencies first and then try bundle installbut this did not solve the issue.
我很困惑为什么这个错误突然出现。我已经启动并运行了数周没有问题。我试过用 rvm 创建一个新的 gemset,但仍然遇到同样的问题。在四处搜索后,我发现建议先更新依赖项,然后再尝试,bundle install但这并没有解决问题。
回答by nickh
Ruby 2.1.2 isn't supported by debugger, unfortunately. Instead, use the byebug gem. See this discussionfor more details.
不幸的是,调试器不支持 Ruby 2.1.2。相反,使用byebug gem。有关更多详细信息,请参阅此讨论。
回答by Mark Amery
Ruby 2.x is not supported by the debuggergem and you should use byebuginstead. Once Rails 4.2.0 is released (or if you use the Rails 4.2.0rc versions) byebugwill be the default debugger included in your Gemfile, but if you're on an earlier version of Rails then you'll need to make the change manually in your Gemfile.
调试器gem不支持 Ruby 2.x ,您应该改用byebug。一旦 Rails 4.2.0 发布(或者如果您使用 Rails 4.2.0rc 版本)byebug将是您 Gemfile 中包含的默认调试器,但如果您使用的是早期版本的 Rails,则需要进行更改手动在您的 Gemfile 中。
Just replace
只需更换
gem "debugger"
with
和
gem "byebug"
in your Gemfile and run a bundle install.
在你的 Gemfile 中运行一个bundle install.
Some more background
更多背景
Even the maintainer of the debuggergem makes this recommendation. The debuggergem's README on GitHub has the following note:
甚至调试器gem的维护者也提出了这个建议。在调试宝石的GitHub上自述有以下注意事项:
- Only 1.9.2 and 1.9.3 are supported. For 2.X rubies, consider using byebug.
The maintainer has no intention of fixing this; he closed the issue debugger can't be installed on ruby 2.Xunfixed, explaining that debuggernever properly supported Ruby 2.X and that he now recommends byebug.
维护者无意修复这个问题;他关闭了问题debugger can't be installed on ruby 2.Xunfixed,解释说调试器从未正确支持 Ruby 2.X,他现在推荐byebug。
Additionally, the maintainer of debuggerhas not pushed a commit or even replied to a pull request since June 2014. The gem seems to be abandonware at this point.
此外,自 2014 年 6 月以来,调试器的维护者没有推送提交,甚至没有回复拉取请求。此时 gem 似乎是废弃软件。
Rails itself has adopted byebugas the official debugger for Ruby 2.X as of this pull request in April, and from Rails 4.2.0 onwards the Gemfile created when you run rails new my_new_app_namewill reference byebuginstead of debuggerfor Ruby 2.X users.
Rails 本身已经采用byebug作为 Ruby 2.X 的官方调试器,从4 月的这个 pull request开始,从 Rails 4.2.0 开始,运行时创建的 Gemfilerails new my_new_app_name将引用byebug而不是debuggerRuby 2.X 用户。
tl;dr
tl;博士
debuggeris dead. Use byebug.
调试器死了。使用byebug。
回答by andrewdotn
This monstrosity of a command ended up doing the trick for me:
这个命令的怪物最终为我做了伎俩:
gem install debugger-ruby_core_source && ARCHFLAGS="-I$(dirname -- "$(gem which debugger/ruby_core_source/ruby-$(ruby -v | awk '{sub(/p/, "-p", ); print }')/vm_core.h)") -include vm_core.h" bundle install
My apologies.
我很抱歉。
Breaking it down:
分解它:
First, install the Ruby headers.
gem install debugger-ruby_core_sourceNow, if that succeeds we want to run
bundle installbut it needs to be able to find those Ruby headers. Grepping the output ofgem contents debugger-rebuy_core_source, we find that it installs a bunch of different headers for different patchlevels of 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 ...What's the current patch level?
$ ruby -v ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]To transform that into the
ruby-2.0.0-p318format used by thedebugger-ruby_core_sourcegem, we useawkto print only the second field of that version string, and change thepto-p:$ ruby -v | awk '{sub(/p/, "-p", ); print }' 2.0.0-p481Now we run
bundle install, withARCHFLAGSset to add the directory containing the ruby headers to the include file search path, and preloadvm_core.h:gem install debugger-ruby_core_source \ && ARCHFLAGS="-I$(dirname -- \ "$(gem which debugger/ruby_core_source/ruby-$(ruby -v | awk '{sub(/p/, "-p", ); print }')/vm_core.h)") \ -include vm_core.h" \ bundle installi.e.,
gem install debugger-ruby_core_source \ && ARCHFLAGS="-I<path-to-dir_containing_vm_core.h> -include vm_core.h" \ bundle install
首先,安装 Ruby 头文件。
gem install debugger-ruby_core_source现在,如果成功,我们想要运行,
bundle install但它需要能够找到那些 Ruby 头文件。Grepping 的输出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]要将其转换为gem 使用的
ruby-2.0.0-p318格式debugger-ruby_core_source,我们使用awk仅打印该版本字符串的第二个字段,并将其更改p为-p:$ ruby -v | awk '{sub(/p/, "-p", ); print }' 2.0.0-p481现在我们运行
bundle install,使用ARCHFLAGSset 将包含 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", ); print }')/vm_core.h)") \ -include vm_core.h" \ bundle installIE,
gem install debugger-ruby_core_source \ && ARCHFLAGS="-I<path-to-dir_containing_vm_core.h> -include vm_core.h" \ bundle install
回答by valk
For those who's using gem 'pry-debugger'just change it to gem 'pry-byebug'in your Gemfile.
对于那些正在使用的人,gem 'pry-debugger'只需将其更改为gem 'pry-byebug'您的Gemfile.
回答by carlosvini
Unfortunatelly no answer solved this problem. As answered before by nickh, "Ruby 2.1.2 isn't supported by debugger".
不幸的是,没有答案解决了这个问题。正如 nickh 之前回答的那样,“调试器不支持 Ruby 2.1.2”。
I found a japanese post that allowed me to install this gem, but i don't take any responsibility for it, since it's not an official release. Do it at your own risk:
我找到了一个允许我安装这个 gem 的日文帖子,但我对此不承担任何责任,因为它不是官方版本。风险自负:
git clone https://github.com/mekishizufu/debugger.git
cd debugger
git checkout ca451a9bdf
gem build debugger.gemspec
gem install debugger-1.6.6.gem
回答by Gil Christiano Guedes dos Sant
**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

