Skip to content

Instantly share code, notes, and snippets.

@andreaseger
Created January 21, 2013 14:22
Show Gist options
  • Save andreaseger/4586408 to your computer and use it in GitHub Desktop.
Save andreaseger/4586408 to your computer and use it in GitHub Desktop.
bundler provides gems not matching the current platform
# A sample Gemfile
source "https://rubygems.org"
gem "jrb-libsvm", git: 'git://github.com/sch1zo/jrb-libsvm.git',
require: 'libsvm', platforms: :jruby
gem "rb-libsvm", git: 'git://github.com/sch1zo/rb-libsvm.git', branch: 'custom_stuff',
require: 'libsvm', platforms: :ruby
GIT
remote: git://github.com/sch1zo/jrb-libsvm.git
revision: e7fcdb1333f86d51a3ae961d46b09381ce9c5eba
specs:
jrb-libsvm (0.0.1)
GIT
remote: git://github.com/sch1zo/rb-libsvm.git
revision: 1e22ffe052bb2b157b3c773443edcf46baeb3406
branch: custom_stuff
specs:
rb-libsvm (1.0.11)
GEM
remote: https://rubygems.org/
specs:
PLATFORMS
java
ruby
DEPENDENCIES
jrb-libsvm!
rb-libsvm!
$> rvm --create use jruby-1.7.2@platforms-test
$> bundle install
Fetching git://github.com/sch1zo/jrb-libsvm.git
Fetching git://github.com/sch1zo/rb-libsvm.git
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Using jrb-libsvm (0.0.1) from git://github.com/sch1zo/jrb-libsvm.git (at master)
Using bundler (1.2.3)
$> bundle list
Gems included by the bundle:
* bundler (1.2.3)
* jrb-libsvm (0.0.1 e7fcdb1)
$> bundle exec ruby platforms.rb
Run options: --seed 27834
# Running tests:
.....
Finished tests in 0.021000s, 238.0952 tests/s, 238.0952 assertions/s.
5 tests, 5 assertions, 0 failures, 0 errors, 0 skips
$> rvm --create use ruby-1.9.3-p362@platforms-test
$> bundle install
Fetching git://github.com/sch1zo/rb-libsvm.git
remote: Counting objects: 713, done.
remote: Compressing objects: 100% (357/357), done.
remote: Total 713 (delta 353), reused 656 (delta 297)
Receiving objects: 100% (713/713), 130.33 KiB, done.
Resolving deltas: 100% (353/353), done.
Fetching git://github.com/sch1zo/jrb-libsvm.git
remote: Counting objects: 109, done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 109 (delta 41), reused 94 (delta 26)
Receiving objects: 100% (109/109), 150.00 KiB, done.
Resolving deltas: 100% (41/41), done.
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Using rb-libsvm (1.0.11) from git://github.com/sch1zo/rb-libsvm.git (at custom_stuff) with native extensions
Using bundler (1.2.3)
$> bundle list
Gems included by the bundle:
* bundler (1.2.3)
* rb-libsvm (1.0.11 1e22ffe)
$> bundle exec ruby platforms.rb
/home/USER/.rvm/gems/ruby-1.9.3-p362@platforms-test/bundler/gems/jrb-libsvm-e7fcdb1333f8/lib/libsvm/version.rb:2: warning: already initialized constant VERSION
/home/USER/.rvm/gems/ruby-1.9.3-p362@platforms-test/bundler/gems/jrb-libsvm-e7fcdb1333f8/lib/libsvm.rb:2:in `require': cannot load such file -- java (LoadError)
from /home/USER/.rvm/gems/ruby-1.9.3-p362@platforms-test/bundler/gems/jrb-libsvm-e7fcdb1333f8/lib/libsvm.rb:2:in `<top (required)>'
from /home/USER/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
from /home/USER/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /home/USER/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
from /home/USER/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
from /home/USER/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
from /home/USER/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
from /home/USER/.rvm/gems/ruby-1.9.3-p362@global/gems/bundler-1.2.3/lib/bundler.rb:128:in `require'
from platforms.rb:3:in `<main>'
#after removing line 4 and 5 from Gemfile
$> bundle install
Using rb-libsvm (1.0.11) from git://github.com/sch1zo/rb-libsvm.git (at custom_stuff) with native extensions
Using bundler (1.2.3)
$> bundle exec ruby platforms.rb
Run options: --seed 11699
# Running tests:
.....
Finished tests in 0.000597s, 8369.1113 tests/s, 8369.1113 assertions/s.
5 tests, 5 assertions, 0 failures, 0 errors, 0 skips
require 'bundler'
Bundler.setup
Bundler.require(:default)
require 'minitest/autorun'
describe 'platforms-test' do
it 'should have a libsvm' do
assert Object.const_defined?('Libsvm')
end
%w(Model Node SvmParameter Problem).each do |klass|
it "should define the #{klass} class for libsvm" do
assert Libsvm.const_defined?(klass)
end
end
end
@andreaseger
Copy link
Author

both rb-libsvm and jrb-libsvm provide the same interface, one uses the C version and the other the Java version of the libary.

running the script in jruby works as expected, but when i switch to MRI bundler keeps loading the java version of the gem which obviously does not work

@andreaseger
Copy link
Author

removing rubygems-bundler doesn't helps -> same results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment