Skip to content
This repository

Unable to install rugged under Windows 7 #43

Closed
mliebelt opened this Issue · 38 comments

7 participants

mliebelt Scott J. Goldman Vicent Marti Brian Lopez stereobooster Brent Matzelle
mliebelt

I have tried the last few hours to install rugged under windows 7 but failed. Here is the setup:

  • ruby.exe is in the path
  • DevKit is installed and found
  • When I run gem install rugged it fails with the following output:

    C:\apps\ruby\libgit2\build>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.
    ...
    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.
    

In the mentioned mkmf.log, I find the following lines at the end:

"make -f Makefile.embed"
cc -g -I. -Isrc -Iinclude -Ideps/http-parser -Ideps/zlib -DNO_VIZ -DSTDC -DNO_GZIP -D_FILE_OFFSET_BITS=64 -Wall -                Wextra -fPIC -O2   -c -o src/blob.o src/blob.c
make: cc: Command not found
make: *** [src/blob.o] Error 127

What Do I have to do / to install to fix that error for me?

Vicent Marti
Owner
vmg commented

/cc @brianmario

I'm not sure about how to fix this. The Makefile.embed that we use to build libgit2 is designed for POSIX systems -- it won't work at all under Windows, even if the DevKit is installed.

Is there anyway we can ship Rugged gems with a pre-build libgit2 dll under Windows? How does that even work?

Brian Lopez
Collaborator

Would be so great!

stereobooster

If I build libgit2 dll on my windows machine using this instruction. What to do next?

Brent Matzelle

Is there any resolution to this issue? It is possible to create native builds on Windows with DevKit. The RDiscount project has figured out how to make it work for both Windows and Linux/UNIX. The build can be executed with a single command with DevKit (I've tested it):

gem install rdiscount --platform=ruby

Could a rugged developer please look at the RDiscount Rakefile and extconf.rb files to see if this cross-platform support can be added to rugged's build files? I volunteer to help with testing the builds on Windows.

BTW, I've already compiled libgit2 on Windows so I should have all the necessary files.

Brent Matzelle

Can anyone offer any insight into this issue? I'd be happy to help get the Windows build working but I'll need some direction.

Scott J. Goldman
Owner

The Makefile.embed that we use to build libgit2 is designed for POSIX systems -- it won't work at all under Windows, even if the DevKit is installed.

I think you mean, it won't work under windows... YET. :punch:

Vicent Marti
Owner
vmg commented

You could certainly write a Makefile.embed.w32, but the original one simply won't work.

Scott J. Goldman
Owner

since the commonly-used windows ruby devkit ships with mingw32, using one embedded makefile in libgit2 seems tractable. I sent out a PR here: libgit2/libgit2#776

of course i can create two makefiles if you think that would be better... i would just be nervous about keeping all 3 makefiles in sync.

Scott J. Goldman scottjg closed this in 5f300a8
Scott J. Goldman
Owner

until we release a new version of the gem, you can point your trusty Gemfiles to the updated code with:
gem "rugged", :git => "git://github.com/libgit2/rugged.git", :branch => "development"

Brent Matzelle

Thanks Scott!

I downloaded the development version of libgit2 and compiled it with cmake using MinGW. I tried running that command above and it didn't work:

build>gem "rugged", :git => "git://github.com/libgit2/rugged.git", :branch => "development"
ERROR: While executing gem ... (RuntimeError)
Unknown command rugged,

I added "gem install" like so:

build>gem install rugged :git => "git://github.com/libgit2/rugged.git", :branch => "development"

Unfortunately that didn't work either. Error below.

ERROR: Error installing rugged:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
*** 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.

Am I doing something wrong? I'm running Windows XP SP3.

stereobooster

@bmatzelle

Create Gemfile with following contents:

source :rubygems

gem "rugged", :git => "git://github.com/libgit2/rugged.git", :branch => "development"

Then run (from folder with Gemfile)

gem install bundler
bundle install

NOTE: it will not install gem globally. Read about bundler

Scott J. Goldman
Owner

right. alternatively you can clone the rugged git repository and just gem build rugged.gemspec and install the resulting gem

Brent Matzelle

@stereobooster

Thanks for that explanation. That got me going but it didn't work on my Windows development machine until I performed some tweaks to extconf.rb. I forked the repo and added the change. Here's the commit log:

bmatzelle@b6854a5

It should be cross-platform, except I'm concerned about that '/lib' directory part. Any thoughts on whether I should make a pull request on it?

BTW, I created the gem with the following Gemfile:

source :rubygems

gem "rugged", :git => "git://github.com/bmatzelle/rugged.git", :branch => "development"

Then I ran the following command on that Gemfile:

> set LIBGIT2_PATH=C:\Program Files\libgit2
> bundle install
Scott J. Goldman
Owner

@bmatzelle you shouldn't have to specify a LIBGIT2_PATH, rugged comes bundled with a libgit2 version that's known to work and will build it automatically. also while building the gem, devkit will automatically get added to your path, which should solve your which problem. did that not happen?

likewise, rugged uses the Makefile.embed in libgit2, not cmake, so i'm not sure all of these fixes are needed?

Brent Matzelle

@scottjg

you shouldn't have to specify a LIBGIT2_PATH, rugged comes bundled with a libgit2 version that's known to work and will build it automatically

That wasn't working for me. It failed in extconf.rb because it evaluated ENV['LIBGIT2_PATH'] and saw that it was nil and tried to extract the locally stored .gz build of libgit2.

also while building the gem, devkit will automatically get added to your path, which should solve your which problem. did that not happen?

It assume that it didn't detect DevKit because that if `which make`.strip.empty? command failed. Am I missing a switch in the 'bundle install' command? For instance, in order to inform Ruby to compile with DevKit I was informed to use gem install rdiscount --platform=ruby.

rugged uses the Makefile.embed in libgit2, not cmake, so i'm not sure all of these fixes are needed?

I used cmake for compiling libgit2 only. However bundler was running extconf.rb, which was attempting to create a makefile and failed (until I created my patch). Bundler didn't use the Makefile.embed. Maybe that's my issue?

I wrote the code because I didn't want to bother you guys with another "sorry guys, here's the next error message" so I decided to be proactive and get it working. I know the drill, however. My code might probably only work for for me and not be particularly useful to anyone else. I just wanted to show you guys I am legitimately trying to help. As it stands right now I have what's might be the first working win32 rugged gem on my computer, which is pretty nice. That helps me but not the entire rugged community. So is there anything else I can do/say that will help?

Scott J. Goldman
Owner

@bmatzelle why did it fail to extract the locally stored tar ball? was there an error?

FWIW, I had it installed straight from @scottjg url with no issue on MRI 1.9.3p194.

Scott J. Goldman scottjg reopened this
Scott J. Goldman
Owner

so i have discovered that my local environment has mingw in %PATH%. DevKit does ship with which but not with tar :(

stereobooster

Bundler didn't use the Makefile.embed

@bmatzelle just to clear up: Bundler manage dependencies, it doesn't compile gems. For compilation used native mechanism of rubygems. Here is nice tutorial

stereobooster

@scottjg why do you pack it as tar.gz and not using git submodule? Just curious.

[submodule "vendor/libgit2"]
    path = vendor/libgit2
    url = https://github.com/libgit2/libgit2.git
Scott J. Goldman scottjg closed this
Scott J. Goldman
Owner

ended up using a submodule

Brent Matzelle

Hey guys, I hate to go there again but that 'which make' issue is still there, even with the latest version:

C:\rugged>bundle install
Updating git://github.com/libgit2/rugged.git
Fetching gem metadata from http://rubygems.org/..
Using rugged (0.16.0) from git://github.com/libgit2/rugged.git (at development)
with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
.

        C:/Ruby193/bin/ruby.exe extconf.rb
*** 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:/Ruby193/bin/ruby
extconf.rb:11:in ``': No such file or directory - which make (Errno::ENOENT)
        from extconf.rb:11:in `<main>'
stereobooster

@bmatzelle in the latest DevKit there is which.exe in mingw\bin\. Update DevKit

Brent Matzelle

@stereobooster Thanks. That got me farther. Unfortunately the sub-module didn't work for some reason (I have the latest version of msysgit and TortoiseGit BTW). The directory is empty so I get this error:

        --ruby=C:/Ruby193/bin/ruby
extconf.rb:6:in `sys': ERROR: 'make -f Makefile.embed' failed (RuntimeError)
        from extconf.rb:30:in `block in <main>'
        from extconf.rb:29:in `chdir'
        from extconf.rb:29:in `<main>'
stereobooster

execute git submodule update --init. I'm just about to add it to Rakefile.

Scott J. Goldman
Owner

@bmatzelle not sure why this isn't the default, but to use bundler with submodules, you gotta do...

gem "rugged", :git => "git://github.com/libgit2/rugged.git", :branch => "development", :submodules => true

adding to the rakefile might be more foolproof..

stereobooster

add task to rakefile #83

Scott J. Goldman
Owner

merged @stereobooster's change so hopefully this work ok for @bmatzelle now!

Brent Matzelle

That did it! Thank you @scottjg and @stereobooster!

stereobooster

@bmatzelle did you run tests? bundle exec rake test or simply bundle exec rake ?

Brent Matzelle

@stereobooster I didn't run either of those commands. I just ran a local Ruby script on my machine and performed some simple operations, all of which worked so far. All of this work was in preparation for a Ruby project that uses Git but I won't be writing the actual code for at least a couple weeks.

stereobooster

All of this work was in preparation for a Ruby project that uses Git

Did you know that not all git operations are implemented in rugged. Take a look TODO

Brent Matzelle

@stereobooster No, but it doesn't matter. The project is an early phase so I can use Git command-line wrappers at first to provide the basic functionality until Rugged gets up to speed. Thanks for that TODO link. I'll be monitoring it.

stereobooster

Git command-line wrappers

take a look here https://github.com/mojombo/grit

Brent Matzelle

I already tried it but the posix-spawn gem dependency doesn't work with Windows:

http://stackoverflow.com/questions/9554556/does-grit-works-with-windows-7-well

Brent Matzelle

Interesting. I'll try that out. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.