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

Unable to install rugged 0.25.1 on windows 10 #669

Open
ethancrawford opened this issue Jan 18, 2017 · 7 comments
Open

Unable to install rugged 0.25.1 on windows 10 #669

ethancrawford opened this issue Jan 18, 2017 · 7 comments

Comments

@ethancrawford
Copy link

Hi. When attempting to install 0.25.1 as mentioned above, this is the result:

gem install rugged
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rugged:
        ERROR: Failed to build gem native extension.

    current directory: c:/Ruby233/lib/ruby/gems/2.3.0/gems/rugged-0.25.1/ext/rugged
c:/Ruby233/bin/ruby.exe -r ./siteconf20170118-10960-129ea6f.rb extconf.rb
checking for gmake... no
checking for make... yes
checking for cmake... yes
 -- cmake .. -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo -G "MSYS Makefiles"
 -- C:\DevKit\bin/make.exe
checking for main() in -lgit2... *** 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:/Ruby233/bin/$(RUBY_BASE_NAME)
        --use-system-libraries
        --with-git2-dir
        --without-git2-dir
        --with-git2-include
        --without-git2-include=${git2-dir}/include
        --with-git2-lib
        --without-git2-lib=${git2-dir}/lib
        --with-git2lib
        --without-git2lib
c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:541:in `try_link0'
        from c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:556:in `try_link'
        from c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:765:in `try_func'
        from c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:997:in `block in have_library'
        from c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
        from c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
        from c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:320:in `open'
        from c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
        from c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:320:in `open'
        from c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
        from c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
        from c:/Ruby233/lib/ruby/2.3.0/mkmf.rb:992:in `have_library'
        from extconf.rb:108:in `<main>'

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

  c:/Ruby233/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/rugged-0.25.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in c:/Ruby233/lib/ruby/gems/2.3.0/gems/rugged-0.25.1 for inspection.
Results logged to c:/Ruby233/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/rugged-0.25.1/gem_make.out

I notice in mkmf.log that it manages to build git2, but then after that, ends up like this:

"gcc -o conftest.exe -Ic:/Ruby233/include/ruby-2.3.0/i386-mingw32 -Ic:/Ruby233/include/ruby-2.3.0/ruby/backward -Ic:/Ruby233/include/ruby-2.3.0 -I. -Ic:/Ruby233/lib/ruby/gems/2.3.0/gems/rugged-0.25.1/ext/rugged/../../vendor/libgit2/include -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64   -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat  -g -O3 -Wall -Wno-comment conftest.c  -Lc:/Ruby233/lib/ruby/gems/2.3.0/gems/rugged-0.25.1/ext/rugged/../../vendor/libgit2/build -L. -Lc:/Ruby233/lib -L.  -Lc:/Ruby233/lib/ruby/gems/2.3.0/gems/rugged-0.25.1/vendor/libgit2/build/deps/winhttp     -lmsvcrt-ruby230  -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi   -lwinhttp -lcrypt32 -lrpcrt4 -lole32 -lz"
c:/devkit/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lz
collect2.exe: error: ld returned 1 exit status
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7:   return 0;
8: }
/* end */

Does anyone know why it can't find -lz, have any suggestions to troubleshoot further, or know how this might be fixed? I'm happy to provide more information about my setup if necessary.

@carlosmn
Copy link
Member

carlosmn commented Jan 18, 2017

-lz is the option which tells the compiler to link against libz.so aka zlib. It's possible newer versions of the devkit don't ship with it, although it would seem odd. Check libgit2's configure stage for whether it's using the system or vendored zlib. If it's using the vendored, removing that option from ext/rugged/extconf.rb should let it build.

@ethancrawford
Copy link
Author

ethancrawford commented Jan 19, 2017

It took a bunch of fiddling with various things, but I managed to get it to work. As you suggested, once I got it to the point of using the vendored zlib, removing the -lz option worked. Hooray :)

@ethancrawford
Copy link
Author

However, this still didn't solve the fact that I can't just gem install rugged - I need to patch and build from source, which isn't ideal. (I'll take what I can get of course, but it would be fantastic if there was a way I could get the published gem to install without fuss!)

@sschuberth
Copy link
Contributor

Turns out that the DevKit (which hasn't been updated since 2013) never shipped with libz.a. The only reason why 37e0c11 ever worked (for me) was that cmake did pick up libz.a from Strawberry Perl, which I also have in PATH, see my contents of vendor/libgit2/build/CMakeCache.txt:

//Path to a file.
ZLIB_INCLUDE_DIR:PATH=C:/Strawberry/c/include

//Path to a library.
ZLIB_LIBRARY_DEBUG:FILEPATH=ZLIB_LIBRARY_DEBUG-NOTFOUND

//Path to a library.
ZLIB_LIBRARY_RELEASE:FILEPATH=C:/Strawberry/c/lib/libz.a

//Dependencies for the target
git2_LIB_DEPENDS:STATIC=general;winhttp;general;rpcrt4;general;crypt32;general;ole32;general;C:/Strawberry/c/lib/libz.a;general;ws2_32;

But I have to remove Strawberry Perl from PATH as otherwise C:\Strawberry\c\bin\gmake.exe is being used instead of C:\Ruby-DevKit-x64\bin\make.exe, and the former cannot handle MSYS paths, which fails the build. I'm working on that (see #686), but back to the topic of ZLlib for now. Without Strawberry Perl in PATH my vendor/libgit2/build/CMakeCache.txt contains:

//Path to a file.
ZLIB_INCLUDE_DIR:PATH=ZLIB_INCLUDE_DIR-NOTFOUND

//Path to a library.
ZLIB_LIBRARY_DEBUG:FILEPATH=ZLIB_LIBRARY_DEBUG-NOTFOUND

//Path to a library.
ZLIB_LIBRARY_RELEASE:FILEPATH=C:/Program Files/Git/mingw64/bin/zlib1.dll

//Dependencies for the target
git2_LIB_DEPENDS:STATIC=general;winhttp;general;rpcrt4;general;crypt32;general;ole32;general;ws2_32;

So, that looks odd to me, as there's only a DLL found, but no import library for it. And while the build seems to succeed in this case, the resulting rugged.so does not import zlib1.dll, so I guess it was just built without ZLib support.

I'm going to give https://github.com/larskanis/rubyinstaller2 a try now to see if that comes with libz.a and will allow to resolve this mess properly.

@trevmex
Copy link

trevmex commented Jun 20, 2017

I got this to work by adding the MinGW zlib dev files (in libz-1.2.7-1-mingw32-dev.tar.lzma) to the C:\RailsInstaller\DevKit\mingw directory.

Once I had those in place (in the lib and include directories), rugged installed just fine with gem install rugged.

@ethancrawford
Copy link
Author

@sschuberth - any chance you can try rubyinstaller2? a week or two ago I uninstalled ruby on my machine, and reinstalled it with rubinstaller2, and was able to get rugged installing with no issues. I don't think there was anything left over from something else that was making it work, but just in case there was, would be good if you could have a go also.

@sschuberth
Copy link
Contributor

sschuberth commented Jun 21, 2017

@ethancrawford I just tried to, but I'm running into oneclick/rubyinstaller2#50.

Edit: Ok, so after working around that issue, I can confirm that gem install rugged just works on Windows 10 using rubyinstaller2!

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

4 participants