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
Your Ruby engine is ruby, but your Gemfile specified jruby
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'
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
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.
Related
Having not touched my Rails application for around a year, I decided to try to get the application up and running but am stuck because what I believe to be a dependency somewhere in my Gemfile. I have included it at the bottom.
My issue is that I am running into the error:
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
extconf.rb:10:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:10:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:11:in `<main>': Use RbConfig instead of obsolete and deprecated Config.
checking for libxml/parser.h... yes
checking for libxslt/xslt.h... yes
checking for libexslt/exslt.h... yes
checking for iconv_open() in iconv.h... no
checking for iconv_open() in -liconv... yes
checking for xmlParseDoc() in -lxml2... no
-----
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
An error occurred while installing nokogiri (1.5.2), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.5.2'` succeeds before bundling.
However upon trying to install Nokogiri separately, I found that I am able to install -v 1.6.3.1 without error. I know that libxml2, libiconv, etc., are installed in my computer but am unsure if the versions match with what Nokogiri 1.5.2 is expecting. Also, I tried using the xcode-select --install approach but to no avail.
So my questions are:
How can I update my gemfile to use Nokogiri 1.6.3.1, which I am able to install. When I don't know which gem is using it as a dependecy, is there a way to look that up?
Without removing each gem one by one, is there a way to figure out/remove Nokogiri all together?
If there is no way to do #1 or #2, then how can I successfully install Nokogiri 1.5.2?
Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.2.8'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'compass-rails'
gem 'compass-960-plugin'
gem 'uglifier', '1.2.3'
gem 'chosen-rails'
gem 'bbcoder'
gem 'sanitize'
gem 'devise'
gem 'possessive'
gem 'err_merchant', :git => "git://github.com/iindigo/err_merchant.git"
gem 'impressionist'
#gem 'kaminari'
#gem 'bcrypt-ruby', '3.0.1' to use rails has_secure_passwordv
group :development do
gem 'sqlite3', '1.3.5'
gem 'annotate', '2.5.0'
gem 'rails-erd'
gem 'rack-mini-profiler'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
end
gem 'jquery-rails'
gem 'rails_tokeninput', '1.6.1.rc1'
gem 'selectivizr-rails'
gem 'friendly_id'
gem 'haml'
gem 'browser'
group :test, :development do
gem 'rspec-rails', '2.8.1'
gem 'spork', '0.9.0'
end
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '1.4.0'
end
group :production do
gem 'sqlite3', '1.3.5'
# gem 'therubyracer'
end
sudo apt-get install ruby-dev libxml2-dev libxslt-dev and then try running bundle install again.
I figured out that by doing the command bundle update "gemnamehere" it was possible to get a list of the dependencies of each gem in the case of failure to update.
This in turn allowed me to figure out which gems I needed to change in-order to get Nokogiri to update.
When I run bundle install in my Rails 4 application I get the following error:
An error occurred while installing nokogiri (1.6.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling.
I'm using rvm and when I run gem install nokogiri -v '1.6.1' it works well. Moreover, when I run gem list I see nokogiri 1.6.1 installed, it's just that bundle install in my app does not work.
By the way, it's happening only when I add the impressionist gem to my Gemfile, but I guess it's just a dependency.
More info: I have followed, just in case, the instructions here, and everything worked well.
Any ideas? TIA
EDIT 1: The full error is:
Installing nokogiri (1.6.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/sonxurxo/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
/Users/sonxurxo/.rvm/rubies/ruby-1.9.3-p448/bin/ruby: invalid option -P (-h will show valid options) (RuntimeError)
Gem files will remain installed in /Users/sonxurxo/Documents/workspace/Smart Promo/RubyOnRails/vendor/bundle/gems/nokogiri-1.6.1 for inspection.
Results logged to /Users/sonxurxo/Documents/workspace/Smart Promo/RubyOnRails/vendor/bundle/gems/nokogiri-1.6.1/ext/nokogiri/gem_make.out
An error occurred while installing nokogiri (1.6.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling.
EDIT 2: I'm on Mac OS X Mavericks, with XCode and developer tools successfully installed
EDIT 3: My Gemfile:
source 'https://rubygems.org'
# gem 'rails', '3.2.1'
gem 'rails', '4.0.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'authlogic'
gem 'acl9'
gem 'recaptcha'
gem 'omniauth-facebook'
gem 'omniauth-twitter'
gem "paperclip", ">= 3.4.1"
gem 'kaminari'
gem 'activerecord-session_store'
gem 'rpush'
gem 'mysql2'
gem 'twitter'
gem 'gmaps4rails'
gem 'gon'
gem 'flexslider'
gem 'jquery-ui-rails'
gem "breadcrumbs_on_rails"
gem "jquery-fileupload-rails"
gem 'gettext_i18n_rails'
gem 'gettext', '>=3.0.2', :require => false, :group => :development
gem 'thinking-sphinx'
gem 'delayed_job_active_record'
gem 'daemons'
gem 'ts-delayed-delta', '~> 2.0.0', :require => 'thinking_sphinx/deltas/delayed_delta'
gem 'geocoder'
gem 'i18n'
gem 'globalize', '~> 4.0.0'
gem 'batch_translations'
gem 'countries'
gem 'country_select'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 4.0.0'
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
end
gem 'jquery-rails'
gem 'impressionist'
EDIT 4: Output for gem list nokogiri:
*** LOCAL GEMS ***
nokogiri (1.6.1, 1.5.9)
I think I solved this.
I say think because it seems to be related with a misconfiguration concerning rvm and bundler.
bundler was installing my gems in vendor/bundle, and not using those from the rvm gemset. What I did was to tell bundler to use those gems from rvm, and then, since nokogiri was already installed, it worked.
Thank everyone for your comments and answers.
Impressionist has the following dependency:
s.add_dependency 'nokogiri', '~> 1.5'
Do you need the latest version of nokogiri or can you live with this version as well?
With 'bundle install --deployment' it won't work if you are below a directory with spaces in its name. Replacing the spaces with underscores fixed a similar problem for me. See https://github.com/bundler/bundler/issues/3020
I'm getting this error when I try to bundle install
Bundler::GemspecError: Could not read gem at /home/theareba/.rvm/gems/ruby-2.0.0-p353/cache/nokogiri-1.6.1.gem. It may be corrupted.
An error occurred while installing nokogiri (1.6.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.6.1'` succeeds before bundling.
I've tried removing nokogiri in the cache and bundle installing again in vain.
Here's my gemfile
source 'https://rubygems.org'
gem 'rails', '4.0.0'
ruby "2.0.0"
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-1-stable'
gem 'spree', github: 'spree/spree', branch: '2-1-stable'
gem 'bootstrap-sass', '2.3.2.0'
gem 'sass-rails'
gem 'uglifier'
gem 'coffee-rails'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder'
group :development, :test do
gem 'turn', :require => false
gem 'sqlite3'
gem 'taps', :require => false
gem 'rspec-rails'
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor'
end
UPDATE
Error that occurs when I run gem install nokogiri -v '1.6.0'
Fetching: mini_portile-0.5.2.gem (100%)
Fetching: nokogiri-1.6.0.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:5:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/nokogiri-1.6.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out
Note: I've installed both libxslt1-dev and libxml2-dev that are requirements in nokogiri installation.
I've also tried gem install nokogiri -v '1.6.1' but it still fails. I've installed nokogiri -v 1.5.0 in another app so I tried it in this app and got the error that spree requires nokogiri version 1.6.0 or greater. I'm I missing something?
So here's what solved my problem. I created a new gemset i.e
rvm gemset create nokogiri
rvm use ruby-2.0.0-p353#nokogiri
Note: I'm using rvm and ruby 2.0.0. Then I made sure I've got necessary lib installed by running
sudo apt-get install libxml2-dev libxslt-dev
The libraries happened to be already installed. Then I installed nokogiri
gem install nokogiri -v '1.6.1'
It installed successfully. And finally ran bundle install to get all my gems. Hope this helps anyone having the same issue.
Check the RVM gemset. I fixed it by restoring the gemset. If you try upgrading to 4.0.2? I used Nokogiri 1.6.1 with Ruby 2.0.0 and Rails 4.0.2
try this
sudo apt-get install ruby-dev
sudo apt-get install libxml2 libxml2-dev libxslt1-dev
and reinstall nokogiri
sudo gem install nokogiri
When I do a
bundle install --path vendor/bundle
on my app, I get the following error.
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (= 1.0.18) java
Current Bundler version:
bundler (1.1.5)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
My gem list shows that I have the mentioned gem
*** LOCAL GEMS ***
bundler (1.1.5, 1.0.22, 1.0.18)
My gem file looks like this
gem "rake", "0.9.2"
gem "activerecord-jdbc-adapter", "1.2.0"
gem "activerecord-jdbcmysql-adapter", "1.2.0"
gem "acts_as_tree", "0.1.1"
gem "bundler", "1.0.18", :require => "bundler"
gem "database_cleaner", "0.6.7"
gem "jdbc-mysql", "5.1.13"
gem "jruby-jars", "1.6.2"
gem "jruby-rack", "1.1.3"
gem "jruby-openssl", "0.7.4"
gem "net-scp", "1.0.4"
gem "net-ssh", "2.2.1"
gem 'uuidtools', "2.1.1"
gem 'nokogiri', "1.5.0"
How do I fix this? I use jruby-1.6.3 and rails 3.0.10.
Have you tried to
- either remove bundler from the gemfile
- set it to the bundler version to use to bundle it
- or vice versa: use the bundler version to bundle that you require in the gem file
but as Anthony said, do you have a reason for including it in the Gemfile ?
I'm trying to open by my rails console in my newsly created app, but I can't connect to a database. It looks like there might be a problem with sqlite3-1.3.3 vs 1.3.4
$ rails c
/Library/Ruby/Gems/1.8/gems/activerecord-3.1.1/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `establish_connection': Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (can't activate sqlite3 (~> 1.3.4, runtime), already activated sqlite3-1.3.3. Make sure all dependencies are added to Gemfile.) (RuntimeError)
Install
$sudo gem install
ERROR: could not find gem activerecord-sqlite3-adapter locally or in a repository
What gems I have installed
$gem list
*** LOCAL GEMS ***
...
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3, 1.3.2, 1.2.5)
I'm using rails 3.1.1
EDIT:
Here is my gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'json'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
Running bundle install produces this
$sudo bundle install
using rake (0.9.2.2)
...
Using sqlite3 (1.3.3)
Your bundle is complete! Use bundle show [gemname] to see where a bundled gem is installed.
$ bundle show sqlite3
/Library/Ruby/Gems/1.8/gems/sqlite3-1.3.3
You're using Rails 3.1, which uses bundler to manage gems.
Add gem 'sqlite3' to your Gemfile
run bundle form the command line
This will install the gems your app needs. You should then be able to launch the console.
I've seen similar situations in the past because of missing/bad shared libraries. Gems install ruby code, native bindings to libraries, but they do not install the external libraries themselves.
The dependency for sqlite on Ubuntu, for example, is libsqlite3-dev.
$ sudo apt-get install libsqlite3-dev
For OSX:
Install sqlite3 on mac osx?