5

My goal is to use libmspack. It depends on ffi-compiler, I've forked ffi-compiler, to add some custom code, and I want libmspack to use my modified version. I have a simple Gemfile:

source 'http://rubygems.org'

gem 'ffi-compiler', :github =>'survili/ffi-compiler'
gem 'libmspack'

When running 'bundle install', installation of 'ffi-compiler' completes fine, but 'libmspack' install fails with an error that it can't find 'ffi-compiler'.(LoadError: cannot load such file -- ffi-compiler/compile_task)

I've noticed that if I remove 'libmspack' from Gemfile, and try to install it using 'bundle exec install libmspack', it works fine.

Can someone explain, what is the correct way to achieve my goal, causing libmspack to use custom ffi-compiler gem ?

I've found this SO post, which asks the same, but has no answer: Gem::LoadError when using a git repo in Gemfile

Thank you in advance

------ OUTPUT of bundle(empty gemset using RVM) -------

jackju at macbook-air  ~/tmp/delme1
$ rvm use 2.1.1@stackoverproblem --create
ruby-2.1.1 - #gemset created /home/jackju/.rvm/gems/ruby-2.1.1@stackoverproblem
ruby-2.1.1 - #generating stackoverproblem wrappers...........
Using /home/jackju/.rvm/gems/ruby-2.1.1 with gemset stackoverproblem
jackju at macbook-air  ~/tmp/delme1
$ rvm current
ruby-2.1.1@stackoverproblem
jackju at macbook-air  ~/tmp/delme1
$ vim Gemfile

[1]+  Stopped                 vim Gemfile
jackju at macbook-air  ~/tmp/delme1
$ rvm current
ruby-2.1.1@stackoverproblem
jackju at macbook-air  ~/tmp/delme1
$ gem list

*** LOCAL GEMS ***

bigdecimal (1.2.4)
bundler (1.5.3)
bundler-unload (1.0.2)
executable-hooks (1.3.1)
gem-wrappers (1.2.4)
io-console (0.4.2)
json (1.8.1)
minitest (4.7.5)
psych (2.0.3)
rake (10.1.0)
rdoc (4.1.0)
rubygems-bundler (1.4.2)
rvm (1.11.3.9)
test-unit (2.1.1.0)
jackju at macbook-air  ~/tmp/delme1
$ bundle
Fetching git://github.com/survili/ffi-compiler.git
remote: Reusing existing pack: 260, done.
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 265 (delta 2), reused 0 (delta 0)
Receiving objects: 100% (265/265), 38.59 KiB | 0 bytes/s, done.
Resolving deltas: 100% (116/116), done.
Fetching gem metadata from http://rubygems.org/.........
Fetching additional metadata from http://rubygems.org/..
Resolving dependencies...
Installing rake (10.3.1)
Installing ffi (1.9.3)
Using ffi-compiler (0.1.4) from git://github.com/survili/ffi-compiler.git (at master)

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/jackju/.rvm/rubies/ruby-2.1.1/bin/ruby -rubygems /home/jackju/.rvm/gems/ruby-2.1.1@stackoverproblem/gems/rake-10.3.1/bin/rake RUBYARCHDIR=/home/jackju/.rvm/gems/ruby-2.1.1@stackoverproblem/extensions/x86_64-linux/2.1.0/libmspack-0.0.4 RUBYLIBDIR=/home/jackju/.rvm/gems/ruby-2.1.1@stackoverproblem/extensions/x86_64-linux/2.1.0/libmspack-0.0.4
rake aborted!
LoadError: cannot load such file -- ffi-compiler/compile_task
/home/jackju/.rvm/gems/ruby-2.1.1@stackoverproblem/gems/libmspack-0.0.4/ext/Rakefile:1:in `<top (required)>'
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /home/jackju/.rvm/gems/ruby-2.1.1@stackoverproblem/gems/libmspack-0.0.4 for inspection.
Results logged to /home/jackju/.rvm/gems/ruby-2.1.1@stackoverproblem/extensions/x86_64-linux/2.1.0/libmspack-0.0.4/gem_make.out
An error occurred while installing libmspack (0.0.4), and Bundler cannot
continue.
Make sure that `gem install libmspack -v '0.0.4'` succeeds before bundling.
jackju at macbook-air  ~/tmp/delme1
$ ls
Gemfile
jackju at macbook-air  ~/tmp/delme1
$ 
13
  • Sounds like the fork of ffi-compiler you are using might not be compatible with the version that libmspack is expecting. Maybe you need to fork an earlier version of ffi-compiler for use with libmspack? Apr 23, 2014 at 15:38
  • @GregBurghardt - no, that's not the issue. It is compatible. Apr 24, 2014 at 13:12
  • maybe gem 'ffi-compiler', :github =>'manycolors/ffi-compiler', require: "ffi-compiler" Apr 25, 2014 at 18:02
  • @TyrelRichey - thanks, but it didn't help Apr 27, 2014 at 9:10
  • I might have my five minutes of stupidity right now, but… I cannot seem to find a ffi-compiler fork by manycolors on Github?
    – janfoeh
    Apr 27, 2014 at 9:24

1 Answer 1

2
+50

The problem is missing 'rubygems/tasks' which is found in this gem: https://github.com/postmodern/rubygems-tasks.

I was able to install libmspack on my machine following these steps:

  1. gem install rubygems-tasks

  2. git clone [email protected]:survili/ffi-compiler.git

  3. cd ffi-compiler

  4. rake build gem

  5. gem install pkg/ffi-compiler-0.1.4.gem

  6. gem install libmspack -v '0.0.4'

Successfully installed libmspack-0.0.4 
1 gem installed
7
  • your flow described above works, and I will accept your answer. But I will be very glad, if you can explain why if I add gem 'rubygems-tasks' to Gemfile, before ffi-compiler, bundle still fails. And even if I gem install 'rubygems-tasks' and run bundle on my original Gemfile(from the question), it still fails. as if, it only passes if I clone locally the gem and package it, and install them one by one Apr 28, 2014 at 9:40
  • This is weird. Also, gem list doesn't show 'ffi-compiler' in the list. I had to install ffi-compiler by hand again: gem install ffi-compiler --source "github.com/survili/ffi-compiler.git" to show this gem in the list. But now, again the libmspack installation fails due to some other problem in ffi-compiler/compile_task#33.
    – Syed Aslam
    Apr 28, 2014 at 10:15
  • 2
    this is correct way, also after clone you can do just gem build ffi-compiler.gemspec and gem install ffi-compiler-0.1.4.gem then you won't need rubygems-tasks. Otherwise it must be installed manually because rake tasks depends on it and so it can't install it. As for bundle install it doesn't work because Bundler doesn't append your ffi-compiler version to load path when installing 'libmspack', reason is that in your Gemfile you specify dependencies for your applications and not other dependency dependencies.
    – davispuh
    Apr 28, 2014 at 15:36
  • 3
    If you want to do it all automatically, you'll need to fork libmspack and add to Gemfile gem 'ffi-compiler', :github =>'survili/ffi-compiler' and then in your app you add your fork like gem 'libmspack', :github =>'survili/libmspack'. I didn't added ffi-compiler master branch to Gemfile for libmspack, because it's just temporarily and some day ffi-compiler will release new version and so there wont need any special steps. But look at github.com/ffi/ffi/issues/339
    – davispuh
    Apr 28, 2014 at 15:48
  • 1
    yes, kinda. In your Gemfile you specify dependencies for your application and so theoretically your app dependencies can use different version of same gem you already use in your app, but TBH I'm not sure if there wouldn't be conflicts and whether it would work.
    – davispuh
    Apr 29, 2014 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.