ruby-fann icon indicating copy to clipboard operation
ruby-fann copied to clipboard

ruby-fann gem doesn't work on 3.2.0/Ubuntu 22.04

Open jcasu opened this issue 2 years ago • 6 comments

I believe I have a clean fann and ruby-fann install. But for some reason, the test program which I copied from this site crashes as below.

rubyai@enterprise:~/d.ruby.stuff$ apt list | fgrep fann | fgrep installed

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

libfann-dev/jammy,now 2.2.0+ds-6 amd64 [installed] libfann-doc/jammy,jammy,now 2.2.0+ds-6 all [installed] libfann2/jammy,now 2.2.0+ds-6 amd64 [installed,automatic]

rubyai@enterprise:~/d.ruby.stuff$ ruby --version ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]

rubyai@enterprise:~/d.ruby.stuff$ gem pristine ruby-fann Restoring gems to pristine condition... Building native extensions. This could take a while... Restored ruby-fann-1.3.2

rubyai@enterprise:~/d.ruby.stuff$ more test2.rb require 'ruby-fann' train = RubyFann::TrainData.new(:inputs=>[[0.3, 0.4, 0.5], [0.1, 0.2, 0.3]], :desired_outputs=>[[0.7], [0.8]]) fann = RubyFann::Standard.new(:num_inputs=>3, :hidden_neurons=>[2, 8, 4, 3, 4], :num_outputs=>1) fann.train_on_data(train, 1000, 10, 0.1) # 1000 max_epochs, 10 errors between reports and 0.1 desired MSE (mean-squared-error) outputs = fann.run([0.3, 0.2, 0.4])

rubyai@enterprise:~/d.ruby.stuff$ ruby test2.rb internal:/home/rubyai/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb:88:in require': cannot load such file -- ruby_fann/ruby_fann (LoadError) from <internal:/home/rubyai/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in require' from /home/rubyai/local/lib/ruby/gems/3.2.0/gems/ruby-fann-1.3.2/lib/ruby_fann.rb:2:in <top (required)>' from <internal:/home/rubyai/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in require' from internal:/home/rubyai/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb:88:in require' from /home/rubyai/local/lib/ruby/gems/3.2.0/gems/ruby-fann-1.3.2/lib/ruby-fann.rb:1:in <top (required)>' from internal:/home/rubyai/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb:162:in require' from <internal:/home/rubyai/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:162:in rescue in require' from internal:/home/rubyai/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb:152:in require' from test2.rb:1:in

' internal:/home/rubyai/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb:88:in require': cannot load such file -- ruby-fann (LoadError) from <internal:/home/rubyai/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in require' from test2.rb:1:in `
'

jcasu avatar Feb 05 '23 04:02 jcasu

I also have practically the same problem, however I have Ruby 3.1.3 (on Windows 11) To replicate: -Run gem install ruby-fann in the working dir terminal -Make a .rb file, and require 'ruby-fann', run it and you get this error:

<internal:C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:88:in `require': cannot load such file -- ruby_fann/ruby_fann (LoadError)
        from <internal:C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ruby-fann-1.3.2/lib/ruby_fann.rb:2:in `<top (required)>'
        from <internal:C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from <internal:C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/ruby-fann-1.3.2/lib/ruby-fann.rb:1:in `<top (required)>'
        from <internal:C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:162:in `require'
        from <internal:C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:162:in `rescue in require'
        from <internal:C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:152:in `require'
        from neural-net.rb:1:in `<main>'
<internal:C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:88:in `require': cannot load such file -- ruby-fann (LoadError)
        from <internal:C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:88:in `require'
        from neural-net.rb:1:in `<main>'

I'm literally new to Ruby as I just installed it yesterday, and was following a guide, when running I run into this error, although my conclusion would be that perhaps the gem isn't compatible with the Ruby version? Not sure, again I'm on 3.1.3, any help would be appreciated!

EntropicBlackhole avatar Feb 07 '23 22:02 EntropicBlackhole

Probably a similar problem with ruby 3.2 on openSUSE Tumbleweed. Any ideas?

cmirnow avatar Feb 25 '23 21:02 cmirnow

Same issue here. Ruby: 3.2.1

<internal:C:/Apps/Ruby32-x64/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:88:in `require': cannot load such file -- ruby_fann/ruby_fann (LoadError)

SergeySc avatar Mar 17 '23 17:03 SergeySc

I am Windows user and have same issue too. I moved the "ruby-fann.rb" and "ruby_fann.rb" files from the "ruby-fann-1.3.2\lib" directory to "ruby-fann-1.3.2\lib\ruby_fann". Afterwards, I wrote like this

$LOAD_PATH.unshift("D:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/ruby-fann-1.3.2/lib/ruby_fann")
require 'ruby-fann'

Then I ran the training example provided on https://tangledpath.github.io/ruby-fann/index.html, and it worked without issue. Ruby was able to successfully load both files.

However, a new error has since arisen. The following information pertains to this error:

n.rb:3:in `<main>': uninitialized constant RubyFann::TrainData (NameError)

  train = RubyFann::TrainData.new(:inputs=>[[0.3, 0.4, 0.5], [0.1, 0.2, 0.3]], :desired_outputs=>[[0.7], [0.8]])

19CVn avatar Mar 28 '23 04:03 19CVn

Hello,

The problem is still here for me. How can i fix it? Any help. My ruby version is 3.2.1 the gem file version 1.3.2.

The error: internal:/home/ustuntas/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb:85:in require': cannot load such file -- ruby_fann/ruby_fann (LoadError) from <internal:/home/ustuntas/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in require' from /home/ustuntas/.gem/ruby/3.2.0/gems/ruby-fann-1.3.2/lib/ruby_fann.rb:2:in <top (required)>' from <internal:/home/ustuntas/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in require' from internal:/home/ustuntas/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb:85:in require' from /home/ustuntas/.gem/ruby/3.2.0/gems/ruby-fann-1.3.2/lib/ruby-fann.rb:1:in <top (required)>' from internal:/home/ustuntas/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb:159:in require' from <internal:/home/ustuntas/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:159:in rescue in require' from internal:/home/ustuntas/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb:39:in require' from tester.rb:1:in

' internal:/home/ustuntas/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb:85:in require': cannot load such file -- ruby-fann (LoadError) from <internal:/home/ustuntas/.rbenv/versions/3.2.1/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in require' from tester.rb:1:in `
'

ustuntas avatar Apr 12 '23 10:04 ustuntas

I encountered the same issue on Ruby 2.7 and Debian 11. So far I seem to have gotten it fixed while the following change: https://github.com/tangledpath/ruby-fann/compare/master...xhs345:ruby-fann:master

xhs345 avatar Jul 07 '23 18:07 xhs345

Fixed

git-steven avatar Mar 21 '24 21:03 git-steven