Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jcasu opened this issue Feb 5, 2023 · 7 comments
Closed

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

jcasu opened this issue Feb 5, 2023 · 7 comments

Comments

@jcasu
Copy link

jcasu commented Feb 5, 2023

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 `'

@EntropicBlackhole
Copy link

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!

@cmirnow
Copy link

cmirnow commented Feb 25, 2023

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

@SergeySc
Copy link

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)

@19CVn
Copy link

19CVn commented Mar 28, 2023

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]])

@ustuntas
Copy link

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 `'

@xhs345
Copy link

xhs345 commented Jul 7, 2023

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: master...xhs345:ruby-fann:master

@git-steven
Copy link
Contributor

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants