whitequark / rlua

Ruby to Lua bindings library.
http://whitequark.github.com/rlua/
MIT License
27 stars 10 forks source link

Fix for homebrew 5.1.4 #1

Closed sw17ch closed 12 years ago

sw17ch commented 12 years ago

I noticed that RLua fails to install with the current version of Lua on Homebrew (5.1.4). Following is the error I get when trying to install. Several variations of the options also failed.

$ gem install rlua -- --with-lua5.1-lib=/usr/local/Cellar/lua/5.1.4/lib/ --with-opt-include=/usr/local/Cellar/lua/5.1.4/include/
Building native extensions.  This could take a while...
ERROR:  Error installing rlua:
    ERROR: Failed to build gem native extension.

        /Users/me/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb --with-lua5.1-lib=/usr/local/Cellar/lua/5.1.4/lib/ --with-opt-include=/usr/local/Cellar/lua/5.1.4/include/
checking for luaL_newstate() in -llua5.1... no
*** 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
    --with-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/me/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
    --with-lua5.1-dir
    --without-lua5.1-dir
    --with-lua5.1-include
    --without-lua5.1-include=${lua5.1-dir}/include
    --with-lua5.1-lib=${lua5.1-dir}/lib
    --with-lua5.1lib
    --without-lua5.1lib
 extconf failure: need liblua5.1

Gem files will remain installed in /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rlua-1.0 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-1.9.3-p194/gems/rlua-1.0/ext/gem_make.out

These commits do a few things, but mainly:

  1. Search for a library that includes a . before the version number in extconf.rb
  2. #include <lua.h> instead of #include <lua5.1/lua.h>.

I'm not sure if #2 above is preferable. After making the changes in this pull request, running the following command manages to install the gem:

$ rake gem && gem install pkg/rlua-1.1.rc.1.gem -- --with-lua5.1-lib=/usr/local/Cellar/lua/5.1.4/lib --with-lua5.1-include=/usr/local/Cellar/lua/5.1.4/include/rake/gempackagetask is deprecated.  Use rubygems/package_task instead
WARNING: 'require 'rake/rdoctask'' is deprecated.  Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
    at /Users/johnvanenk/.rvm/gems/ruby-1.9.3-p194/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
mkdir -p pkg
rm -f pkg/rlua-1.1.rc.1/ext/rlua.c
ln ext/rlua.c pkg/rlua-1.1.rc.1/ext/rlua.c
rm -f pkg/rlua-1.1.rc.1/lib/rlua.rb
ln lib/rlua.rb pkg/rlua-1.1.rc.1/lib/rlua.rb
rm -f pkg/rlua-1.1.rc.1/LICENSE.rdoc
ln LICENSE.rdoc pkg/rlua-1.1.rc.1/LICENSE.rdoc
rm -f pkg/rlua-1.1.rc.1/README.rdoc
ln README.rdoc pkg/rlua-1.1.rc.1/README.rdoc
rm -f pkg/rlua-1.1.rc.1/TODO.rdoc
ln TODO.rdoc pkg/rlua-1.1.rc.1/TODO.rdoc
rm -f pkg/rlua-1.1.rc.1/ext/extconf.rb
ln ext/extconf.rb pkg/rlua-1.1.rc.1/ext/extconf.rb
cd pkg/rlua-1.1.rc.1
mv rlua-1.1.rc.1.gem ..
cd -
Building native extensions.  This could take a while...
Successfully installed rlua-1.1.rc.1
1 gem installed
Installing ri documentation for rlua-1.1.rc.1...
Installing RDoc documentation for rlua-1.1.rc.1...
whitequark commented 12 years ago

The pull request seems to work fine on Debian. I'll add a bit more stuff and release a new version of gem.

whitequark commented 12 years ago

By the way, I noticed that rlua is licensed under LGPL3, for historical reasons. I'm going to relicense it under MIT. Do you allow me to redistribute your contribution under that license, too?

sw17ch commented 12 years ago

Yes. Absolutely.

sw17ch commented 12 years ago

The beta gem fails to install on windows, but fails silently:

C:\Users\Administrator>gem install rlua -v 1.1.beta1
Successfully installed rlua-1.1.beta1
1 gem installed
Installing ri documentation for rlua-1.1.beta1...
Installing RDoc documentation for rlua-1.1.beta1...

C:\Users\Administrator>pry
[1] pry(main)> require 'rlua'
LoadError: cannot load such file -- rlua.so
from C:/Rubies/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
 `require'
[2] pry(main)>

I haven't had a chance to do too much more investigation, but we noticed that the log file somehow fails to find the newstate symbol (which is a problem in and of itself). More importantly, it appears that if the checks/compilation fails, the gem doesn't fail to install.

whitequark commented 12 years ago

Hmm, not surprising -- it was never supposed to work on Windows. I don't have a Windows system anyway, so you're on your own. I guess that you just don't have Lua headers/libs installed.