JRuby: Nokogiri 1.6 Failing To Install & Bundler Attempting To Install Already Met Dependency - ruby

I am getting an error on jruby (linux) when installing the
"trinidad_diagnostics_extension" gem (though this question is not about trinidad). A chain of dependencies is
generating the error:
"trinidad_diagnostics_extension" depends on "jruby-lint >= 0.3.0"
"jruby-lint >= 0.3.0" in turn depends on "nokogiri >= 1.5.0.beta.4"
Before attempting to install "trinidad_diagnostics_extension", the relevant
part of my gem list looks like this:
$gem list
nokogiri (1.5.9 java)
jruby-lint (0.4.1)
As you can see, the needed dependencies seem already to be met. Nonetheless,
after adding gem 'trinidad_diagnostics_extension' to my Gemfile and then
running jruby -S bundle install, the bundler attempts to install nokogiri
(1.6.0.rc1), and during this installation fails with the following error:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
... bunch of omitted output here
nokogiri.c:42:18: fatal error: util.h: No such file or directory
compilation terminated.
make: *** [nokogiri.o] Error 1
Gem files will remain installed in /home/jg/.rvm/gems/jruby-1.7.3/gems/nokogiri-1.6.0.rc1 for inspection.
Results logged to /home/jg/.rvm/gems/jruby-1.7.3/gems/nokogiri-1.6.0.rc1/ext/nokogiri/gem_make.out
Why is bundler trying to install nokogiri when that dependency is already met?
How can I fix this? Successfully installing nokogiri 1.6 or making the trinidad extension aware that 1.6 does not need to be installed would both be fine solutions.
In case it's relevant I have JRUBY_OPTS=-Xcext.enabled=true
UPDATE
I was able to get it work by first installing the gem outside of bundler:
jruby -S gem install trinidad_diagnostics_extension
And then the bundle command worked fine, since it was already installed. So I got it working by I am still confused by why I had to install it outside of bundler and why that would matter, and would like some insight if anyone has it.

1.6.0.pre1 does not exist for the Java platform, for uninteresting reasons. That said, you should only get prereleases if you specifically ask for them.

Related

Trying to put bundle in PATH

I'm working on a Ruby project that requires the use of a few gems. I'm a bit confused, since I thought I already had bundler installed on my Mac. I tried installing it just now and got the following error:
Leias-MacBook-Pro:spec leia$ gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
I then tried using --user-install, a trick I picked up from browsing Stack Overflow.
Leias-MacBook-Pro:spec leia$ gem install bundler --user-install
WARNING: You don't have /Users/leia/.gem/ruby/2.3.0/bin in your PATH, gem executables will not run.
Successfully installed bundler-2.0.2
Parsing documentation for bundler-2.0.2
Done installing documentation for bundler after 5 seconds
1 gem installed
Now, I kind of need the gem executables to run, so I opened my .bash_profile and dropped the following code in:
export PATH=/Users/leia/.gem/ruby/2.3.0/bin:$PATH
But no matter how I try to fix it, bundle still won't run. The gem I'm installing is rspec, and I definitely need to be able to run those executables. Am I doing something wrong here? I've tried to follow tutorials and Google similar issues, but I can't figure out what the problem is. Any pointers or suggestions?

TheRubyRacer error while installing Beef in Windows 10 - 64 bit

I am trying to install Beef in a WIndows 10 - 64 bit PC.
I followed the instructions provided in the following link:
https://github.com/beefproject/beef/blob/master/INSTALL.txt
But I keep getting this error:
An error occurred while installing therubyracer (0.11.4), and Bundler
cannot continue. Make sure that gem install therubyracer -v '0.11.3'
succeeds before bundling.
I drilled down a bit & found that the installed version of therubyracer is 0.11.0beta1 x86-mingw32 whereas the installer is searching for version 0.11.3
In the link provided above, the following lines are mentioned in line 38:
Finally, edit beef's gem lock file by replacing the required ruby racer version with the version downloaded from the link above.
But when I do that I get this error:
Your lockfile is unreadable. Run rm Gemfile.lock and then bundle
install to generate a new lockfile.
Can anyone please help me out with this?
Doing what the error message suggests should do the trick. Just remove existing Gemfile.lock in beef project and then run bundle install command once again.
The Gemfile has the the following check:
# Windows support
if RUBY_PLATFORM.downcase.include?('mswin') || RUBY_PLATFORM.downcase.include?('mingw')
# make sure you install this gem following https://github.com/eakmotion/therubyracer_for_windows
gem 'therubyracer', '~> 0.11.0beta1'
elsif !RUBY_PLATFORM.downcase.include?('darwin')
gem 'therubyracer', '0.11.3'
end
So, it will generate a new Gemfile.lock file specific to Windows. The one in the repo is for Ubuntu/Debian.
Even after trying out the solution given by Uzbekjon, I wasn't able to get past the error. Beef requires a javascript runtime for the login page to properly show up. As suggested in the post given here, I got a workaround by installing Node.js

Can not install vagrant-librarian-chef on Window?

I am install vagrant-librarian-chef in window 7, but it appear this error:
Installing the 'vagrant-librarian-chef' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
An error occurred while installing chef (12.8.1), and Bundler cannot continue.
Make sure that gem install chef -v '12.8.1' succeeds before bundling.
Warning: this Gemfile contains multiple primary sources. Using source more than once without a block is a security risk, and may result in installing unexpected gems. To resolve this warning, use a block to indicate which gems should come from the secondary source. To upgrade this warning to an error, run bundle config disable_multisource true.Errno::ENOENT: No such file or directory # dir_s_mkdir - C:/Users/tuan/.vagrant.d/gems/gems/chef-12.8.1-universal-mingw32/acceptance/top-cookbooks/test_run/learn-the-basics-ubuntu/cookbooks/learn-the-basics-ubuntu/.kitchen/kitchen-vagrant/kitchen-learn-the-basics-ubuntu-learn-the-basics-ubuntu-default-ubuntu-1404
Pls help me fix that.
Thanks all!
I was having a similar issue when using the 'ohai' ruby gem. I tried running gem install chef -v '12.8.1' but received an error. I fixed my problem by adding
gem 'chef-config', '~>12.7.2'
to my gemfile.
I looked at my gem dependency tree (gem dependency) and noticed the 'ohai' gem was trying to use chef-config 12.8, so I pinned it to an earlier version.

Building gems with jRuby cext on Heroku

I am trying to use the JRuby Heroku buildpack (https://github.com/jruby/heroku-buildpack-jruby) to run a simple test application.
However, it seems that gems with C extensions cannot be compiled. For example, when doing a "git push heroku", the gems without C extensions are installed successfully, but then...
Using activerecord (3.1.3)
Using activeresource (3.1.3)
Using bouncy-castle-java (1.5.0146.1)
Using bson (1.7.0)
Installing bson_ext (1.7.0) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/tmp/build_10vcxrs9ayvxf/jruby/bin/jruby extconf.rb
NotImplementedError: C extension support is not enabled. Pass -Xcext.enabled=true to JRuby or set JRUBY_OPTS or modify .jrubyrc to enable.
(root) at /tmp/build_10vcxrs9ayvxf/jruby/lib/ruby/shared/mkmf.rb:8
require at org/jruby/RubyKernel.java:1019
(root) at /tmp/build_10vcxrs9ayvxf/jruby/lib/ruby/shared/rubygems/custom_require.rb:1
(root) at extconf.rb:1
Gem files will remain installed in /tmp/build_10vcxrs9ayvxf/vendor/bundle/jruby/1.9/gems/bson_ext-1.7.0 for inspection.
Results logged to /tmp/build_10vcxrs9ayvxf/vendor/bundle/jruby/1.9/gems/bson_ext-1.7.0/ext/cbson/gem_make.out
An error occurred while installing bson_ext (1.7.0), and Bundler cannot continue.
Make sure that `gem install bson_ext -v '1.7.0'` succeeds before bundling.
Dependencies installed
Upon seeing the advice given above, I then went and created a modified version of the JRuby buildpack, which can be found here: https://github.com/grahamdaley/heroku-buildpack-jruby-cext
The only difference between this buildpack and the original one is that I have now set JRUBY_OPTS as follows:
JRUBY_OPTS="--1.9 -Xcext.enabled=true -J-Xmx400m"
However, this doesn't seem to have made any difference at all and I'm still getting the same error.
Any hints? Is it possible (and would help) to add a .jrubyrc file somewhere in the buildpack?
you should simply configure JRUBY_OPTS instead of a setting up a customized build-pack :
heroku config:add JRUBY_OPTS="--1.9 -Xcext.enabled=true -J-Xmx400m"
that being said - it's probably a bad idea to use C-ext with JRuby
you definitely do not need C-ext due to BSON gem (it has a native JRuby version) - editing your Gemfile and/or re-bundling (rm Gemfile.lock && bundle) locally with JRuby will likely solve this for you ...
Install without C extention
On way is just install json without the C extension. Is possible because the C extension is optional. Attention this is slower than bson with C extension this is may a problem for you. source
Ruby — with optional C extension
Open a Ticket
Almost any gem - even those with native dependencies - can be installed using Bundler. If there’s a specific gem that won’t install on Heroku, please submit a support ticket.
So you can open a support ticket here

Error installing gems that use native extensions on Ubuntu, Ruby 1.9.2 via RVM

I get an error while trying to install the ffi gem:
~ - 16:54>gem i ffi
Building native extensions. This could take a while...
ERROR: Error installing ffi:
ERROR: Failed to build gem native extension.
rake RUBYARCHDIR=/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/lib RUBYLIBDIR=/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/lib
/home/mdemare/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems.rb:370:in `bin_path': can't find gem rake ([">= 0"]) with executable rake (Gem::GemNotFoundException)
from /home/mdemare/.rvm/gems/ruby-1.9.2-p136/bin/rake:19:in `<main>'
Gem files will remain installed in /home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6 for inspection.
Results logged to /home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/gen/gem_make.out
I'm getting frequent errors of all kinds while installing gems with native extensions, so I assume that there's something broken with my Ubuntu installation, but I've no idea what. I'll post any information you need to diagnose the problem.
EDIT: When I cd to the ffi gem (mentioned in the second but last line), and run the rake line in line 6, I get "Could not find RubyGem rake-compiler".
After gem i rake-compiler, and run rake again, I get this:
configure: error: source directory already configured; run "make distclean" there first
make: *** [/home/mdemare/.rvm/gems/ruby-1.9.2-p136/gems/ffi-1.0.6/build/x86_64-linux/ffi_c/1.9.2/libffi/.libs/libffi_convenience.a] Error 1
rake aborted!
Command failed with status (2): [make...]
Update:
These are my rake gemspecs:
~ - 10:59>find ~/.rvm/ -name 'rake-0.8.7.gemspec'
~/.rvm/gems/ruby-1.9.2-p136/specifications/rake-0.8.7.gemspec
~/.rvm/gems/ruby-1.9.2-p136#global/specifications/rake-0.8.7.gemspec
~/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/gems/1.9.1/specifications/rake-0.8.7.gemspec
The last one is where gem looks, but that gemspec is different from the first one, and doesn't include the executable. Copying the long one doesn't quite solve the problem though - I get a file not found for the rake executable.
This caused me a ton of aggravation at the Boston Hack Day when trying to install Vagrant (for which FFI is a dependency). I ended up wasting so much time that I switched machines to work around the problem.
After the fact, I found a hack that works (although I'm sure there's a better solution). The file that the error message is complaining about
~/.rvm/gems/ruby-1.9.2-p180/bin/rake
differs from other similar copies in that it's missing path setup stuff at the head, so I copied these lines from one of the files that had them:
[genericized per #danv's answer below. Thanks for the improvement!]
ENV['GEM_HOME']=ENV['GEM_HOME'] || '~/.rvm/gems/ruby-1.9.2-p180'
ENV['GEM_PATH']=ENV['GEM_PATH'] || '~/.rvm/gems/ruby-1.9.2-p180:~/.rvm/gems/ruby-1.9.2-p180#global'
ENV['PATH']='~/.rvm/gems/ruby-1.9.2-p180/bin:~/.rvm/gems/ruby-1.9.2-p180#global/bin:~/.rvm/rubies/ruby-1.9.2-p180/bin:' + ENV['PATH']
That fixed it for me. This was a new Ubuntu 10.10 install with no default Ruby installation (which could be part of the problem) and Ruby 1.9.2 installed using RVM. Lots of other gems installed fine, including those requiring native compilation, so the problem is something specific to FFI.
I had a similar problem, and a workaround at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=529663 helped me.
In short, try to install the gem with:
$ rake=/usr/bin/rake gem install ffi
#Tom Morris - Tried your method and it worked fine.
I inserted your path specs (modified - see below) into ~/.rvm/gems/ruby-1.9.2-p180/bin/rake after line 12.
I modified the path specs so they are generic using ~ for the user home:
ENV['GEM_HOME']=ENV['GEM_HOME'] || "~/.rvm/gems/ruby-1.9.2-p180"
ENV['GEM_PATH']=ENV['GEM_PATH'] || "~/.rvm/gems/ruby-1.9.2-p180:~/.rvm/gems/ruby-1.9.2-p180#global"
ENV['PATH']="~/.rvm/gems/ruby-1.9.2-p180/bin:~/.rvm/gems/ruby-1.9.2-p180#global/bin:~/.rvm/rubies/ruby-1.9.2-p180/bin:"+ ENV['PATH']
Thanks for finding this fix!
Thanks #Tim Morris and #danv, your answers / comments helped. I adjusted for my setup, which is based more towards a superuser environment. Now this is what /usr/local/rvm/gems/ruby-1.9.2-p180/bin/rake looks like on my server:
require 'rubygems'
version = ">= 0"
ENV['GEM_HOME']=ENV['GEM_HOME'] || "/usr/local/rvm/gems/ruby-1.9.2-p180"
ENV['GEM_PATH']=ENV['GEM_PATH'] || "/usr/local/rvm/gems/ruby-1.9.2-p180:/usr/local/rvm/gems/ruby-1.9.2-p180#global"
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end
gem 'rake', version
load Gem.bin_path('rake', 'rake', version)
The installer attempts to run rake but fails when it isn't found:
can't find gem rake ([">= 0"]) with executable rake (Gem::GemNotFoundException)
You need to install the rake gem: gem install rake.

Resources