2

I'm trying to install Jruby on ROR for my application. Used commands from its documentation https://devcenter.heroku.com/articles/moving-an-existing-rails-app-to-run-on-jruby . While bundle installation got the following errors

  1. Your Ruby engine is ruby, but your Gemfile specified jruby
  2. Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

Furthermore certain gems are not installed successfully, shows error like 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.

Not able to find the issue. Would somebody help with this ?

Gemfile :

ruby '1.9.3', :engine => 'jruby', :engine_version => '1.7.9'
gem "rake"
gem "rails", "3.2.16"
gem 'foreigner'
gem 'activerecord-jdbcpostgresql-adapter'
gem 'jruby'
gem 'airbrake'
gem "spreadsheet", "~> 0.9.0"
gem 'paperclip'
gem 'aws'
gem 'aws-sdk'
gem 'aws-s3', :require => nil
gem 'authlogic'
gem 'execjs'
gem 'mail', :require => nil
gem 'fastercsv', :require => nil
gem "rspec-rails"
gem 'rubyzip', :require => nil
gem 'test-unit'
gem 'typhoeus'
gem 'thin'
gem 'therubyracer'
gem 'useragent'
gem 'will_paginate'
gem 'therubyracer'
gem 'libv8', '3.16.14.3'
Sap
  • 235
  • 1
  • 15

2 Answers2

3

You can't use 'therubyracer' and 'libv8' gems with JRuby.

Short answer:

Use 'therubyrhino' gem instead (https://github.com/cowboyd/therubyrhino)

Explanation:

There are some gems that can't be used under JRuby, because they are using native (C) extensions - here is a list: https://github.com/jruby/jruby/wiki/C-Extension-Alternatives

cthulhu
  • 3,749
  • 1
  • 21
  • 25
2

Make sure to install all below libraries, before installing Ruby/RVM.

sudo apt-get install zlib1g zlib1g-dev build-essential openssl libssl-dev libmysqlclient18 libmysqlclient-dev libyaml-dev

Before JRuby installation.

sudo apt-get install ruby-dev
sudo apt-get install build-essential g++
rvm install jruby

Don't specify Jruby version, default you will get latest version.

Pravin Mishra
  • 8,298
  • 4
  • 36
  • 49
  • Finished with installation and i bundle installed the gems and got the same error again "Installing libv8 (3.16.14.3) Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension." – Sap Dec 19 '13 at 07:10
  • Used this command "gem install libv8 -v '3.16.14.3'" and retried. Still getting error ! Why does that happen for this gem ? – Sap Dec 19 '13 at 07:12
  • have a look http://stackoverflow.com/questions/19673714/rails-gem-install-error-error-installing-libv8-error-failed-to-build-gem-nati – Pravin Mishra Dec 19 '13 at 10:22