Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

git ls-files in gemspec template is bad practice. #2287

Closed
courtland opened this issue Jan 30, 2013 · 3 comments
Closed

git ls-files in gemspec template is bad practice. #2287

courtland opened this issue Jan 30, 2013 · 3 comments

Comments

@courtland
Copy link

Would it be possible to change the default gem.files line in the default gemspec template found here: https://github.com/carlhuda/bundler/blob/master/lib/bundler/templates/newgem/newgem.gemspec.tt

In my rails application, I frequently use gems in my Gemfile with a :git repository option, however my deployment/production systems do not have git and re-downloading the git tree every time is not desirable. I now rely on the latest version of Bundler's "bundle package -all" feature, where the git tree is packaged up nicely into vendor/cache/repo_name... I then commit that to my source control tree.

When a gemspec contains git ls-files, bundle install --deployment on the production system gives a fatal error because the git repository (.git directory) is not included in the packaged gem directory (created from the git checkout).

Please refer to this issue here for a more detailed discussion:
savonrb/savon#380 (comment)

I run into this problem a lot with gems when using :git and :path options in my Gemfile in conjunction with "bundle package" and "bundle install --deployment". I am trying to start a better trend where people stop using git ls-files and other git commands in their gemspec because it wrongly assumes the consumer of the gem has access to git and the git repository during production.

Thanks.

@indirect
Copy link
Member

indirect commented Feb 1, 2013

Please try the prerelease of Bundler 1.3! It solves this problem by caching the result of evaluating the gemspec when you run bundle package --all. That means that in production git is never invoked.

@indirect indirect closed this as completed Feb 1, 2013
@courtland
Copy link
Author

Sounds good. Thanks.

If I bundle package --all a git repo in Bundler 1.3, can it be used in production with Bundler 1.2?

@indirect
Copy link
Member

indirect commented Feb 1, 2013

Yup. 1.3 rewrites the gemspecs, and 1.2 will just read them.

dLobatog added a commit to dLobatog/hammer-cli-foreman that referenced this issue Dec 17, 2013
git ls-files does not always give the right result, and installations
from source might fail to build the gem properly because of this (see
    http://pastie.org/8557757).

See the issues below for longer discussions on this:
rodjek/rspec-puppet#111
rubygems/bundler#2287
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants