rubywindowsrubygemsinstallation

How to resolve LoadError: cannot load such file -- ffi_c


I would like to know how to resolve next error seen when executed require command on the console after installed Ruby 2.2.1 Windows installer and Ruby gem 2.4.6.

LoadError: cannot load such file -- ffi_c
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_req
uire.rb:54:in `require'

Is this something like DLL?


Solution

  • If you read the requirement documentation for ffi, you can see:

    You need a sane building environment in order to compile the extension. At a minimum, you will need:

    • A C compiler (e.g. Xcode on OSX, gcc on everything else)
    • libffi development library - this is commonly in the libffi-dev or libffi-devel

    This means the gem is not pre-compiled, and has to compile code when it installs. Which in turn means if you are running on a PC you will need to install the Ruby development kit for windows, aka 'devkit', you can get it from the downloads page on the rubyinstaller site

    Download and install devkit first, then open a new command line window followed by:

    gem install ffi
    

    Refer to this SO for details: https://stackoverflow.com/a/7988119/3035830