我正在尝试创建一个新的 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/