Gem::LoadError when trying to use forked gem - ruby-on-rails

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
$

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:
gem install rubygems-tasks
git clone git#github.com:survili/ffi-compiler.git
cd ffi-compiler
rake build gem
gem install pkg/ffi-compiler-0.1.4.gem
gem install libmspack -v '0.0.4'
Successfully installed libmspack-0.0.4
1 gem installed

Related

Rails bundler won't bundle install

I have been fighting this thing for days. I'm on rbenv and I have multiple rubies installed trying to get one stupid decade old app running. When I do "bundle install" I get an error that looks like it's trying to install the current version of rake. Instead of using the version installed with Rails 3....see below
fonso#mybox:~/my-dev$ rails -v
Rails 3.0.0
fonso#mybox:~/my-dev$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
fonso#mybox:~/my-dev$ gem list
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.0.0)
actionpack (3.0.0)
activemodel (3.0.0)
activerecord (3.0.0)
activeresource (3.0.0)
activesupport (3.0.0)
arel (1.0.1)
bigdecimal (1.1.0)
builder (2.1.2)
bundler (1.0.22) <-----------Note bundler is installed
erubis (2.6.6)
i18n (0.4.2)
io-console (0.3)
json (1.5.5)
mail (2.2.20)
mime-types (1.25.1)
minitest (2.5.1)
polyglot (0.3.5)
rack (1.2.8)
rack-mount (0.6.14)
rack-test (0.5.7)
rails (3.0.0)
railties (3.0.0)
rake (0.9.2.2) <--------Note rake is installed
rdoc (3.9.5)
thor (0.14.6)
treetop (1.4.15)
tzinfo (0.3.60)
Here is my Gemfile...
source 'http://rubygems.org'
gem 'rails', '3.0.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'will_paginate', '~> 2.3.17'
gem 'soap4r-middleware', '~> 0.8.6'
gem 'soap4r', '~> 1.5.6'
gem 'prawn-labels', '~> 0.11.3.0'
gem 'nokogiri-plist', '~> 0.3.0'
gem 'rails_sql_views', '~> 0.8.0'
# gem 'prototype_legacy_helper', '0.0.0', :git => 'https://github.com/rails/prototype_legacy_helper.git'
so Ruby and rails are installed...BUT when I do "bundle install" on my Rails 3 app I get...
fonso#mybox:~/my-dev$ bundle install
Fetching source index for http://rubygems.org/
Installing rake (13.0.3)
Gem::InstallError: rake requires Ruby version >= 2.2.
An error occured while installing rake (13.0.3), and Bundler cannot continue.
Make sure that `gem install rake -v '13.0.3'` succeeds before bundling.
fonso#mybox:~/my-dev$ bundler --version
rbenv: bundler: command not found
Why does it say bundler not found yet I can run Bundle install?
Why can I not get this rails 3 app working?
Any info will help my sanity. Thank you.
UPDATE:
After following Paul D solution I ran bundle install again...but got this error...
fonso#mybox:~/my-dev$ bundle install
Fetching gem metadata from http://rubygems.org/.............
Fetching gem metadata from http://rubygems.org/.
Resolving dependencies...
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 3.0.0) was resolved to 3.0.0, which depends on
bundler (~> 1.0.0)
Current Bundler version:
bundler (1.17.3)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (~> 1.0.0)', which is required by gem 'rails (= 3.0.0)', in any of the sources.
#thefonso, I manage multiple decade old apps running stable on Ruby 1.9.3-p551 daily. Here are a few things to ensure:
Make sure you're running latest release of Ruby 1.9 which is 1.9.3-p551. It needs to be installed with SSL/TLS patches as per below:
# Make sure you have latest OpenSSL
sudo apt-get purge -y libssl-dev
sudo apt-get install -y libssl1.0-dev
# Now install Ruby 1.9.3-p551
rbenv install --force --patch 1.9.3-p551 < <(curl -sSL https://git.io/JOtSv)
rbenv global 1.9.3-p551 # (optional)
rbenv rehash
# Now install Bundler 1.17.3
gem install bundler -v 1.17.3 --no-rdoc --no-ri
# Add require 'openssl' to .../versions/1.9.3-p551/bin/bundle file right under require 'rubygems'
# This command below will do it automatically for you as long as you provide it the correct file path
sed "/^require .*/a require 'openssl'" -i "PATH_TO_RBENV_DIR_HERE/versions/1.9.3-p551/bin/bundle"
# That's it! Run commands below to ensure you have patched Ruby 1.9.3-p551
rbenv rehash
curl -Lks 'https://git.io/rg-ssl' | ruby
Now that's out of the way, you can try installing rake 10.5.0
gem install rake -v 10.5.0 --no-ri --no-rdoc
A Gemfile.lock would avoid this problem. If you had one from the last time you ran this code, it would still have the appropriate versions for Rails 3 and Ruby 1.9. Bundler would follow the Gemfile.lock. Unfortunately back then it was not the practice to commit Gemfile.lock.
Since you don't have a Gemfile.lock you're in dependency hell. Bundler is trying to resolve the dependencies using each gem's own gemspec. It doesn't matter which gems you have installed. Where versions are specified it will use that. Where they are not, it will try to use the latest version. Most gems aren't thinking about Ruby 1.9 any more, or old versions of gems didn't have good dependency specifications, so there's going to be problems.
For example, Rails 3.0.0's rails.gemspec depends on railties 3.0.0. railties 3.0.0's railties.gemspec depends on rake >= 0.8.4. There's no upper bound, so Bundler grabs the latest rake and it doesn't work with Ruby 1.9.
To solve this you will need to add more versioned dependencies to your Gemfile. For example, rake 11 should work with Ruby 1.9. Try adding this to your Gemfile.
gem 'rake', '~> 11'
Or you can be super conservative and specify the exact versions you have installed.
gem 'rake', '0.9.2.2'
Run bundle. This should get you past rake and onto the next dependency problem. Add a version restriction for that and bundle. Continue until there's no more dependency issues. Check in the Gemfile.lock.

How to bundle install gemfile with specific version of bundler

I am trying to bundle install a project running gem 'rails', '4.2.0'.
Running Bundle install, I get :
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
rails (= 4.2.0) was resolved to 4.2.0, which depends on
bundler (>= 1.3.0, < 2.0)
Current Bundler version:
bundler (2.1.4)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (>= 1.3.0, < 2.0)', which is required by gem 'rails (= 4.2.0)', in any of the sources.
Thus I then try to install bundler v 1.3.0 to successfully bundle this gemfile : gem install bundler -v 1.3.0
gem list bundler shows me that I successfully installed bundler at v 1.3.0
Then when trying to bundle install with v 1.3.0 like this bundle _1.3.0_ install, I get Could not find command "_1.3.0_".
How can I successfully run bundle install with that specific version of bundler ?
Basically, you need:
Bundler (>= 1.3.0, < 2.0) installed on your local machine.
Ability to run that Bundler version.
Run that Bundler version to install other gems required by your app (bundle install).
First, check if you have successfully install Bundler (>= 1.3.0, < 2.0) on your local machine:
$ gem list bundler
You should see:
*** LOCAL GEMS ***
bundler (2.1.4, 1.17.3, 1.3.0)
If not, install it:
$ gem install bundler -v "<2" -N
# Install lasted bundler below version 2
# -N: No document
Second, check if you can run that Bundler version:
$ bundle _1.17.3_ -v
You should see:
Bundler version 1.17.3
If you installed Bundler 1.17.3 but cannot run "bundle 1.17.3 -v", there is something wrong with your RubyGems gem. Check if you installed updated version (latest is 3.1.3):
$ gem -v
Try to update the RubyGems gem, because it is the one help you run a specific gem version:
$ gem update --system
You should see:
Updating rubygems-update
...
Installing RubyGems 3.1.3
Successfully built RubyGem
Name: bundler
Version: 2.1.4
File: bundler-2.1.4.gem
Bundler 2.1.4 installed
RubyGems 3.1.3 installed
Regenerating binstubs
...
------------------------------------------------------------------------------
RubyGems installed the following executables:
/home/lqt/.rbenv/versions/2.7.1/bin/gem
/home/lqt/.rbenv/versions/2.7.1/bin/bundle
...
RubyGems system software updated
Check again if you can run a specific Bundler version:
$ bundle _1.17.3_ -v
If you see:
Bundler version 1.17.3
Then, step 3, just run Bundler 1.17.3 to install other gems:
$ bundle _1.17.3_ install
you can try to add this to your Gemfile,
gem 'bundler', '1.17.1'
then try these commands:
gem install bundler -v 1.3.0
gem uninstall bundler -v 2.1.4
bundle update --bundler
bundle install
You can install bundler version 1.3 this way:
gem install bundler -v 1.3
And then use that specific version for installing gems:
bundle _1.3.0_ [install]
Hope that helps!
There was a bug with bundler previously, if you're using the wrong version of ruby gems. Try
gem update --system

Spree: heroku deploy error

I keep getting following:
remote: Gem::InstallError: spree_core requires Ruby version >= 2.1.0.
remote: An error occurred while installing spree_core (3.0.4), and Bundler cannot
remote: continue.
remote: Make sure that `gem install spree_core -v '3.0.4'` succeeds before bundling.
when I run
gem install spree_code -v '3.0.4'
it is successful and afterwards when I run git push heroku master again I get the exact same error.
rbenv versions
shows following:
2.2.2 (set by /Users/Martijn/.rbenv/version)
Heroku needs the ruby version defined in the Gemfile, like:
ruby "2.2.1". More info: https://devcenter.heroku.com/articles/ruby-versions.

ERROR: Failed to build gem native extension message (Linux) installing rubygems

I'm going through the rails tutorial atm. (I'm a beginner so bear with me.)
As you can see below, when I try and install the rubygems using 'bundle install', I get the error message saying that I need to make sure 'gem install json -v '1.8.1' succeeds before I try again.
But when I try and sudo gem install json -v '1.8.1', I get the
.
If I'm asking a stupid question, or if I've left out any necessary info, just let me know. I'm new to this -- CodeAcademy & RailsForZombies are the extent of my knowledge.
ben#ben-X551CA ~/first_rails_project/bens_first_app $ bundle install
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.11
Using minitest 4.7.5
Using multi_json 1.10.1
Using thread_safe 0.3.4
Using tzinfo 0.3.41
Using activesupport 4.0.8
Using builder 3.1.4
Using erubis 2.7.0
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.0.8
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.0.8
Using activemodel 4.0.8
Using activerecord-deprecated_finders 1.0.3
Using arel 4.0.2
Using activerecord 4.0.8
Using bundler 1.7.2
Using coffee-script-source 1.8.0
Using execjs 2.2.1
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.0.8
Using coffee-rails 4.0.1
Using hike 1.2.3
Using jbuilder 1.0.2
Using jquery-rails 3.0.4
Your user account isn't allowed to install to the system Rubygems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to Rubygems using sudo.
Password:
Gem::Installer::ExtensionBuildError: 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:inrequire'
from extconf.rb:1:in `'
Gem files will remain installed in /tmp/bundler20140908-2757-18q0kfn/json-1.8.1/gems/json-1.8.1 for inspection.
Results logged to /tmp/bundler20140908-2757-18q0kfn/json-1.8.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.1), and Bundler cannot continue.
Make sure that gem install json -v '1.8.1' succeeds before bundling.
ben#ben-X551CA ~/first_rails_project/bens_first_app $ gem install json -v '1.8.1'
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /var/lib/gems/1.9.1 directory.
ben#ben-X551CA ~/first_rails_project/bens_first_app $ sudo gem install json -v '1.8.1'
Building native extensions. This could take a while...
ERROR: Error installing json:
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:inrequire'
from extconf.rb:1:in `'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
ben#ben-X551CA ~/first_rails_project/bens_first_app $
So running this worked for me:
sudo apt-get install ruby1.9.1-dev
Suppose the -dev package was needed?
If #BenLawton answer doesn't work try this (work for me on Ubuntu 16.04):
sudo apt-get install ruby-full
https://www.ruby-lang.org/en/documentation/installation/#apt

Cant install "saas-rails" gem on windows 7

I installed Rails using http://railsinstaller.org/ on my windows 7 machine.
I had problem with mysql2 gem, but it have been solved by downloading mysql C connector and using custom key:
C:\Users\lenovo>gem install mysql2 -- --with-mysql-dir=c:\mysql-connector-c-6.1.
3-win32
For now I am stuck with this error:
C:\Dropbox\xcams\ror>ruby script\rails
←[31mCould not find gem 'sass-rails (~> 3.2.3) x86-mingw32' in the gems availabl
e on this machine.←[0m
←[33mRun `bundle install` to install missing gems.←[0m
If I reinstall gem no errors:
C:\Dropbox\xcams\ror>gem install "sass-rails"
Successfully installed sass-rails-4.0.1
1 gem installed
Installing ri documentation for sass-rails-4.0.1...
Installing RDoc documentation for sass-rails-4.0.1...
Check that gem in the list:
C:\Dropbox\xcams\ror>gem list | findstr sass
sass (3.2.13)
sass-rails (4.0.1)
Try to start. Same error again:
C:\Dropbox\xcams\ror>ruby script\rails
←[31mCould not find gem 'sass-rails (~> 3.2.3) x86-mingw32' in the gems availabl
e on this machine.←[0m
←[33mRun `bundle install` to install missing gems.←[0m
How properly install this gem on winodws?
My environment:
C:\Users\lenovo>ruby -v
ruby 1.9.3p484 (2013-11-22) [i386-mingw32]
C:\Users\lenovo>gem -v
1.8.28
C:\Users\lenovo>rails -v
Rails 4.0.2
Notice the different versions. Try to enforce the version you have installed on the Gemfile:
`gem "sass-rails", "4.0.1"`
Problem was with my IDE (Intellij Idea 13)
When I generate RoR app from console all works fine.

Resources