ruby-on-rails - 无法通过安装调试器

标签 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 应用程序模板吗?

最佳答案

所以对于这个确切的情况——从您的 Gemfile 中注释掉或删除它以及任何依赖它的 gem(查看 Gemfile.lock)你的项目,然后运行 ​​bundle install

Rails 4.1.8 实际上生成了一个应用程序的 Gemfile,其中 debugger 被注释掉了,所以它应该已经可以正常工作了。

如果你真的需要一个调试器,你可以使用byebug ,Ruby 2.0+ 的 debugger 的替代品。在即将发布的 Rails 4.2.0 版本中,它是 already baked into the generator .

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

关于ruby-on-rails - 无法通过安装调试器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27463912/

相关文章:

html - 在 Rails 应用程序中使用 flex 制作表单

ruby - 在 WSL(适用于 Linux 的 Windows 子系统)上安装 Ruby 2.3

ruby-on-rails - Minitest 5 - 套件级设置

ruby-on-rails-4 - 所有 Rails 项目 - Bundler 使用为不同 gem 创建的 binstub

ruby-on-rails - 关于 RoR 更新数据库记录

javascript - 如果 ruby​​ on rails 中的 text_field 为空,如何禁用提交按钮?

ruby-on-rails - 使用 simple_form 自定义错误消息

ruby-on-rails - Rails 3 - yield return 或 callback 不会在 View 中调用 <%= yield( :sidebar) || render ('shared/sidebar' ) %>

ruby-on-rails - Rails 控制台找不到 activesupport-4.1.2,即使它已安装

ruby - 使用 bundler 为不同平台加载不同版本的 gem