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

berks install fails to fetch git repository dependencies that use git-lfs #1825

Open
maoe opened this issue Sep 17, 2019 · 0 comments · May be fixed by #1826
Open

berks install fails to fetch git repository dependencies that use git-lfs #1825

maoe opened this issue Sep 17, 2019 · 0 comments · May be fixed by #1826

Comments

@maoe
Copy link

maoe commented Sep 17, 2019

We have a Chef cookbook that uses git-lfs to store some binaries. If we depend on it from other cookbooks, berkshelf fails to fetch it during berks install like this:

Fetching 'some-cookbook' from git@git.example.com:chef/some-cookbook.git (at master)
Git error: command `git reset --hard 977350841d8984d56feb3b98faed6a86b22efb79` failed. If this error persists, try remo
ving the cache directory at '/home/maoe/.berkshelf/.cache/git/e41334cf49b248784779d83338e08899eee8ef5d'.Output from the
 command:


hint: The remote resolves to a file:// URL, which can only work with a
hint: standalone transfer agent.  See section "Using a Custom Transfer Type
hint: without the API server" in custom-transfers.md for details.
Downloading files/default/some-binary.ubuntu-16.04 (152 MB)

hint: The remote resolves to a file:// URL, which can only work with a
hint: standalone transfer agent.  See section "Using a Custom Transfer Type
hint: without the API server" in custom-transfers.md for details.
Error downloading object: files/default/some-binary.ubuntu-16.04 (d297b69): Smudge error: Error downloading files/default/some-binary.ubuntu-16.04 (d297b6970253e17f5e835261ca7645d364a0a23cd73b25ad30ae1f3e4c6fd506): batch request: missing protocol: "file:///home/maoe/.berkshelf/.cache/git/e41334cf49b248784779d83338e08899eee8ef5d/.git/info/lfs"

Errors logged to /tmp/d20190917-15282-4oev7p/.git/lfs/logs/20190917T111501.394111993.log
Use `git lfs logs last` to view the log.
error: external filter 'git-lfs filter-process' failed
fatal: files/default/some-cookbook.ubuntu-16.04: smudge filter lfs failed

        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/mixin/git.rb:24:in `git'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/locations/git.rb:57:in `block in install'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/locations/git.rb:55:in `chdir'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/locations/git.rb:55:in `install'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/installer.rb:193:in `block in download_locations'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/installer.rb:190:in `each'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/installer.rb:190:in `download_locations'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/installer.rb:160:in `install_from_universe'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/installer.rb:43:in `run'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/berksfile.rb:405:in `install'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/cli.rb:131:in `install'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/cli.rb:47:in `dispatch'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/lib/berkshelf/cli.rb:23:in `execute!'
        /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/berkshelf-7.0.7/bin/berks:5:in `<top (required)>'
        /usr/bin/berks:306:in `load'
        /usr/bin/berks:306:in `<main>'

Apparently this happens because berkshelf clones a bare repository as a cache and clone it to another workspace locally, but unfortunately git-lfs doesn't support fetching from local repositories so git reset --hard #{@revision} fails with the error messages above.

I guess we can do either of the following:

  • Use git %{clone --no-checkout --reference="#{cache_path}" #{url} "#{scratch_path}"}
    • This way the origin would be set to url instead of cache_path. It could be slower though.
  • Check if the repository uses git-lfs somehow. If so skip caching.
    • I'm not sure how to check it though.

What do you think? If the former sounds good I can make a patch.

FWIW I'm using berkshelf 7.0.7 on Ubuntu.

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

Successfully merging a pull request may close this issue.

1 participant