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

Error: "Could not find commit hash for master" #37

Closed
andymerskin opened this issue Oct 4, 2018 · 44 comments · Fixed by #243
Closed

Error: "Could not find commit hash for master" #37

andymerskin opened this issue Oct 4, 2018 · 44 comments · Fixed by #243

Comments

@andymerskin
Copy link

Hey there—I'm trying to get started with Svelte and running:

Environment:

  • macOS 10.14 Mojave
  • Node v8.11.4
  • degit v2.1.3

Running:

degit sveltejs/template-webpack

... gives me:

! could not find commit hash for master

Double checking that the user/repo is correct, I'm not really sure why it can't find the hash. I tried it with a couple other repos out there and no-go.

Any ideas?

@andymerskin
Copy link
Author

Well derp, I was trying to run this on a new Macbook Pro that I hadn't installed Xcode or the Command Line Tools on, so git wasn't ready to go yet. Now that it's installed, I tried degit again and everything worked like a charm.

It may be pertinent in the rare cases when people don't have git properly configured (who even does that?!) that degit properly pass any errors along that may occur like this.

@paulocoghi
Copy link

Would be interesting if degit doesn't depend on git to work. I was trying to figure out for weeks why some team mates had the same issue. 😄

@Webzeugmacher
Copy link

git update helped on windows 10

@oliverjanik
Copy link

I just updated to latest git on Win 10 same problem:

PS C:\Users\Oliver\dev> degit svetlejs/template svetle-test
! could not find commit hash for master

Any more ideas?

@andymerskin
Copy link
Author

@oliverjanik Could you make sure git is on your PATH (or at least usable with the git command in your prompt?) It's possible you need to relink it after updating or installing.

@oliverjanik
Copy link

Yeah git is usable from the same prompt.

@osdevisnot
Copy link

This error manifests itself in Travis CI too. Trying to use degit there currently results in this error:

(node:5343) UnhandledPromiseRejectionWarning: Error: could not find commit hash for master
    at Degit.clone (/home/travis/build/osdevisnot/tslib-cli/node_modules/degit/index.js:170:10)
    at Object.<anonymous> (/home/travis/build/osdevisnot/tslib-cli/cli.js:39:15)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

@DerBasler
Copy link

I had the same problem using it in my wsl shell but had no problem using it in my powershell.
I was using git version 2.11.0 in my powershell and 1.9.1 in my wsl. Maybe that helps someone.

@paulocoghi
Copy link

I replaced degit with lukeed/gittar, and it's sufficient for what I need.

It isn't a pure replacement, and maybe doesn't have all the features you are using on degit, but it can suit most use cases.

@paulocoghi
Copy link

paulocoghi commented May 11, 2019

@docmars , @Rich-Harris

I think we can close this issue, because I don't think anymore that it would be the case to adapt degit to don't depend on git, because it's exactly what gittar does.

We can live with both libraries, each one with its pros and cons.

Degit has more features, but requires git. Gittar is more simple, but doesn't requires git. Each developer chooses the one it sees fit.

@osdevisnot
Copy link

Agree with @paulocoghi here. For my small project I ended up using gittar as well.

@bigidea-kz
Copy link

maybe you need to write about it in the documentation?

@cogoo
Copy link

cogoo commented May 22, 2019

Setting the cache value to false in the degit options solved this for me:

degit(repo, {
      cache: false,
      force: true,
      verbose: true,
    });

@paulocoghi
Copy link

@cogoo, in the most cases, this error occurs when git isn't available/installed.

@cogoo
Copy link

cogoo commented May 23, 2019

@cogoo, in the most cases, this error occurs when git isn't available/installed.

I have git installed. With cache: true it attempts to find the repo from a local cache, which is what caused the error for me

@paulocoghi

@jspinella
Copy link

Thanks for saving me some time on this one... same situation, just did a phresh install with Catalina. You'd think the error message would be a little more... helpful.

@alexljamin
Copy link

alexljamin commented Sep 24, 2019

Just updated Xcode in App Store but did not open it. Tried to run the degit and got

! could not find commit hash for master

After starting the updated Xcode for the first time it installed some components and after that, degit command worked just fine

@riazXrazor
Copy link

thanks @cogoo it worked !!

@vguhesan
Copy link

vguhesan commented Sep 28, 2019

If you're seeing the following error(s):
`$ npx degit https://github.com/sveltejs/sapper-template#rollup my-app

! could not find commit hash for rollup`

or

`$ npx degit https://github.com/sveltejs/sapper-template#webpack my-app

! could not find commit hash for webpack`

It's because git isn't working. git depends on xcode and xcode requires you to accept it's license agreement.

Try running "git" and if you see the following message:
$ git Agreeing to the Xcode/iOS license requires admin privileges, please run “sudo xcodebuild -license” and then retry this command.
then type:
sudo xcodebuild -license and follow instructions for scrolling through the license agreement. At the end, you will need to type "agree" then
At that point, your original command should work fine.

Also if you haven't installed degit you may need to do the following:
sudo npm install -g degit

@masterl
Copy link

masterl commented Oct 7, 2019

I have the same error with sveltejs/template.

Doc said to just run degit sveltejs/template svelte-app

Results:

$ degit sveltejs/template svelte-app
! could not find commit hash for master

What Version
Linux Manjaro 18.1.0 Juhraya
Git 2.23.0
Node 12.9.1
NPM 6.11.2
Degit 2.1.4

I use git everyday without any problems.
Cloning the svelte template repo manually works without problems.

@vguhesan
Copy link

vguhesan commented Oct 7, 2019

@masterl did you try what I have suggested above?
#37 (comment)

@masterl
Copy link

masterl commented Oct 8, 2019

@vguhesan That doesn't apply.
I'm not on a mac.
I have git installed and configured.

Everything is on the comment, I have git, node, npm, degit all installed.
As I also said above, I can clone the repo directly without any problems.

The issue seems to be on degit itself.

@paulocoghi
Copy link

@masterl , can you try again with cache: false ?

@masterl
Copy link

masterl commented Oct 9, 2019

@paulocoghi Where do I use that?

running degit --help the cache option doesn't even have a parameter:
--cache, -c Only use local cache


I tried running with this flag, but the result was the same:

degit -c sveltejs/template svelte-app
! could not find commit hash for master

@paulocoghi
Copy link

@masterl , unfortunately you are right.

As mentioned by @cogoo and @riazXrazor, when using degit on code (not as cli), setting cache to false on the options may solve this problem

But it seems that we can't do the same on cli.

@PlkMarudny
Copy link

So, how to disable caching in degit?

@paulocoghi
Copy link

@PlkMarudny , this way:

degit(<repo_url>, {
    cache: false
});

@Conduitry
Copy link

Conduitry commented Dec 29, 2019

I was just looking into getting degit to display more helpful error messages when it runs into a problem, and I found that it does display the underlying error if you call it with the verbose -v flag. Does it make sense to always display that error? I'm hoping that will eliminate a lot of questions in Svelte issues and the chatroom about this. In the meantime, now that I know this, I suppose we can tell people to run it again with -v so we can get some sort of idea of what's happening.

Edit: Or perhaps less intrusively: a gentle extra note that's displayed when there's an error with verbose mode off that the user can add -v to get more logging.

@thinkOfaNumber
Copy link

I know this thread is covering a lot of different issues now, but I had the same "could not fetch remote":

npx degit "sveltejs/sapper-template#webpack" sapper-test
! could not fetch remote https://github.com/sveltejs/sapper-template
! could not find commit hash for webpack

but it turns out that my .gitconfig in my home directory had an invalid http proxy that I could no longer access. Hope this helps someone.

@bernardoadc
Copy link

bernardoadc commented Feb 12, 2020

Would be interesting if degit doesn't depend on git to work. I was trying to figure out for weeks why some team mates had the same issue. 😄

@paulocoghi What if degit supports cloning local repos? That wouldn't work. I think we should properly display error messages so people can act to solve problems, not dodge them

@paulocoghi
Copy link

@bernardoadc , you are right 👍 I had not thought about this possibility and, in this case, it is interesting that degit uses git.

Since gittar is a good alternative when all you want is to clone public repos, I believe that we have good options for any case.

@hypersundays
Copy link

I know this thread is covering a lot of different issues now, but I had the same "could not fetch remote":

npx degit "sveltejs/sapper-template#webpack" sapper-test
! could not fetch remote https://github.com/sveltejs/sapper-template
! could not find commit hash for webpack

but it turns out that my .gitconfig in my home directory had an invalid http proxy that I could no longer access. Hope this helps someone.

I was getting this same error trying to run degit through npx. Once I installed degit globally, everything worked like a charm

@EitharAlotoom95
Copy link

I run this "degit sveltejs/template my-svelte-project" on git terminal not the cmd .. and it works .
just right click then choose git bash here and run the command there . I hope that will be helpful .

@rdela
Copy link

rdela commented Nov 23, 2020

fregante's mention above of #242/#207 helped me figure my encounter with this error message out
when I ran it with the -v option per Conduitry's suggestion I got: > destination directory is empty, not helpful.
but the problem was I needed to append the branch, #trunk in this case, because this repo does not have a master branch.

@netaisllc
Copy link

Note that Github itself has seemingly begun to default new repos to a main branch.

Today I ran into what looked like a degit issue (! could not find commit hash for master) which actually wasn't degit's problem. There indeed wasn't a master branch. As soon as I created one and ran degit again there was much joy.

@paulocoghi
Copy link

paulocoghi commented Dec 6, 2020

A PR adding a check to see which branch is available between main and master can solve the scenario mentioned by @netaisllc .

Edit:

This PR (#243) from @fregante , provides an even better approach: read the default branch.

@rajeeshsays
Copy link

D:\ANZ104AngularDemo\ANZ104AngularDemo\angular\taskbox>degit chromaui/intro-storybook-angular-template
! could not fetch remote https://github.com/chromaui/intro-storybook-angular-template
! could not find commit hash for HEAD
Pls give a solution...

@rdela
Copy link

rdela commented Aug 12, 2021

hi @rajeeshsays, please open an issue on the repository in question, as:

npx degit chromaui/intro-storybook-svelte-template taskbox

from intro-storybook-svelte-template works fine, and the command that you presumably ran correctly in a supported environment is in their readme:

npx degit chromaui/intro-storybook-angular-template taskbox

@wangjia184
Copy link

installed the latest git version 2.34.1.windows.1

Failed with same error

@glayn2bukman
Copy link

glayn2bukman commented Sep 23, 2022

turns out the github repo is at sveltejs/template not svelte/template and as such the command should be
npx degit sveltejs/template <your-project-name>

@pixelbadger01
Copy link

Hello. I am getting this error:

' degit radixdlt/create-scrypto-dapp
! could not download https://github.com/radixdlt/create-scrypto-dapp/archive/75feed25fadafa73dbd8349974d755087afd44b3.tar.gz '

I took the liberty of checking the comments before me, and I can confirm Git is working so I'm just wondering what else I can look into.

Yes the URL is also fine.

@paulocoghi
Copy link

... it does display the underlying error if you call it with the verbose -v flag

For @NateDawg360 and everyone else: please use -v (verbose mode) to display the root cause, as already explained on the thread by Conduitry

@vdawg-git
Copy link

vdawg-git commented Nov 11, 2023

I am also getting this error while using the JS Api I am on Arch Linux, with git installed.
Setting cache to false, solves this.
Enabling verbose does not result in a more descriptive error.

Its the error in the title + that it cannot find the commit hash of the repo

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.