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 under Windows 7 #43

Closed
mliebelt opened this issue Mar 4, 2012 · 38 comments
Closed

Unable to install rugged under Windows 7 #43

mliebelt opened this issue Mar 4, 2012 · 38 comments

Comments

@mliebelt
Copy link

mliebelt commented Mar 4, 2012

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?

@vmg
Copy link
Member

vmg commented Mar 4, 2012

/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?

@brianmario
Copy link
Contributor

We could give cross-compiling a try - I do that for mysql2 and yajl-ruby. Although I don't ship mysql2 with the libmysql.dll itself, we could probably build and ship libgit2.dll pretty easily (assuming it builds under the compilers I use http://crossgcc.rts-software.org/doku.php)

On Sunday, March 4, 2012 at 6:54 AM, Vicent Martí wrote:

/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?


Reply to this email directly or view it on GitHub:
#43 (comment)

@emassip
Copy link

emassip commented Mar 12, 2012

Would be so great!

@stereobooster
Copy link
Contributor

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

@bmatzelle
Copy link

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.

@bmatzelle
Copy link

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.

@scottjg
Copy link

scottjg commented Jun 19, 2012

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. 👊

@vmg
Copy link
Member

vmg commented Jun 19, 2012

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

@scottjg
Copy link

scottjg commented Jun 20, 2012

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.

@scottjg
Copy link

scottjg commented Jun 20, 2012

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"

@bmatzelle
Copy link

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
Copy link
Contributor

@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

@scottjg
Copy link

scottjg commented Jun 21, 2012

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

@bmatzelle
Copy link

@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:

https://github.com/bmatzelle/rugged/commit/b6854a59c7e0dc4275a1ab02281fae19790d8de1

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

@scottjg
Copy link

scottjg commented Jun 21, 2012

@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?

@bmatzelle
Copy link

@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?

@scottjg
Copy link

scottjg commented Jun 21, 2012

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

@emassip
Copy link

emassip commented Jun 21, 2012

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

@scottjg scottjg reopened this Jun 21, 2012
@scottjg
Copy link

scottjg commented Jun 21, 2012

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

@stereobooster
Copy link
Contributor

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
Copy link
Contributor

@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

@scottjg
Copy link

scottjg commented Jun 22, 2012

ended up using a submodule

@scottjg scottjg closed this as completed Jun 22, 2012
@bmatzelle
Copy link

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
Copy link
Contributor

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

@bmatzelle
Copy link

@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
Copy link
Contributor

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

@scottjg
Copy link

scottjg commented Jun 22, 2012

@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
Copy link
Contributor

add task to rakefile #83

@scottjg
Copy link

scottjg commented Jun 23, 2012

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

@bmatzelle
Copy link

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

@stereobooster
Copy link
Contributor

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

@bmatzelle
Copy link

@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
Copy link
Contributor

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

@bmatzelle
Copy link

@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
Copy link
Contributor

Git command-line wrappers

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

@bmatzelle
Copy link

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

@stereobooster
Copy link
Contributor

mojombo/grit#4

@bmatzelle
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants