"Unable to load application: GitVersionBump::VersionUnobtainable:" error on Windows
When attempting to use git-version-bump -h or any derivative of such, following error is produced;
$ git-version-bump
The system cannot find the path specified.
The system cannot find the path specified.
The system cannot find the path specified.
d:/Ruby200/lib/ruby/gems/2.0.0/gems/git-version-bump-0.15.1/lib/git-version-bump.rb:299:in `gem_version': GVB.version(false) failed; perhaps you need to install git? (GitVersionBump::VersionUnobtainable)
from d:/Ruby200/lib/ruby/gems/2.0.0/gems/git-version-bump-0.15.1/lib/git-version-bump.rb:37:in `version'
from d:/Ruby200/lib/ruby/gems/2.0.0/gems/git-version-bump-0.15.1/lib/git-version-bump/version.rb:2:in `<module:GitVersionBump>'
from d:/Ruby200/lib/ruby/gems/2.0.0/gems/git-version-bump-0.15.1/lib/git-version-bump/version.rb:1:in `<top (required)>'
from d:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from d:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from d:/Ruby200/lib/ruby/gems/2.0.0/gems/git-version-bump-0.15.1/lib/git-version-bump.rb:308:in `<top (required)>'
from d:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from d:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from d:/Ruby200/lib/ruby/gems/2.0.0/gems/git-version-bump-0.15.1/bin/git-version-bump:3:in `<top (required)>'
from d:/Ruby200/bin/git-version-bump:23:in `load'
from d:/Ruby200/bin/git-version-bump:23:in `<main>'
The error suggests that I do not have git installed, which I do and is the latest version for windows.
$ git --version
git version 1.9.5.msysgit.0
I looked over the code and thought maybe the git_available function was failing, but I am not well versed with ruby to say for sure.
That's rather strange. Unfortunately, since I don't use Windows, and haven't got access to a Windows machine, it's rather tricky for me to test out any solutions. I suspect that the problem is likely to be that the system method doesn't use a bourne-compatible shell on Windows.
Can you try modifying line 234 to remove the >/dev/null 2>&1 from the command being run? If that doesn't help, try changing the line to read system("git", "--version"). Which one of those works will give me a reasonable idea of what exactly is needed on Windows to make everything work. Of course, if neither of them work, I'm not sure where we'll go from there...
Ahh, after some debugging I was able to get it to run. However, it's the bare minimum. You can see the modified file here:
https://gist.github.com/KarnSaheb/11d81dab48ab95d55106
Things that I changed: Removed the >/dev/null 2>&1 as you suggested and removed the "Shell quotes" (seems that windows spits out the dir paths with quotes around the path).
Are you sure you put the modified file in the gist? Line 234 still has the output redirection in it.
I tried deleting >/dev/null 2>&1 and now my error is on line 296 instead. not sure what "shell quotes" is referring to
The gist works for me on Windows (at least for the basic use-case of just requiring the gem). I just pasted it over the existing file and it solved the problem I was having, which was that this gem was causing Rack Contrib to fail to load.
@mpalmer are you interested in working together on a fix for this? I'm happy to try and help, but I have the inverse problem to you, in that I have no Linux machines to hand to test with.
I've made some good progress with a couple of simple (and hopefully uncontentious) changes on my fork: https://github.com/benbasson/git-version-bump/tree/windows-compatibility
Only one issue left that I'm aware of on the critical path (I haven't run through all the use-cases yet). The surrounding single quotes (commented "Shell Quoted, for your convenience") seem to always cause Git to return status code 128 and complain that it can't find the directory. I hacked out these single quotes locally and it works, but that's probably not the right answer, so I'll look at how to properly escape the string in a cross-platform way.
I don't really know much about shell quoting, but I've simply branched the logic for Windows / *nix so that the arguments passed to the shell are different depending on the platform in use. This seems to solve my problems and unless I'm missing anything should be backwards compatible. @mpalmer if this stuff looks good to you I'm happy to send a PR.
@benbasson Feel free to send along your PR for a look. In principle, I'd prefer to get away from using the shell entirely, and pass the arguments directly (and eat the output), but I doubt I'll get time to do that myself any time soon, so your platform-differentiating approach is probably the best until then.
Hiya - any thoughts on the PR? I just came across the issue again and switched to my branch for now.
+1 for the merging the PR, would be really useful to get this into the main branch
+1 I'm experiencing this failure as well - I'd appreciate a solution that works reliably b/c we have to help other developers (including windows devs) install our OSS application, and this is a real problem for them.. Thanks!