Skip to content

Fix to make gem compile on Arch Linux (second attempt) #65

Closed
wants to merge 2 commits into from

7 participants

@asppsa
asppsa commented Dec 24, 2012

I experienced the same problem mentioned in issue cowboyd/libv8#61. It seems that Arch Linux (and perhaps other systems?) requires some changes to the V8 source to make it compile using the 'python2' executable instead of the assumed 'python' executable (which on Arch points to Python 3). The proposed patch is copied from the Arch Build System (ABS), and is executed whenever a 'python2' executable exists on the system.

This is a revised version of pull request #64 (the previous version failed with 1.8.7).

@asppsa asppsa Support for 'python2' executable
This fix is needed to make the gem compile on Arch Linux.
0e48790
@ignisf
Collaborator
ignisf commented Jan 1, 2013

Thanks, this fixed it for me 👍

@jbirdjavi

I'm using Archlinux and I tried installing this gem w/patch by putting this line in my Gemfile:

gem 'libv8', :git => 'git://github.com/asppsa/libv8.git', :branch => 'abs-copy'

I got this error on a 'bundle install':

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

    /home/justin/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb 
creating Makefile 
Using compiler: /usr/bin/g++
which: no gmake in (/home/justin/.rvm/gems/ruby-1.9.3-p327/bin:/home/justin/.rvm/gems/ruby-1.9.3-p327@global/bin:/home/justin/.rvm/rubies/ruby-1.9.3-p327/bin:/home/justin/.rvm/bin:~/bin:~/.bin:/usr/local/homebrew/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/git/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/bin/core_perl:/opt/qt/bin)
make: *** No rule to make target `x64.release'.  Stop.


Gem files will remain installed in /home/justin/.rvm/gems/ruby-1.9.3-p327/bundler/gems/libv8-0e487902216a for inspection.
Results logged to /home/justin/.rvm/gems/ruby-1.9.3-p327/bundler/gems/libv8-0e487902216a/ext/libv8/gem_make.out

Am I doing anything wrong?

@asppsa
asppsa commented Jan 5, 2013

@jbirdjavi, a similar issue to yours was raised previously (see #47) -- my guess is that "which make" on your system will point at a non-GNU version of make, as you have quite a few things in your path. If I'm right, then you can fix it by adding a symlink to the arch default 'make' (/usr/bin/make) called "gmake" somewhere in your path.

@jbirdjavi

@asppsa I initially thought that too so I did create a symlink but determined that it didn't matter so I had taken it out, since make is actually GNU Make. But I created the symlink again anyway and retested...

Make stuff:

justin@jbirdjavi-l-arch ~/cmde/work_rails/sp[master*]: gmake --version
GNU Make 3.82
Built for x86_64-unknown-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
justin@jbirdjavi-l-arch ~/cmde/work_rails/sp[master*]: make --version
GNU Make 3.82
Built for x86_64-unknown-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
justin@jbirdjavi-l-arch ~/cmde/work_rails/sp[master*]: which make
/usr/bin/make

Latest 'bundle install':

Using libv8 (3.11.8.9) from git://github.com/asppsa/libv8.git (at abs-copy) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/justin/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb 
creating Makefile
Using compiler: /usr/bin/g++
gmake: *** No rule to make target `x64.release'.  Stop.
/home/justin/.rvm/gems/ruby-1.9.3-p327/bundler/gems/libv8-d6074c6251cd/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/home/justin/.rvm/gems/ruby-1.9.3-p327/bundler/gems/libv8-d6074c6251cd/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
    from /home/justin/.rvm/gems/ruby-1.9.3-p327/bundler/gems/libv8-d6074c6251cd/ext/libv8/location.rb:35:in `each'
    from /home/justin/.rvm/gems/ruby-1.9.3-p327/bundler/gems/libv8-d6074c6251cd/ext/libv8/location.rb:35:in `verify_installation!'
    from /home/justin/.rvm/gems/ruby-1.9.3-p327/bundler/gems/libv8-d6074c6251cd/ext/libv8/location.rb:26:in `install!'
    from extconf.rb:7:in `<main>'



Gem files will remain installed in /home/justin/.rvm/gems/ruby-1.9.3-p327/bundler/gems/libv8-d6074c6251cd for inspection.
Results logged to /home/justin/.rvm/gems/ruby-1.9.3-p327/bundler/gems/libv8-d6074c6251cd/ext/libv8/gem_make.out
@jbirdjavi

Oh, I switched to cowboyd's repo and am getting the same exact thing as I am on your repo. I must be running into a different issue... :/

@ignisf
Collaborator
ignisf commented Jan 6, 2013

@jbirdjavi, to my knowledge currently libv8 cannot be used directly from git as it relies on GYP which needs to be checked out (from SVN) and patched before the gem is built (that's why the README states that you need to run rake checkout). Bundler cannot do this on its own (for SVN, git submodules can be cloned automatically by specifying :submodules => true in the Gemfile) which means we're out of luck at least for now.

I should probably open a feature request for this, if it's OK with @cowboyd.

@ignisf
Collaborator
ignisf commented Jan 6, 2013

There are two workarounds for now (I believe that this is considered an upstream issue with GYP although it doesn't seem that there's much done for fixing it, and this pull rq may not be accepted at all):

  1. Build and install the gem yourself with:
git clone git://github.com/asppsa/libv8.git
cd libv8
bundle install
bundle exec rake checkout
bundle exec rake binary
gem install pkg/libv8-3.11.8.3<YOUR PLATFORM HERE>.gem
  1. ln -s /usr/bin/python2 $HOME/.rvm/bin/python and retry installing the gem with gem install libv8 or bundle install while having just gem libv8 in your Gemfile.
@ignisf ignisf referenced this pull request Jan 6, 2013
Closed

Don't compile on gentoo #66

@jbirdjavi

Thanks @ignisf! The first workaround did the trick for me. +1 for this pull request.

@ghedamat
ghedamat commented Jan 6, 2013

Thanks @ignisf! The first workaround did the trick also for me.

@cowboyd
Owner
cowboyd commented Jan 6, 2013

@asppsa Thanks for the PR. It'll be great to get this working for everybody on Arch Linux.

However, I think that there is a problem with this approach as written because the patch happens during the rake checkout task which is only run on the local box when building the gem by hand.

Ideally, users of Arch Linux, like everybody else, should be able to just insert

gem 'libv8'

into their Gemfiles, or type gem install libv8 from the command line and it will successfully compile. As written, they can only clone from git.

Is there any way to do this at v8 build time (as opposed to gem build time) https://github.com/cowboyd/libv8/blob/master/ext/libv8/builder.rb

That way, Arch users can install directly from rubygems.org

@vassilevsky

I am running Arch i686. Linking ~/.rvm/bin/python to python2 totally allowed me to do a regular gem install libv8! Thank you very much for the tip!

@ignisf
Collaborator
ignisf commented Jan 6, 2013

@vassilevsky, keep in mind that this is a VERY ugly and unsustainable workaround and is to be used only temporarily until we can find a permanent fix. Now that you have installed the gem, you can safely remove the link to ensure that your distro is working consistently and as expected.

@asppsa, @cowboyd, perhaps a patch! method in builder.rb. That way we get rid of all the patching in rake checkout?

@cowboyd
Owner
cowboyd commented Jan 7, 2013

@ignisf I like that idea. Especially if we make it so that no code has to change in order to add or remove a patch. Just drop a .patch file in a known place and away you go.

@asppsa asppsa closed this Jan 7, 2013
@asppsa
asppsa commented Jan 7, 2013

Ok, I've closed this pull request, given its problems. The code I copied from the ABS PKGBUILD system (i.e. the sed lines) should only be applied to the v8 sources if a python2 executable is available, so I can't really generate a .patch file from their solution unless there is some code to only apply the patch in the right circumstances (when python2 is around). Otherwise, someone more talented than me will probably need to work out a more elegant way of patching v8.

For now I'll have a go at modifying builder.rb with the same lines to see if that can work. I can always do it again as a patch later if that becomes possible.

@robertquinn

@ignisf @ghedamat @jbirdjavi

What should this line look like if I am on OSX X 10.7.5 (Lion):

gem install pkg/libv8-3.11.8.3[YOUR PLATFORM HERE].gem

Here are the things I have tried: http://i.imgur.com/CwpN803.png

@ignisf
Collaborator
ignisf commented May 20, 2013

@robertquinn, try gem install libv8 --version 3.11.8.17. It should download the correct binary version of the gem for your OS.

You can see the correct gem platform this way:

require 'rbconfig'
RbConfig::CONFIG.values_at 'target_cpu', 'target_os'
@robertquinn

@ignisf

For some reason, I am still getting the same error. I have tried so many things, and yet no solution. Here is the output I got after following your workaround: http://i.imgur.com/jzoGsqb.png

To recap, my system:
OS X 10.7.5 (Lion)
Ruby: 1.9.3p194
Rails: 3.2.13
Platform: x86_64-darwin11.4.0

@ignisf
Collaborator
ignisf commented May 20, 2013

oh... I see.. I suspect that gyp (the "build system" for libv8) requires python 2.[67] and there is no binary version of 3.11.8.17 for the x86_64-darwin11 platform.. You can either try again after updating python, or try with the 3.11.8.13 version that has a binary for darwin11. I suggest updating your python though... :)

@robertquinn

@ignisf, I hate to keep bugging you, but updating python is giving me a lot of trouble as I am very new to all this and you appear to have much experience in the matter.

I went to http://www.python.org/download/releases/3.3.2/ and downloaded this:
(Mac OS X 64-bit/32-bit Installer (3.3.2) for Mac OS X 10.6 and later 2.)

Upon completion of the download, I ran:
gem install libv8 --version 3.11.8.17

Yet, I still received the same error. I noticed the output still said:
"Using Python 2.5.4"

Despite downloading a newer python version, it is not being used. So how do I change the version of python that the "gem" command uses? I googled and discovered "virtualenv," which appears to be a good python manager, however I am a bit at a dead end now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.