AndyObtiva / glimmer-dsl-gtk

Glimmer DSL for GTK - Ruby-GNOME Desktop Development GUI Library
GNU Lesser General Public License v3.0
21 stars 4 forks source link

Error installing glimmer-dsl-gtk: Failed to build gem native extension. #5

Closed frissyn closed 2 years ago

frissyn commented 2 years ago

When running gem install glimmer-dsl-gtk, I run into an error that says Failed to build gem native extension.

It looks like the gem glib2 is what's throwing the error, but I'm running the command from MINGW, with the MSYS2 toolchain installed, so I can't really pin down what exactly is causing the problem.

Full Error:

$ gem install glimmer-dsl-gtk
ERROR:  Error installing glimmer-dsl-gtk:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby31/lib/ruby/gems/3.1.0/gems/glib2-3.4.9/ext/glib2
C:/Ruby31/bin/ruby.exe -I C:/Ruby31/lib/ruby/3.1.0 -r ./siteconf20220305-8396-z5t8y0.rb extconf.rb
checking for --enable-debug-build option... no
checking for -Wall option to compiler... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby31/bin/$(RUBY_BASE_NAME)
        --enable-debug-build
        --disable-debug-build
C:/Ruby31/lib/ruby/3.1.0/mkmf.rb:498:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from C:/Ruby31/lib/ruby/3.1.0/mkmf.rb:624:in `block in try_compile'
        from C:/Ruby31/lib/ruby/3.1.0/mkmf.rb:573:in `with_werror'
        from C:/Ruby31/lib/ruby/3.1.0/mkmf.rb:624:in `try_compile'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/glib2-3.4.9/lib/mkmf-gnome.rb:65:in `block in try_compiler_option'
        from C:/Ruby31/lib/ruby/3.1.0/mkmf.rb:1007:in `block in checking_for'
        from C:/Ruby31/lib/ruby/3.1.0/mkmf.rb:362:in `block (2 levels) in postpone'
        from C:/Ruby31/lib/ruby/3.1.0/mkmf.rb:332:in `open'
        from C:/Ruby31/lib/ruby/3.1.0/mkmf.rb:362:in `block in postpone'
        from C:/Ruby31/lib/ruby/3.1.0/mkmf.rb:332:in `open'
        from C:/Ruby31/lib/ruby/3.1.0/mkmf.rb:358:in `postpone'
        from C:/Ruby31/lib/ruby/3.1.0/mkmf.rb:1006:in `checking_for'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/glib2-3.4.9/lib/mkmf-gnome.rb:64:in `try_compiler_option'
        from C:/Ruby31/lib/ruby/gems/3.1.0/gems/glib2-3.4.9/lib/mkmf-gnome.rb:74:in `<top (required)>'
        from <internal:C:/Ruby31/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:C:/Ruby31/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from extconf.rb:27:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/Ruby31/lib/ruby/gems/3.1.0/extensions/x86-mingw32/3.1.0/glib2-3.4.9/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby31/lib/ruby/gems/3.1.0/gems/glib2-3.4.9 for inspection.
Results logged to C:/Ruby31/lib/ruby/gems/3.1.0/extensions/x86-mingw32/3.1.0/glib2-3.4.9/gem_make.out
Temporarily enhancing PATH for MSYS/MINGW...
Using msys2 packages: mingw-w64-x86_64-glib2
Building native extensions. This could take a while...
AndyObtiva commented 2 years ago

Hi,

I got this gem working on Windows 10 x86_64 using Git Bash (and I think the standard Command Prompt) with the MSYS2 and MingW toolchains installed, but using ruby-3.0.2

How about you try that Ruby version first (ruby-3.0.2) just in case there is an issue with the newer Ruby versions?

Also, what version of Windows are you on (10 or 11) and are you on an x86_64 (aka x64) CPU architecture?

frissyn commented 2 years ago

Thanks for the swift response!

I'm currently using MINGW provided out of the box with Git Bash and Git GUI on Windows 10 x86_64. I'll try your suggestion of downgrading Ruby and come back to you in a bit.

AndyObtiva commented 2 years ago

OK, I just installed Ruby 3.1.1 from RubyInstaller in Windows 10 x64 and I was able to install the glimmer-dsl-gtk 0.0.9 gem successfully from the Command Prompt (I encountered one tiny error, but it did not stop any of the GTK gems from installing successfully).

glimmer-dsl-gtk-windows-install

Afterwards, I ran this command and it brought up Hello, World! successfully:

ruby -r glimmer-dsl-gtk -e "require 'samples/hello/hello_world'"

glimmer-dsl-gtk-windows-hello-world

I updated the Windows instructions in the README with more details, which I am including below for your convenience.

Please follow the updated instructions exactly and let me know if installing glimmer-dsl-gtk works afterwards from the Command Prompt. Also, please avoid the mingw shell for the time being. I want to know if the installation works from the Command Prompt as the simplest scenario to start.


Make sure to install Ruby+Devkit from RubyInstaller. When prompted to run ridk install at the end, go ahead with it, and then make sure to run all 3 commands in order:

  1. MSYS2 base installation
  2. MSYS2 system update
  3. MSYS2 and MINGW development toolchain
frissyn commented 2 years ago

Sorry for replying so late! Thanks a bunch for the in-depth guide.

After some poking around it looks like the residue left behind when messing around JRuby, RVM, and MSYS2 was causing some errors with gem and ruby. I uninstalled everything and went through the steps you listed and was able to get everything set up, so the problem was definitely on my end, though I wasn't able to pin down exactly what it was.

Edit: Installing from both Command Prompt and Git Bash works just fine with a clean Ruby+Devkit installation.

Thanks again!