git warnings when running a binary inside a folder that is not a git repo #6

Open
bowsersenior opened this Issue Aug 7, 2012 · 2 comments

Projects

None yet

2 participants

@bowsersenior

Hi,

We ran across this issue with gauntlt, but I think it is a more general issue. When a gem with a binary using acclaim is installed (gem install gauntlt) there are git warnings when running the executable:

$ gauntlt
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
... normal output here ...

I believe the issue is that the 'acclaim.gemspec' is being loaded here:

This gemspec, like most gemspecs, has a line with backticks to get the files:

The problem is that this line makes no sense at this point, since that line is for building the gem before pushing to rubygems. The reason that there are 3 warnings is because the same issue occurs with ribbon and jewel.

I am not sure what the solution here is. I noticed a similar issue with bundler that was resolved a while back:

Really appreciate your help and advice on resolving this!

Thanks,
Mani

@matheusmoreira

Hi,

Thank you for your detailed report, I really appreciate your help. This is definitely a bug.

I created Jewel to centralize access to gem metadata, so the specification is loaded and available at runtime. In Acclaim, the path to the gem's directory is needed to access the template files.

The problem is that the gemspecs currently use git to generate the list of files. When a binary is executed and the gems required, git tries to access the repository in the current directory and likely fails. It will probably be even worse if the user doesn't have git at all. I suppose the files of an entirely unrelated repository could end up in the gemspec, too.

It shouldn't break everything but, as you described, it did result in undesirable error messages being printed as a side effect.

Bundler's fix gave me some good ideas — chdiring into the directory will probably result in a more robust solution and cleaner API — it's already in my TODO list for Jewel.

However, in the end the fix will consist of removing the git call and using a pure Ruby solution, probably Dir.glob. It will be implemented in all of my projects.

Again, thanks for pointing this out! I will work on this as soon as I get home.

@bowsersenior

Thanks for the quick and detailed response. I think you are right in terms of the eventual solution by using Dir.glob. I used to rely on Dir.glob for setting the files in a gemspec until a couple of years ago, when the git ls-files approach was popularized by bundler.

It seems that there is a fundamental problem with the git ls-files approach, which is clever, but introduces a dependency on git. There doesn't seem to be any thought given to using the gemspec in any context outside of building the .gem package for rubygems. This is an area that rubygems needs improvement on for tasks like extracting metadata, etc.

FYI, for the time being, I've switched to Trollop for command line parsing but I look forward to being able to go back to using acclaim soon, as it is much easier to use and produces nicer output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment