2013-02-05 78 views
11

我正在嘗試將一個小測試應用程序推送到Heroku。這裏是應用程序和創業板文件:如何在Heroku上使用rdiscount?

應用:

require 'sinatra' 
require 'haml' 
require 'rdiscount' 

set :markdown, :layout_engine => :haml, :layout => :layout 


get '/' do 
    haml :index 
end 

get '/blog' do 
    markdown :test 
end 

的Gemfile:

source :rubygems 
gem 'sinatra' 
gem 'thin' 
gem 'haml' 
gem 'rdiscount' 

前推到我的Heroku運行bundle install

-----> Ruby/Rack app detected 
-----> Installing dependencies using Bundler version 1.3.0.pre.5 
    Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment 
    Fetching gem metadata from http://rubygems.org/.......... 
    Fetching gem metadata from http://rubygems.org/.. 
    Using daemons (1.1.9) 
    Using eventmachine (1.0.0) 
    Using haml (3.1.7) 
    Using rack (1.4.3) 
    Using rack-protection (1.3.2) 
    installing rdiscount (2.0.7) 
    Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 
    /usr/local/bin/ruby extconf.rb 
    checking for random()... yes 
    checking for srandom()... yes 
    checking for rand()... yes 
    checking for srand()... yes 
    checking size of unsigned long... long 
    checking size of unsigned int... int 
    no int with size 4 
    *** 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=/usr/local/bin/ruby 
    --with-rdiscount-dir 
    --without-rdiscount-dir 
    --with-rdiscount-include 
    --without-rdiscount-include=${rdiscount-dir}/include 
    --with-rdiscount-lib 
    --without-rdiscount-lib=${rdiscount-dir}/lib 
    Gem files will remain installed in /tmp/build_3aijv3ga0dy1y/vendor/bundle/ruby/1.9.1/gems/rdiscount-2.0.7 for inspection. 
    Results logged to /tmp/build_3aijv3ga0dy1y/vendor/bundle/ruby/1.9.1/gems/rdiscount-2.0.7/ext/gem_make.out 
    An error occurred while installing rdiscount (2.0.7), and Bundler cannot continue. 
    Make sure that `gem install rdiscount -v '2.0.7'` succeeds before bundling. 
! 
!  Failed to install gems via Bundler. 
! 
!  Heroku push rejected, failed to compile Ruby/rack app 

我不明白,rdiscount可能依賴於其他一些寶石或圖書館,這種依賴似乎沒有得到解決:但是當試圖安裝rdiscount寶石推到Heroku的失敗。但是,我不明白如何解決這個問題。你能給我一些關於如何使這個工作的建議嗎?

回答

27

在Heroku上似乎有一個Ruby 1.9.2的問題,以及它認爲int的字節數是多少。

嘗試添加ruby "1.9.3"到你的Gemfile這樣的:

source :rubygems 
ruby "1.9.3" 

gem 'sinatra' 
gem 'thin' 
gem 'haml' 
gem 'rdiscount' 

我自己的測試重現了1.9.2你的錯誤和1.9.3

+0

也成功了這個bug:https://開頭github上。 com/rtomayko/rdiscount/issues/48 – GregB

+0

很好的回答!解決了問題!非常感謝!!! –

+0

謝謝你,這也解決了我的問題。 – Jason