0

while installing therubyracer along with Ruby 2.0.0.p0 and Rails 4.0, i get the following error

ERROR:  While executing gem ... (NoMethodError)
    undefined method `size' for nil:NilClass

If I install same gem in using bundle install then I get dependent gem error see below log.

NoMethodError: undefined method `size' for nil:NilClass
An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before bundling.

Please find the link for GIT which i was trying to install https://github.com/niquola/angularjs-on-rails

Rameshwar Vyevhare
  • 2,699
  • 2
  • 28
  • 34
  • always post the whole stacktrace or link to it in a gist or whatever. – phoet Oct 09 '13 at 11:05
  • and did you try to install libv8 before? What operating system, and do you have node.js installed? – Doon Oct 09 '13 at 11:21
  • Please refer this http://stackoverflow.com/questions/9036105/bundle-install-error-in-installing-libv8-3-3-10-4-on-rails-running-on-lion – Jenorish Oct 09 '13 at 13:03

1 Answers1

3

I ran to the same problem today. And got it solved. I'm using Lubuntu 13.04, RVM and Ruby 1.9.3 instead.

It could be that your platform is not in the supported list of libv8, which is used by rubyracer, and the gem should be compiled by yourself.

Straight from: https://github.com/cowboyd/libv8

Get libv8 source from git, compile it and build gem from:

git clone git://github.com/cowboyd/libv8.git
cd libv8
bundle install
bundle exec rake checkout
bundle exec rake compile
bundle exec rake build

Install gem:

gem install ./pkg/libv8-3.16.14.3.gem

I still got an error when executed "bundle update" on my project folder, because gem didn't seem to be copied to my bundle gem cache.

Bundler::GemspecError: Could not read gem at /home/devmachine/.rvm/gems/ruby-1.9.3-p448/cache/libv8-3.16.14.3.gem. It may be corrupted.
An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue.
Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before bundling.

So I copied it to this folder before I ran "bundle update" again:

cp /home/devmachine/Downloads/libv8/pkg/libv8-3.16.14.3.gem /home/devmachine/.rvm/gems/ruby-1.9.3-p448/cache

Keep in mind that you should have following packages installed before performing compilation:

  • git
  • git-svn
  • libv8-dev
  • python
  • g++

I hope it helps.

- = Better solution = -

Actually a case of RTFM.

You dont have to build your own gem with native extension. You just have to have v8 library present in your system. After that you can configure bundler to use native v8. For that you should install V8 engine on your system.

# Get Google v8 engine from git
git clone git://github.com/v8/v8.git v8 && cd v8
# Install GYP
make dependencies
# I had problems with warnings and strict aliasing. So I ignored and switched them off.
make native werror=no strictaliasing=off

Now you should be able to use v8 from system:

bundle config build.libv8 --with-system-v8

After this command you can continue using usual "bundle install"..

- = Suggested solution = -

Forget v8 and use Node.js instead:

wget http://nodejs.org/dist/node-latest.tar.gz
tar zxvf node-latest.tar.gz
# cd into extracted directory (e.g. cd node-v0.10.14)
make
make install

Remove "therubyracer" dependency from your project Gemfile.

Community
  • 1
  • 1
vellotis
  • 829
  • 1
  • 12
  • 26
  • If somebody fails with this procedure, give a look on following http://appsintheopen.com/posts/18-installing-the-libv8-ruby-gem-on-centos-5-8 – vellotis Oct 21 '13 at 21:03
  • It also works on mac 10.9 Mavericks slightly modified. Thanks! – MacTeo Oct 22 '13 at 09:10