关注'Heroku入门'时出现Ruby'bundle install'错误:无法构建gem native扩展

时间:2014-09-19 05:52:49

标签: ruby heroku gem

我从一开始就跟着Heroku getting started进行了捆绑安装' (step#declare-app-dependencies)并看到一个错误。似乎缺少一些依赖,但我不知道如何找到它们是什么。谁能告诉我应该做什么?

$ bundle install
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.9

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/usr/bin/ruby2.0 extconf.rb 
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h


Gem files will remain installed in /tmp/bundler20140919-3839-1mafrop/json-1.8.1/gems/json-1.8.1 for inspection.
Results logged to /tmp/bundler20140919-3839-1mafrop/json-1.8.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.1), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.1'` succeeds before bundling.

环境=

  1. linuxmint 64位作为VM guest
  2. ruby​​ 2.0.0p299(2013-08-29)[x86_64-linux-gnu]
  3. gem -v = 2.0.7
  4. gem list --local = bundler(1.7.3),i18n(0.6.9),rake(10.3.2)
  5. 已安装Heroku Toolbelt
  6. 使用说明中的example code

1 个答案:

答案 0 :(得分:0)

经过数小时的试用,我终于bundle install了。我做了

sudo apt-get purge ruby*
sudo apt-get install ruby
sudo apt-get install ruby-dev
sudo gem install bundler

在这些之后,bundle install没有错误地传递了json-1.8.1。然后错误来了

...
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
...

所以我做了

sudo apt-get install libpq-dev

再次bundle install。它读了Your bundle is complete!


供您参考,我也做了以下工作。我不知道Heroku getting started示例是否确实需要它们。

sudo apt-get install postgresql postgresql-contrib
sudo apt-get install libmagickwand-dev python-dev