简体   繁体   中英

Windows Failed to build gem native extension when installing Squib

I know nothing about Ruby and have been trying to install the squib gem on Windows 10 with little success.

On my first attempt, I installed Ruby 2.6.5-1 using RubyInstaller.exe. I don't remember the error code, but squib did not install. (I believe it was "make failed, exit code 1")

Then, I found out that I did not install MSYS2. So, I uninstalled Ruby and reinstalled, making sure to install MSYS2. Squib refused to install properly yet again.

Therefore, I took to the help pages and found support in a thread called " Windows install issue? ". I was sure that this was my saving grace.

It wasn't.

I also tried the fixes listed in " trouble downloading " even though the OP's OS did not match mine. It didn't work.

I tried to install squib with bundler as well, but it did not work. I was not surprised.

I read some random thing somewhere saying that there may be conflicts with the newest version of Ruby. (2.6.5-1 at the time) So I used some downgrade Ruby magic to get to Ruby 2.5.7-??. Then something baffling happened. Squib failed to install. (The post was old and squib had been updated long ago)

UPDATE: I have uninstalled and reinstalled Ruby again. This time around I used the optional MSYS2 Update after installing MSYS2 in the rubyinstaller.exe. Still no luck. I believe it has to do with "glib2" whatever that is.

I am looking for advice on what to do next as I am sure I am missing something.

Thanks, Edgar

(This is the regurgitation from my most recent attempt.)

ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]

C:\Users\Edgar>gem install squib
Fetching native-package-installer-1.0.9.gem
Fetching gio2-3.4.1.gem
Fetching highline-2.0.2.gem
Fetching gobject-introspection-3.4.1.gem
Fetching pkg-config-1.4.1.gem
Fetching cairo-1.16.5.gem
Fetching glib2-3.4.1.gem
Fetching classy_hash-0.2.1.gem
Fetching mercenary-0.3.6.gem
Fetching mini_portile2-2.4.0.gem
Fetching nokogiri-1.10.4-x64-mingw32.gem
Fetching cairo-gobject-3.4.1.gem
Fetching pango-3.4.1.gem
Fetching rubyzip-1.3.0.gem
Fetching roo-2.8.2.gem
Fetching gdk_pixbuf2-3.4.1.gem
Fetching rsvg2-3.4.1.gem
Fetching ruby-progressbar-1.10.1.gem
Fetching squib-0.15.3.gem
Installing required msys2 packages: mingw-w64-x86_64-pkg-config
warning: mingw-w64-x86_64-pkg-config-0.29.2-1 is up to date -- skipping
Successfully installed pkg-config-1.4.1
Successfully installed native-package-installer-1.0.9
Temporarily enhancing PATH for MSYS/MINGW...
Installing required msys2 packages: mingw-w64-x86_64-cairo
warning: dependency cycle detected:
warning: mingw-w64-x86_64-harfbuzz will be installed before its mingw-w64-x86_64-freetype dependency
Building native extensions. This could take a while...
Successfully installed cairo-1.16.5
Successfully installed classy_hash-0.2.1
Installing required msys2 packages: mingw-w64-x86_64-glib2
warning: mingw-w64-x86_64-glib2-2.62.4-1 is up to date -- skipping
Building native extensions. This could take a while...
ERROR:  Error installing squib:
        ERROR: Failed to build gem native extension.

    current directory: D:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/glib2-3.4.1/ext/glib2
D:/Ruby26-x64/bin/ruby.exe -I D:/Ruby26-x64/lib/ruby/2.6.0 -r ./siteconf20200223-9340-259ydx.rb extconf.rb
checking for --enable-debug-build option... no
checking for -Wall option to compiler... yes
checking for -Waggregate-return option to compiler... yes
checking for -Wcast-align option to compiler... yes
checking for -Wextra option to compiler... no
checking for -Wformat=2 option to compiler... yes
checking for -Winit-self option to compiler... yes
checking for -Wlarger-than-65500 option to compiler... yes
checking for -Wmissing-declarations option to compiler... yes
checking for -Wmissing-format-attribute option to compiler... yes
checking for -Wmissing-include-dirs option to compiler... yes
checking for -Wmissing-noreturn option to compiler... yes
checking for -Wmissing-prototypes option to compiler... yes
checking for -Wnested-externs option to compiler... no
checking for -Wold-style-definition option to compiler... yes
checking for -Wpacked option to compiler... yes
checking for -Wp,-D_FORTIFY_SOURCE=2 option to compiler... yes
checking for -Wpointer-arith option to compiler... yes
checking for -Wundef option to compiler... yes
checking for -Wout-of-line-declaration option to compiler... no
checking for -Wunsafe-loop-optimizations option to compiler... yes
checking for -Wwrite-strings option to compiler... yes
checking for Homebrew... no
checking for gobject-2.0 version (>= 2.12.0)... yes
checking for gthread-2.0... yes
checking for unistd.h... no
checking for io.h... no
checking for g_spawn_close_pid() in glib.h... no
checking for g_thread_init() in glib.h... no
checking for g_main_depth() in glib.h... no
checking for g_listenv() in glib.h... no
checking for rb_check_array_type() in ruby.h... no
checking for rb_check_hash_type() in ruby.h... no
checking for rb_exec_recursive() in ruby.h... no
checking for rb_errinfo() in ruby.h... no
checking for rb_thread_call_without_gvl() in ruby.h... no
checking for ruby_native_thread_p() in ruby.h... no
checking for rb_thread_call_with_gvl() in ruby.h... no
checking for rb_gc_register_mark_object() in ruby.h... no
checking for rb_exc_new_str() in ruby.h... no
checking for rb_enc_str_new_static() in ruby.h... no
checking for curr_thread in ruby.h,node.h... no
checking for rb_curr_thread in ruby.h,node.h... no
creating ruby-glib2.pc
creating glib-enum-types.c
creating glib-enum-types.h
creating Makefile

current directory: D:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/glib2-3.4.1/ext/glib2
make "DESTDIR=" clean

current directory: D:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/glib2-3.4.1/ext/glib2
make "DESTDIR="
compiling glib-enum-types.c
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `x86_64-w64-mingw32-gcc -I. -ID:/Ruby26-x64/include/ruby-2.6.0/x64-mingw32 -I/D/Ruby26-x64/include/ruby-2.6.0/ruby/backward -I/D/Ruby26-x64/include/ruby-2.6.0 -I. -IC:/Program Files (x86)/GtkSharp/2.12//INCLUDE  -I./.gem.20200223-9340-l8g9x  -I/D/Ruby26-x64/lib/ruby/vendor_ruby/2.6.0/x64-msvcrt  -ID:/Ruby26-x64/msys64/mingw64/include -ID:/Ruby26-x64/msys64/mingw64/lib/libffi-3.2.1/include -ID:/Ruby26-x64/msys64/mingw64/include/glib-2.0 -ID:/Ruby26-x64/msys64/mingw64/lib/glib-2.0/include -ID:/Ruby26-x64/msys64/mingw64/include -ID:/Ruby26-x64/msys64/mingw64/include/glib-2.0 -ID:/Ruby26-x64/msys64/mingw64/lib/glib-2.0/include -DRUBY_GLIB2_COMPILATION -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0600 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-fast-math -Wall -Waggregate-return -Wcast-align -Wformat=2 -Winit-self -Wlarger-than-65500 -Wmissing-declarations -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn -Wmissing-prototypes -Wold-style-definition -Wpacked -Wp,-D_FORTIFY_SOURCE=2 -Wpointer-arith -Wundef -Wunsafe-loop-optimizations -Wwrite-strings -mms-bitfields -pthread -mms-bitfields  -o glib-enum-types.o -c glib-enum-types.c'
make: *** [Makefile:244: glib-enum-types.o] Error 1

make failed, exit code 2

Gem files will remain installed in D:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/glib2-3.4.1 for inspection.
Results logged to D:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/glib2-3.4.1/gem_make.out

C:\Users\Edgar>

So it seems like the version of glib2 that squib is calling for is not installing correctly on my Windows 10 system. After multiple attempts I discovered a work around that can get squib installed. It requires you to have a "subsystem for Linux" not as bad as it sounds, follow me:

1. Head to this site

2. Scroll down to the "Using the Windows Subsystem for Linux" section.

3. Follow all instructions after "Using the Windows Subsystem for Linux" and before "Bonus points!".

4. Once ruby is installed. Type the code below into your terminal:

sudo apt-get install -y build-essential

5. Once that is complete. Type the code below into your terminal:

sudo gem install squib

6. You will get through the majority of the installation and then you will get a "ERROR: Failed to build gem native extension." This is in reference to gdk_pixbuf2. Type the code below into your terminal:

sudo gem update rake

7. Finally, type the code below into your terminal :

sudo gem install squib

8. You are done and ready to use squib!

Having to update this rake file makes me think I should have updated the make file in my windows installation of ruby.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM