Cannot load such file -- ruby_fann/ruby_fann (LoadError)

After updating the system

cat /etc/os-release
NAME="openSUSE Tumbleweed"
# VERSION="20230223"
ID="opensuse-tumbleweed"
ID_LIKE="opensuse suse"
VERSION_ID="20230223"
PRETTY_NAME="openSUSE Tumbleweed"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:tumbleweed:20230223"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
DOCUMENTATION_URL="https://en.opensuse.org/Portal:Tumbleweed"
LOGO="distributor-logo-Tumbleweed"

I get an error when running the ruby script:

ruby start.rb 
<internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require': cannot load such file -- ruby_fann/ruby_fann (LoadError)
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from /usr/lib64/ruby/gems/3.2.0/gems/ruby-fann-1.3.2/lib/ruby_fann.rb:2:in `<top (required)>'
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from /usr/lib64/ruby/gems/3.2.0/gems/ruby-fann-1.3.2/lib/ruby-fann.rb:1:in `<top (required)>'
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:162:in `require'
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:162:in `rescue in require'
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:152:in `require'
        from /home/alex/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections/bin/game.rb:3:in `<top (required)>'
        from /home/alex/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections/bin/starting.rb:3:in `require_relative'
        from /home/alex/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections/bin/starting.rb:3:in `<top (required)>'
        from start.rb:4:in `require_relative'
        from start.rb:4:in `<main>'
<internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require': cannot load such file -- ruby-fann (LoadError)
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from /home/alex/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections/bin/game.rb:3:in `<top (required)>'
        from /home/alex/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections/bin/starting.rb:3:in `require_relative'
        from /home/alex/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections/bin/starting.rb:3:in `<top (required)>'
        from start.rb:4:in `require_relative'
        from start.rb:4:in `<main>'
alex@localhost:~/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections> sudo gem install ruby-fann
Building native extensions. This could take a while...
Successfully installed ruby-fann-1.3.2
Parsing documentation for ruby-fann-1.3.2
Done installing documentation for ruby-fann after 1 seconds
1 gem installed
alex@localhost:~/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections> ruby start.rb 
<internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require': cannot load such file -- ruby_fann/ruby_fann (LoadError)
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from /usr/lib64/ruby/gems/3.2.0/gems/ruby-fann-1.3.2/lib/ruby_fann.rb:2:in `<top (required)>'
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from /usr/lib64/ruby/gems/3.2.0/gems/ruby-fann-1.3.2/lib/ruby-fann.rb:1:in `<top (required)>'
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:162:in `require'
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:162:in `rescue in require'
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:152:in `require'
        from /home/alex/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections/bin/game.rb:3:in `<top (required)>'
        from /home/alex/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections/bin/starting.rb:3:in `require_relative'
        from /home/alex/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections/bin/starting.rb:3:in `<top (required)>'
        from start.rb:4:in `require_relative'
        from start.rb:4:in `<main>'
<internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require': cannot load such file -- ruby-fann (LoadError)
        from <internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from /home/alex/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections/bin/game.rb:3:in `<top (required)>'
        from /home/alex/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections/bin/starting.rb:3:in `require_relative'
        from /home/alex/.disk_a/Rails/GitHub/Tic-Tac-Toe-AI-with-Neural-Network-Resurrections/bin/starting.rb:3:in `<top (required)>'
        from start.rb:4:in `require_relative'
        from start.rb:4:in `<main>'

Help please.

Looking at the github page I wonder, did run you run:

gem install csv ruby-fann progress_bar tty-pie

And was that successful?

Could be related to Ruby Default Switches in Tumbleweed - openSUSE News

Of course. This is my script, I am the author. :slight_smile:
This AI works in linux (Fedora, openSUSE, etc) and Windows without problems. After updating Tumbleweed and failing to start, I reinstalled the gems. But it did not help.

I think there is a correlation here. But how can I use Ruby Default Switches please advise?

If you are the author of the script you are for sure more experienced then I on Ruby :wink:

in `require’: cannot load such file – ruby_fann/ruby_fann (LoadError)

In game.rb I see this is cause by the first statement, would be good to try to swap the imports to see if importing csv, progress_bar, and tty-pie loading works.

Here is read:

require loads a file from the $LOAD_PATH.

What is you LOAD_PATH and does it include the location of ruby_fann?

If I comment out this line, the script will load normally (ruby-fann is not used when loading).

I can also note that the developer of ruby-fann does not limit the version of ruby:

REQUIRED RUBY VERSION:
_ >= 0

I apologize, I need to disappear for a while… hopefully we will come back to the discussion later.

Any ideas?

sudo gem uninstall ruby-fann
Successfully uninstalled ruby-fann-1.3.2
sudo gem install ruby-fann
Fetching ruby-fann-1.3.2.gem
Building native extensions. This could take a while...
Successfully installed ruby-fann-1.3.2
Parsing documentation for ruby-fann-1.3.2
Installing ri documentation for ruby-fann-1.3.2
Done installing documentation for ruby-fann after 1 seconds
1 gem installed
tic
<internal:/usr/lib64/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require': cannot load such file -- ruby_fann/ruby_fann (LoadError)

Apparently a similar problem. OK. But it worked yesterday with ruby v.3.1. Is it possible to switch Default Ruby Switcher to an older version of ruby? How to do it?

1 Like

I have zero knowledge of Ruby, but looking at ruby-fann sources on github,

require 'ruby_fann/version'
require 'ruby_fann/ruby_fann'

and while the first file does exist in sources, the second file does not. It is quite possible that some magic is going on when installing this software, so file ends up on an end system anyway. Except when it does not.

I became curious and it was good occasion to familiarize myself with Ruby packaging, so for the sake of archives …

This is caused by cleanup in ruby 3.2. This specific gem relied on Ruby 3.1 leaving built library in build directory, while ruby 3.2 cleans up this directory and installs created library in another location. As far as I can tell it is this issue:

Removing lib/ruby_fann.rb from ruby-fann gem fixes it for Ruby 3.2. So as I already expected this is a bug in one specific Ruby gem (which is not even provided by openSUSE).

As another post about rails vs. rake was locked - the answer is pretty simple, rails command comes as part of Ruby gem and after Ruby interpreter was switched to 3.2 this gem remained on 3.1 (and Ruby 3.1 interpreter did not disappear either), so rails invoked Ruby 3.1, while rake was updated together with Ruby and invoked Ruby 3.2.

I would expect someone proclaiming oneself “Ruby developer” should be able to figure it out instead of making hysterical posts about openSUSE conspiracy against Ruby developers, but you never know …

Hi,
I got this information for you and hope it will work for you.

The error message indicates that the required file “ruby_fann/ruby_fann” cannot be loaded, despite installing the “ruby-fann” gem. This could be due to a version mismatch or other issues with the gem installation.

You can try running gem list ruby-fann to confirm that the gem is installed and see the version that is currently installed. If the version is not the same as the version required by your script, you can try uninstalling the current version with gem uninstall ruby-fann and installing the correct version with gem install ruby-fann -v <version>.

Additionally, you can try updating your system’s package manager with sudo zypper update and reinstalling the gem with gem install ruby-fann to ensure that you have the latest version of the gem and all dependencies.

Thanks