You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run npm install --save git+ssh://[email protected]:bmahsman/bubblegum.git, npm checks out the text files that git lfs puts in place of the actual assets. It appears npm isn't using my local user account's ~/.gitconfig, i.e. the filters aren't being used and git-lfs is not being executed.
The issue could be with npm, but I wonder if git lfs install only sets up git lfs for the current user, while npm install is using some kind of global settings for all users. I detail the issue more in this question, which no one has answered after a month. Any help is appreciated.
After poring over the output from git and npm with export GIT_TRACE=1 and npm config loglevel verbose, I believe I have figured out how to get this to work, at least with GitLab (I have since moved from GitHub to GitLab, which also supports Git LFS).
Step 1. Inside of your repository, run the following command (replace bubblegum with the name of your repo) and then commit the resulting .gitconfig and push:
note: For this to work with GitHub, it would appear that the lfs.url to use is: https://api.github.com/lfs/<user or organization>/<repository name>, e.g.
The .gitconfig you commit to the repository allows the git commands used by npm install to know what lfs.url to use. I'm not sure if this solution only masks the fact that npm install can't figure out the lfs.url without you explicitly specifying it in .gitconfig. In other words, when I run the command git clone https://gitlab.com/brynn.mahsman/bubblegum.git, git somehow knows the lfs.url even if I don't have the .gitconfig in the repository. Would someone please enlighten me as to whether this is something npm install should be able to do without having to write this .gitconfig?
edit: This solution apparently disables batch mode when retrieving files from GitLab.
If your git host supports LFS properly, the LFS endpoint should always be your git remote with a "/info/lfs" suffix. You should only have to configure lfs.url if your LFS service is hosted separately from your Git service.
GitHub's lfs-authenticate command over SSH does return that "api.github.com" url, but https://github.com/brynn.mahsman/bubblegum.git/info/lfs works just fine too.
You can run git lfs env to see what url it will attempt to use.
$ git lfs env
git-lfs/1.1.0 (GitHub; darwin amd64; go 1.5.1; git fbbfd7d)
git version 2.5.4 (Apple Git-61)
Endpoint=https://github.com/github/git-lfs.git/info/lfs (auth=none)
Endpoint (dev)=http://github.dev/technoweenie/whatever.git/info/lfs (auth=none)
Thanks for helping me out with this. Knowing that <url>/info/lfs is standard simplifies things a lot.
Do you have any idea why npm install does not have the proper lfs.url on its own without having to tell it explicitly with a .gitconfig in the repository?
I noticed that when you give npm install a repository it first makes a bare clone with --mirror in its cache directory, and then attempts to make a non-bare clone from that, which then is the basis for the files it installs to node_modules/bubblegum/.
Is there something about creating a bare mirror on the local filesystem that makes it lose the ability for your Git host to report the correct lfs.url?
Git LFS replaces pointers on checkout to the working directory. I don't think bare clones will do anything LFS related. If npm wants to support LFS, they'd have to download the actual objects manually. Git LFS doesn't really have any convenient commands for it, but they could be added if npm wanted to add support.
Thanks. In that case, I believe this is now entirely in npm's court. I'll make an issue in their project and see if they want to support it. The .gitconfig workaround should suffice for now.
I noticed that when you give npm install a repository it first makes a bare clone with --mirror in its cache directory, and then attempts to make a non-bare clone from that, which then is the basis for the files it installs to node_modules/bubblegum/.
Ok, I think I get what's happening, and why you need the .gitconfig:
The first repo is a clone from a remote git host. But since it's a bare clone, LFS is not invoked at all. The second repo is a clone of the bare repo. Its origin remote is some local file path, and not a remote git host. That's why you need the .gitconfig.
Perhaps the client could detect this, and look at the config of the repo's local origin to get the original remote git host?
From seeing this message, it sounds like you're trying to use a local Windows path to clone, which won't work. If you're using the latest master, you can instead specify a file URL (not a local path), like this: file:///c%3a/Some/Path/Component/Here. This feature isn't in 2.8.0, but it should be in 2.9.0 when that's released.
Could you please open a new issue for this, then, including the information requested in the CONTRIBUTING file? This sounds like a different issue than this one.
Activity
animeoakes commentedon Dec 17, 2015
I made an issue on npm as well. npm/npm#10857
technoweenie commentedon Dec 20, 2015
Git LFS doesn't understand the
git+sshprotocol. You can use[email protected]:bmahsman/bubblegum.gitinstead.animeoakes commentedon Jan 14, 2016
After poring over the output from
gitandnpmwithexport GIT_TRACE=1andnpm config loglevel verbose, I believe I have figured out how to get this to work, at least with GitLab (I have since moved from GitHub to GitLab, which also supports Git LFS).Step 1. Inside of your repository, run the following command (replace
bubblegumwith the name of your repo) and then commit the resulting.gitconfigand push:Step 2. In the directory in which you want to
npm installyour project, run for example:note: For this to work with GitHub, it would appear that the
lfs.urlto use is:https://api.github.com/lfs/<user or organization>/<repository name>, e.g.The
.gitconfigyou commit to the repository allows the git commands used bynpm installto know whatlfs.urlto use. I'm not sure if this solution only masks the fact thatnpm installcan't figure out thelfs.urlwithout you explicitly specifying it in.gitconfig. In other words, when I run the commandgit clone https://gitlab.com/brynn.mahsman/bubblegum.git,gitsomehow knows thelfs.urleven if I don't have the.gitconfigin the repository. Would someone please enlighten me as to whether this is somethingnpm installshould be able to do without having to write this.gitconfig?edit: This solution apparently disables batch mode when retrieving files from GitLab.
technoweenie commentedon Jan 14, 2016
If your git host supports LFS properly, the LFS endpoint should always be your git remote with a "/info/lfs" suffix. You should only have to configure
lfs.urlif your LFS service is hosted separately from your Git service.GitHub's lfs-authenticate command over SSH does return that "api.github.com" url, but
https://github.com/brynn.mahsman/bubblegum.git/info/lfsworks just fine too.You can run
git lfs envto see what url it will attempt to use.animeoakes commentedon Jan 14, 2016
Thanks for helping me out with this. Knowing that
<url>/info/lfsis standard simplifies things a lot.Do you have any idea why
npm installdoes not have the properlfs.urlon its own without having to tell it explicitly with a.gitconfigin the repository?I noticed that when you give
npm installa repository it first makes a bare clone with--mirrorin its cache directory, and then attempts to make a non-bare clone from that, which then is the basis for the files it installs tonode_modules/bubblegum/.Is there something about creating a bare mirror on the local filesystem that makes it lose the ability for your Git host to report the correct
lfs.url?technoweenie commentedon Jan 14, 2016
Git LFS replaces pointers on checkout to the working directory. I don't think bare clones will do anything LFS related. If npm wants to support LFS, they'd have to download the actual objects manually. Git LFS doesn't really have any convenient commands for it, but they could be added if npm wanted to add support.
animeoakes commentedon Jan 14, 2016
Thanks. In that case, I believe this is now entirely in npm's court. I'll make an issue in their project and see if they want to support it. The
.gitconfigworkaround should suffice for now.technoweenie commentedon Jan 14, 2016
Ok, I think I get what's happening, and why you need the
.gitconfig:The first repo is a clone from a remote git host. But since it's a bare clone, LFS is not invoked at all. The second repo is a clone of the bare repo. Its
originremote is some local file path, and not a remote git host. That's why you need the.gitconfig.Perhaps the client could detect this, and look at the config of the repo's local
originto get the original remote git host?add .gitconfig for lfs file as a workaround for npm install
add .gitconfig for lfs file as a workaround for npm install
feugy commentedon Oct 6, 2016
Hi there.
Although this problem is on npm side, I post here a workaround for other users
We got the same problem here, but workaround provided by zxcpoiu didn't work due to authentication (we're using a private repo).
After some research on Git Enterprise Doc, we found that providing a
.lfsconfigfile on the repo that has lfs items solved the issue:pjho commentedon Nov 8, 2016
@feugy champion! Cheers for that.
For anyone else on bitbucket I needed to drop the
ssh://to get that working so:vincentvent commentedon Aug 26, 2019
I could not get this to work on github. Trying to npm install a private repo and I get:
Error downloading object: ************************ : batch request: ssh: Could not resolve hostname c: Name or service not known: exit status 255I added the .gitconfig URL and ran npm install https://githubrepo
Everything clones well except for the LFS file.
bk2204 commentedon Aug 26, 2019
From seeing this message, it sounds like you're trying to use a local Windows path to clone, which won't work. If you're using the latest
master, you can instead specify a file URL (not a local path), like this:file:///c%3a/Some/Path/Component/Here. This feature isn't in 2.8.0, but it should be in 2.9.0 when that's released.vincentvent commentedon Aug 26, 2019
Thank you @bk2204 I am using a URL
npm install https://githubrepoIn the .gitconfig
bk2204 commentedon Aug 26, 2019
Could you please open a new issue for this, then, including the information requested in the CONTRIBUTING file? This sounds like a different issue than this one.
add .gitconfig for lfs file as a workaround for npm install
add .gitconfig for lfs file as a workaround for npm install
add .gitconfig for lfs file as a workaround for npm install
add .gitconfig for lfs file as a workaround for npm install
add .gitconfig for lfs file as a workaround for npm install