2016-12-16 100 views
1

我試圖在使用RGeo gem的Heroku上部署一個Rails應用程序(ruby​​ 2.3.0,rails 4.2.6),但是我沒有安裝底層GEOS庫這是RGeo寶石所依賴的(見https://github.com/rgeo/rgeo#dependencies)。在Heroku上安裝GEOS

根據Heroku's own instructions,這應該可以通過使用heroku-geo-buildpack,但它不起作用。

ADD BUILDPACK到App:

$ heroku buildpacks:set https://github.com/cyberdelia/heroku-geo-buildpack.git 
$ heroku buildpacks:add heroku/ruby 

構建過程看起來不錯:

remote: Building source: 
remote: 
remote: -----> geos/gdal/proj app detected 
remote:  Using geos version: 3.4.2 
remote:  Using gdal version: 1.11.1 
remote:  Using proj version: 4.8.0_1 
remote: -----> Vendoring geo libraries done 
remote: -----> Ruby app detected 
remote: -----> Compiling Ruby/Rails 
remote: -----> Using Ruby version: ruby-2.3.0 

test依賴:

>>> require 'rgeo' 
=> false 
>>> RGeo::CoordSys::Proj4.supported? 
=> true 
>>> RGeo::Geos.supported? 
=> false 
+0

你運行添加buildpack如文檔說,語言之前buildpack?在添加buildpack之後,它說你應該使用「heroku buildpack」來構建它。 –

+0

@AlexanderLuna是我詳細說明了我的過程 – Yarin

+0

試試這個鏈接,在heroku中安裝GEOS:[安裝GEOS](http://stackoverflow.com/questions/16893840/installing-geos-on-heroku-cedar) – vipin

回答

1

好像有問題在heroku上獲得特定的geos buildpack,主要是因爲geos的構建參數。有關完整的詳細信息,您可以查看this pull request到許多討論過的buildpack。在this blog post中詳細描述了使用fork of the webpack的解決方案。

第1步:在你的項目的根目錄下創建這個文件.vendor_urls

https://s3.amazonaws.com/diowa-buildpacks/geos-3.5.0-heroku.tar.gz 
https://s3.amazonaws.com/diowa-buildpacks/proj-4.9.1-heroku.tar.gz 

添加該文件與git,並確保它以換行符結束。

第2步:設置您的Heroku的配置:

heroku buildpacks:set https://github.com/diowa/heroku-buildpack-rgeo-prep.git 
heroku buildpacks:add https://github.com/peterkeen/heroku-buildpack-vendorbinaries.git 
heroku buildpacks:add heroku/ruby 
heroku config:set LD_LIBRARY_PATH=/app/lib 

(SEE https://github.com/diowa/heroku-buildpack-rgeo-prep#setup

最後要注意的是,如果你已經安裝了rgeo,你需要重新編譯的寶石。您可以使用heroku repo plugin,運行heroku repo:purge_cache -a appname並再次部署。

(SEE http://www.diowa.com/blog/heroku/2016/02/26/using-rgeo-with-geos-on-heroku#deploy

+0

YES-非常感謝@mlabarca,該解決方案工作! – Yarin