Reputation: 61
I'm trying to initiate astro. When i don't choose a framework i get this error although i have git installed and fully working. Any help will be highly appreciated.
√ Which frameworks would you like to use? »
> Copying project files...
could not find commit hash for latest
This seems to be an issue with degit. Please check if you have 'git' installed on your system, and install it if you don't have (https://git-scm.com).
If you do have 'git' installed, please file a new issue here: https://github.com/withastro/astro/issues
Upvotes: 6
Views: 911
Reputation: 1323263
It depends on your OS and environment.
For instance, withastro/astro
issue 2144 reports the exact same error message, but on Windows, using Linux on WSL2 (Ubuntu 20.04.3 LTS).
Double-check your %PATH%
/$PATH
in your execution environment.
Update Oct. 2022, ten months later: withastro/astro
issue 2144 is reported closed with the workaround by Matej Bunček:
As I was researching this seems to be a general issue with NPM for those who uses SSH.
There's an open issue here: npm/cli#2610 which is still far from being resolved, and it's a huge thread.Some folks might be interested in these workarounds to get it working.
git config --global url."https://github.com/".insteadOf [email protected]: git config --global url."https://".insteadOf git://
Also I've tried
yarn
,npm
andpnpm
, all of them seems to have same problem so I believe it's core problem of node.
Also, bothnpm
6 and 7 are not working.
Depends on the use case, but this helped me in CI pipeline (github app token as
GH_TOKEN
env var is used for authentication but PAT should work too):git config --global --remove-section url."ssh://[email protected]" &> /dev/null
Redirecting output to
/dev/null
helps to avoid error if section doesn't exist.
Feb. 2024, the same npm/cli
issue 2610 proposes (by Diego Gangl):
Here's the workaround I've been using for a while. I wrote a small script to replace the
git+ssh
togit+https
inpackage-lock.json
.const fs = require("fs"); const path = require("path"); // I keep this file in a scripts folder const packagelock = path.resolve(__dirname, "../package-lock.json"); fs.readFile(packagelock, "utf8", (err, data) => { if (err) { return console.log(err); } const result = data.replace( /\"resolved\"\:\s\"git\+ssh:\/\/git\@github\.com\/my\/repo\.git/g, '"resolved": "git+https://[USERNAME]:[TOKEN]@github.com/my/repo.git' ); fs.writeFile(packagelock, result, "utf8", (err) => { if (err) { return console.log(err); } else { return console.log("Package lock was fixed"); } }); });
I run this in the dockerfile before running
npm install
RUN node scripts/fix_package_lock.js RUN npm install --production
Upvotes: 1
Reputation: 1738
Not a direct solution to your error message, but a general solution for those kinds of errors:
I would recommend doing the development inside docker containers, so called devcontainers.
Since you will develop in separate and isolated environments containing only the project's minimum dependencies and tools, it is a lot less likely to face OS specific issues in general.
Here are some resources to get started:
Upvotes: 0