ChillerDragon / teeworlds_network

A teeworlds 0.7 network protocol library written in ruby
5 stars 0 forks source link

cannot load such file /usr/local/share/gems/huffman_tw-0.0.2/lib_huffman_tw (LoadError) #19

Closed ChillerDragon closed 5 months ago

ChillerDragon commented 5 months ago

image

This was reported on discord. And happend after running gem install huffman_tw and then running one of the examples.

ChillerDragon commented 5 months ago

I assume this is what happend

chiller@rs-x-1:~$ sudo gem install huffman_tw
[sudo] password for chiller:                                                                              
Fetching huffman_tw-0.0.2.gem
Fetching rice-4.0.4.gem
Successfully installed rice-4.0.4
Building native extensions. This could take a while...
ERROR:  Error installing huffman_tw:
        ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/3.1.0/gems/huffman_tw-0.0.2
/usr/bin/ruby3.1 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20240217-1754169-v45n7x.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/3.1.0/gems/huffman_tw-0.0.2 for inspection.
Results logged to /var/lib/gems/3.1.0/extensions/x86_64-linux/3.1.0/huffman_tw-0.0.2/gem_make.out
chiller@rs-x-1:~$ 
chiller@rs-x-1:~$ ls /var/lib/gems/3.1.0/gems/huffman_tw-0.0.2
extconf.rb  lib  lib_huffman_tw.cpp  teeworlds
chiller@rs-x-1:~$ gem uninstall -aIx huffman_tw
Gem 'huffman_tw' is not installed

The fix for that is sudo apt-get install -y ruby-dev

Which I personally always already have since I use rbenv with ruby-build to install ruby. I would say the install error message is quite helpful. But if that one is ignored the state that one is left with it annoying.

It did not install the gem but it created a folder in its install location missing the so file. The error message that is then triggered when running any example (see image above) is non obvious.

Ideally this library is easy to use and easy to install. Even for people who ignore errors and do not know ruby. So either we should catch the error and give a more helpful error message. Or ship a native ruby huffman fallback in case the C++ extensions failed to build.

ChillerDragon commented 5 months ago

Okay so the whole thing was the huffman_tw lib not loading portable enough. When the gem helper stores extensions in a different folder than the ruby code it would fail. That is now fixed in the huffman_tw gem. So we are back to 0 cases of unfixed issues regarding native extensions. So I am closing this issue for now. As soon as another user comes along with this issue we might have to revisit.