构建本机扩展时使用错误的 ruby 和 rvm 捆绑安装?
bundle install using wrong ruby with rvm when building native extension?
我正在使用 bundle install
安装 rest-client
。它因以下原因而失败:
$ bundle
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Installing unf_ext 0.0.7.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/roger/.rvm/gems/ruby-2.3.4@junk-drawer/gems/unf_ext-0.0.7.4/ext/unf_ext
/usr/bin/ruby2.3 -r ./siteconf20180115-9722-1iow75n.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 /home/roger/.rvm/gems/ruby-2.3.4@junk-drawer/gems/unf_ext-0.0.7.4 for inspection.
Results logged to /home/roger/.rvm/gems/ruby-2.3.4@junk-drawer/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.4/gem_make.out
Installing mime-types-data 3.2016.0521
Installing netrc 0.11.0
Using bundler 1.11.2
An error occurred while installing unf_ext (0.0.7.4), and Bundler cannot continue.
Make sure that `gem install unf_ext -v '0.0.7.4'` succeeds before bundling.
我正在使用 rvm,它似乎工作正常,如果我正在正确读取 rvm info
的输出。
which ruby
报告 /home/roger/.rvm/rubies/ruby-2.3.4/bin/ruby
,看起来是正确的。
我找到了 Install ruby headers with rvm,但我 Ruby header 在(显然)正确的位置:
$ ruby -rmkmf -e 'print RbConfig::CONFIG["rubyhdrdir"]'
/home/roger/.rvm/rubies/ruby-2.3.4/include/ruby-2.3.0
$ ls /home/roger/.rvm/rubies/ruby-2.3.4/include/ruby-2.3.0
ruby/ ruby.h x86_64-linux/
在 bundle
的输出中,我看到 /usr/bin/ruby2.3
,这看起来很可疑。
它在错误的地方寻找 Ruby header 文件。我怎样才能使用 RVM-installed 的?
我用错了bundle
。
$ which bundle
/usr/bin/bundle
要么 Ubuntu 16.04 中包含的那个太旧了,要么使用系统安装的捆绑器不适用于安装了 rvm 的 Ruby。
$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
...
1 gem installed
$ which bundle
/home/roger/.rvm/gems/ruby-2.3.4@junk-drawer/bin/bundle
看起来好多了。
$ bundle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using bundler 1.16.1
...
Bundle complete! 1 Gemfile dependency, 9 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
经验教训:使用 rvm 时,请记住 gem install bundler
。
我正在使用 bundle install
安装 rest-client
。它因以下原因而失败:
$ bundle
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Installing unf_ext 0.0.7.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/roger/.rvm/gems/ruby-2.3.4@junk-drawer/gems/unf_ext-0.0.7.4/ext/unf_ext
/usr/bin/ruby2.3 -r ./siteconf20180115-9722-1iow75n.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 /home/roger/.rvm/gems/ruby-2.3.4@junk-drawer/gems/unf_ext-0.0.7.4 for inspection.
Results logged to /home/roger/.rvm/gems/ruby-2.3.4@junk-drawer/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.4/gem_make.out
Installing mime-types-data 3.2016.0521
Installing netrc 0.11.0
Using bundler 1.11.2
An error occurred while installing unf_ext (0.0.7.4), and Bundler cannot continue.
Make sure that `gem install unf_ext -v '0.0.7.4'` succeeds before bundling.
我正在使用 rvm,它似乎工作正常,如果我正在正确读取 rvm info
的输出。
which ruby
报告 /home/roger/.rvm/rubies/ruby-2.3.4/bin/ruby
,看起来是正确的。
我找到了 Install ruby headers with rvm,但我 Ruby header 在(显然)正确的位置:
$ ruby -rmkmf -e 'print RbConfig::CONFIG["rubyhdrdir"]'
/home/roger/.rvm/rubies/ruby-2.3.4/include/ruby-2.3.0
$ ls /home/roger/.rvm/rubies/ruby-2.3.4/include/ruby-2.3.0
ruby/ ruby.h x86_64-linux/
在 bundle
的输出中,我看到 /usr/bin/ruby2.3
,这看起来很可疑。
它在错误的地方寻找 Ruby header 文件。我怎样才能使用 RVM-installed 的?
我用错了bundle
。
$ which bundle
/usr/bin/bundle
要么 Ubuntu 16.04 中包含的那个太旧了,要么使用系统安装的捆绑器不适用于安装了 rvm 的 Ruby。
$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
...
1 gem installed
$ which bundle
/home/roger/.rvm/gems/ruby-2.3.4@junk-drawer/bin/bundle
看起来好多了。
$ bundle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using bundler 1.16.1
...
Bundle complete! 1 Gemfile dependency, 9 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
经验教训:使用 rvm 时,请记住 gem install bundler
。