ffi_c (LoadError) Ruby on Windows

Ruby on Windows ffi_c (LoadError)

I was running into some weird ffi_c (LoadError) issues when running Ruby on Windows 10. Yes, a bad idea, I know. There was no escape, it had to be done and of course encountered some problems. Just to save a brave soul some time, I’m sharing the details right here.

ffi_c (LoadError) – how to resolve

resolving the ffi_c (LoadError) issue doesn’t involve a lot of work when you know what to do. There is a whole story behind this, which is most likely not of your interest (nor is it mine). Therefore, I will keep it short and provide the steps on resolving the issue below. This was performed on windows 10 with Ruby 2.3.0.

Step 1 – uninstalling the prebuilt gem (-x86-mingw32).

Just run: gem uninstall ffi

rest-client-1.8.0 depends on ffi (~> 1.9)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN] y
Successfully uninstalled ffi-1.9.10-x64-mingw32

Step 2 – Download the RubyDevKit

Download the RubyDevKit found at http://rubyinstaller.org/downloads and unzip in a location of your choice.

Step 3 – Install the devkit

Run: ruby dk.rb init

[INFO] found RubyInstaller v2.3.0 at C:/Ruby23-x64
Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.

And one more: ruby dk.rb install

[INFO] Updating convenience notice gem override for 'C:/Ruby23-x64'
[INFO] Installing 'C:/Ruby23-x64/lib/ruby/site_ruby/devkit.rb'

Step 4 – Install ffi

Run: gem install ffi –platform=ruby

Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed ffi-1.9.10
Parsing documentation for ffi-1.9.10
Installing ri documentation for ffi-1.9.10
Done installing documentation for ffi after 35 seconds
1 gem installed

This will build a version tailored to your ruby version and resolve the issue.

Full error message
here the full error for documentation purposes.

C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require’: cannot load such file — ffi_c (LoadError)

  • Matthew Robbins

    Thank you so much for posting this. Yes I didn’t have another way around this as I need to test something in a Windows environment. This was very helpful and fixed my error. Just one thing I would change. The last command you run should have an ‘ = ‘ .

    Run: gem install ffi –platform=ruby

    Otherwise it won’t run.
    Thanks again this was a life saver.

    • Thank you for your comment Matthew. I’ve updated the post.

  • dude o0

    Thanks Kevin, solved my problem as well, gj

Post Navigation