无法通过安装调试器

时间:2014-12-13 21:41:20

标签: ruby-on-rails ruby bundler

我正在尝试创建一个新的Rails项目,当我运行rails new appname时,它告诉我

Could not find debugger-1.6.8 in any of the sources
Run `bundle install` to install missing gems.

然后当我运行bundle install时出现此错误

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

    /Users/username/.rvm/rubies/ruby-2.1.4/bin/ruby -r ./siteconf20141213-76431-12dyum4.rb 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/username/.rvm/rubies/ruby-2.1.4/bin/ruby
/Users/username/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/fileutils.rb:1401:in `initialize': No such file or directory @ rb_sysopen - ./214/ruby_debug.h (Errno::ENOENT)
  from /Users/username/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/fileutils.rb:1401:in `open'
  from /Users/username/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/fileutils.rb:1401:in `copy_file'
  from /Users/username/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/fileutils.rb:483:in `copy_file'
  from /Users/username/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/fileutils.rb:400:in `block in cp'
  from /Users/username/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/fileutils.rb:1579:in `block in fu_each_src_dest'
  from /Users/username/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/fileutils.rb:1593:in `fu_each_src_dest0'
  from /Users/username/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/fileutils.rb:1577:in `fu_each_src_dest'
  from /Users/username/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/fileutils.rb:399:in `cp'
  from extconf.rb:83:in `block in '
  from extconf.rb:82:in `each'
  from extconf.rb:82:in `'

extconf failed, exit code 1

Gem files will remain installed in /Users/username/.rvm/gems/ruby-2.1.4/gems/debugger-1.6.8 for inspection.
Results logged to /Users/username/.rvm/gems/ruby-2.1.4/extensions/x86_64-darwin-13/2.1.0-static/debugger-1.6.8/gem_make.out 

我知道调试器不适用于Ruby 2.1.4,那么我如何让Bundler停止尝试安装呢?我是否必须使用rails应用程序模板?

2 个答案:

答案 0 :(得分:2)

因此,对于这个确切的情况 - 注释或删除它以及依赖于它的任何宝石(查看Gemfile.lock)来自项目根目录的Gemfile,然后运行{{1 }}

Rails 4.1.8实际上会生成一个已注释掉bundle install的应用Gemfile,因此它应该已经正常工作了。

如果您确实需要调试器,则可以使用byebug,替换Ruby 2.0+的debugger。在即将发布的Rails 4.2.0版本中,它是already baked into the generator

创建新应用时,您还可以在创建应用框架后向而不是运行debugger添加选项-B--skip-bundle。然后,您可以修复bundle install并在项目文件夹中自行运行Gemfile。这只会节省你一点时间。

答案 1 :(得分:0)

出现这种失败的原因是你的Gemfile中出现了' byebug 'gem。你可以在你的'开发中看到它'。测试'看起来像

的Gemfile组
group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

'byebug'与'debugger'具有相同的功能 - 任何对文档感兴趣的人都可以访问Github