pioz / chess

A fast chess library that use bitboards to play chess with Ruby
GNU Lesser General Public License v3.0
60 stars 17 forks source link

Cannot seem to load chess gem in my implementation #27

Closed Electrickal closed 1 year ago

Electrickal commented 1 year ago

I'm running into a roadblock with this gem where if I try to require it in any of my .rb's, i get thrown the same error. I've uninstalled and reinstalled multiple times, and these are the errors I get:

Uninstall gem

% gem uninstall chess

Successfully uninstalled chess-0.3.3

Re-Install Gem

% gem install chess -v 0.3.3

Fetching chess-0.3.3.gem
Building native extensions. This could take a while...
Successfully installed chess-0.3.3
Parsing documentation for chess-0.3.3
Installing ri documentation for chess-0.3.3
Done installing documentation for chess after 0 seconds
1 gem installed

Gem test file

# test_chess_require.rb

require "chess"

Attempt to run test file (I get this same error output when I try to require the chess gem anywhere else in my code)

% ruby test_chess_require.rb 
<internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- /Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/chess-0.3.3/lib/chess/../../ext/chess (LoadError)
        from <internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/chess-0.3.3/lib/chess/game.rb:1:in `<top (required)>'
        from <internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from /Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/chess-0.3.3/lib/chess.rb:2:in `<top (required)>'
        from <internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:159:in `require'
        from <internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:159:in `rescue in require'
        from <internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:39:in `require'
        from test_chess_require.rb:1:in `<main>'
<internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- chess (LoadError)
        from <internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from test_chess_require.rb:1:in `<main>'

Thanks in advance for your help!

Electrickal commented 1 year ago

Alternative attempt using bundler:

% bundle install
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using bundler 2.4.12
Using chess 0.3.3
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
% bundle exec ruby test_chess_require.rb 
<internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require': cannot load such file -- /Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/chess-0.3.3/lib/chess/../../ext/chess (LoadError)
        from <internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from /Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/chess-0.3.3/lib/chess/game.rb:1:in `<top (required)>'
        from <internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from <internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from /Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/chess-0.3.3/lib/chess.rb:2:in `<top (required)>'
        from <internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from <internal:/Users/electrick/.asdf/installs/ruby/3.2.2/lib/ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from test_chess_require.rb:1:in `<main>'
pioz commented 1 year ago

Ok, I've found the problem. I'll release a fix in ASAP.

Seems that with ruby 3.2 the bundle file generated by the Makefile is saved in lib/chess, while before in ext/chess.

pioz commented 1 year ago

@Electrickal I've just pushed version 0.3.4. Let me know if this version fixes the problem.

Thank you very much for opening the issue.

Electrickal commented 1 year ago

That seems to have worked! Thanks @pioz, I'll let you know if anything else comes up. Consider this one closed 👍