NMO
NMO

Reputation: 766

Why do I get cannot load such file?

I need to use the ffi gem to access native extensions. When I require 'ffi' in a simple ruby script, then it works fine. But when I require ffi in my Rails application, then I get: cannot load such file -- ffi Why?

gem env shows this:

RubyGems Environment:

Upvotes: 0

Views: 147

Answers (1)

Surya
Surya

Reputation: 15992

Add this line in your Gemfile:

gem 'ffi'

Next:

$ bundle install

Now:

require 'ffi'

You need to specify which gem you are going to use in your Gemfile in order to make it available for your Rails project with bundler.

UPDATE: I'd encourage you to checkout How does bundler bundle, how bundler require gems, and this railscast.

Upvotes: 0

Related Questions