尝试安装byebug时出错

时间:2018-03-26 21:48:26

标签: ruby rubygems byebug

我在尝试安装byebug时遇到错误。 这是什么原因?

sudo gem install byebug -v '10.0.1'
Building native extensions. This could take a while...
ERROR:  Error installing byebug:
    ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/byebug-10.0.1/ext/byebug
/usr/bin/ruby2.3 -r ./siteconf20180326-12662-69j4pj.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/byebug-10.0.1 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86-linux/2.3.0/byebug-10.0.1/gem_make.out

1 个答案:

答案 0 :(得分:0)

此错误mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h告诉您无法找到构建gem所需的头文件。

另外,为什么要安装sudo?你在用什么系统?您使用的是版本管理器rvm还是rbenv?我推荐https://rvm.io/rvm/install

尝试使用系统库安装

gem install byebug -v '10.0.1' --use-system-libraries

如果不起作用,请运行以下命令并发布其输出:

which ruby
ruby -v
gem -v
echo "${PATH//:/\n}" #may not work if your not on an *nix system

更新:

转到项目的根目录。选择一个ruby版本,但看起来ruby指向系统ruby,而不是rvm版本。尝试安装新的红宝石:

rvm install 2.4.1
rvm use 2.4.1
gem install byebug

如果您的项目中有Gemfile,并且它有ruby -v,请确保它与您使用rvm设置的版本相匹配,并将gem 'byebug'添加到您的Gemfile,然后运行

bundle install