zhm / gdal-ruby

GDAL/OGR bindings for ruby
BSD 3-Clause "New" or "Revised" License
34 stars 10 forks source link

NoMethodError: Installation failure with Ruby 2.2.1 #5

Closed johnjohndoe closed 9 years ago

johnjohndoe commented 9 years ago

I just updated a project to from Ruby 2.1.2 to 2.2.1. When I try to bundle the project the installation for gdal fails. I use Ubuntu 14.04. Here is my configuration:

$ rvm --version
rvm 1.25.27 (stable)
$ ruby --version
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
$ gdal-config --version
1.10.1
$ gdal-config --libs   
-L/usr/lib -lgdal
$ gdal-config --cflags
-I/usr/include/gdal
$ echo $LD_LIBRARY_PATH
/home/user/bin/qgis/lib:/usr/lib

Here is the installation error:

/home/user/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150408-11089-1f5uaok.rb extconf.rb
checking for main() in -lgdal... yes
*** 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=/home/user/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME)
    --with-gdal-dir
    --without-gdal-dir
    --with-gdal-include
    --without-gdal-include=${gdal-dir}/include
    --with-gdal-lib
    --without-gdal-lib=${gdal-dir}/lib
    --with-gdallib
    --without-gdallib
    --with-gdal-config
    --without-gdal-config
    --with-pkg-config
    --without-pkg-config
/home/user/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/shellwords.rb:73:in `shellsplit': 
undefined method `scan' for nil:NilClass (NoMethodError)
    from /home/user/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/mkmf.rb:1788:in `pkg_config'
    from extconf.rb:11:in `<main>'

extconf failed, exit code 1

Refering to issue #1 I already uninstalled and reinstalled libgdal1-dev:

$ sudo apt-get remove libgdal1-dev
$ sudo apt-get install libgdal1-dev
$ gem install gdal -v '0.0.7'
oleksii-leonov commented 9 years ago

Actually, it's a bug with pkg_config method in Ruby 2.2.0 lib/mkmf.rb file.

As quick fix — you can monkey-patch this method with pkg_config from Ruby 2.1.0: https://github.com/aleksejleonov/gdal-ruby/commit/62f69df917f0769ce2da9fb9e7afb39e39efd61f.

zhm commented 9 years ago

Thanks for reporting this. I noticed this problem on travis but I haven't had time to get a proper fix for it.

It looks like the problem is here: https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L1774

It's now checking for success of the process to return the string value, which results in nil for the result when the config executable doesn't respond to --libs-only-l (gdal-config does not).

Changing this line https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L1787

to:

libs = get['libs-only-l'] || ''

Seems to fix the problem. I'm open to a PR that fixes this at least until it's fixed upstream.

Thanks for the info!

johnjohndoe commented 9 years ago

:+1: Please link the pull request here.

zhm commented 9 years ago

Version 1.0.0 is tested and working with ruby 2.2.1. If you have any problems, just re-open the issue :)