-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
'husky install' fails if '.git' directory does not exists #851
'husky install' fails if '.git' directory does not exists #851
Comments
Hi @mondeja, Thanks for the report. It's fixed in |
Thank you @typicode! 🙏 |
This is still an issue:
https://github.com/gajus/fast-printf/blob/master/package.json#L32 |
I'm running v5.0.9 and am getting this error :-(
|
Can't seem to reproduce, here's how I'm testing:
Is your Otherwise could you provide minimal steps for me to reproduce (or a repo)? |
We get the issue when we use a repo as a dependency. e.g. in package.json: For more information on how this works see: https://docs.npmjs.com/cli/v6/commands/npm-install We have followed the advice to use pinst to work around this issue:
But get the error when installing the updated version:
|
Thanks for the details. This is a bit of an edge case. When you publish a package on npm, Here, this step is not run and when AFAIK I don't think there's a way to detect that. Personally, I would remove |
Having the same issue... Trying to install via npm swagger-ui-react (swagger link) BUT im getting this error.. as a devDependency husky installed.. if there is an option to fix that? |
@IevgeniiK-AVISPL seems to be fixed by |
"scripts": {
"prepare": "cd .. && husky installtemplate/.husky",
...
} this worked for me |
I'm experiencing common issue with husky 8.0.1 where .git folder and package.json are on the same lvl, but in the end I get : |
You can do |
Thanks it worked |
…ir at .git according to typicode/husky#851 (comment)
I have the same problem in version ^7.0.4 Should I try this workaround
? |
## What's the purpose of this pull request? Fix husky + lint-staged that runs pre-commit lints for core packages. |Before|After| |-|-| |<img width="833" alt="Screenshot 2023-03-15 at 16 57 30" src="https://user-images.githubusercontent.com/11325562/225429287-ca4e4c1a-b7ac-4921-927a-b667fe24b431.png">|<img width="833" alt="Screenshot 2023-03-15 at 16 57 37" src="https://user-images.githubusercontent.com/11325562/225429495-12efa3bb-bbac-41df-9b86-c7623b93553f.png">| Should should also see this scripts running pre commits: <img width="771" alt="Screenshot 2023-03-15 at 17 05 06" src="https://user-images.githubusercontent.com/11325562/225429666-afa29d0c-92f2-414e-858f-8a8e3da41a79.png"> ## How to test it? - run `yarn` command. - you should see the pre commit lint tasks after a commit as well 😉 ## references typicode/husky#851
if you are encountering error when adding some githook like |
Still not work, can I skip in CI?Not found a option to skip in ci. |
Finally ,I found the error is. |
make prepare husky key _prepare so it doesn't run on ci servers See typicode/husky#851 (comment) Do not publish this. Just for internal use to get builds working
What is the recommendation if you don't control the repo you're installing? with the following dependency in package.json:
I still cannot install even when trying to disable husky:
edit: Updating to 8.0.3 fixed this for me I think. I was on ^7.0.2 before |
function install(dir = '.husky') {
if (process.env.HUSKY === '0') {
l('HUSKY env variable is set to 0, skipping install');
return;
}
if (git(['rev-parse']).status !== 0) {
l(`git command not found, skipping install`);
return;
}
const url = 'https://typicode.github.io/husky/#/?id=custom-directory';
if (!p.resolve(process.cwd(), dir).startsWith(process.cwd())) {
throw new Error(`.. not allowed (see ${url})`);
}
if (!fs.existsSync('.git')) {
throw new Error(`.git can't be found (see ${url})`);
}
try {
fs.mkdirSync(p.join(dir, '_'), { recursive: true });
fs.writeFileSync(p.join(dir, '_/.gitignore'), '*');
fs.copyFileSync(p.join(__dirname, '../husky.sh'), p.join(dir, '_/husky.sh'));
const { error } = git(['config', 'core.hooksPath', dir]);
if (error) {
throw error;
}
}
catch (e) {
l('Git hooks failed to install');
throw e;
}
l('Git hooks installed');
} So,the question maybe because the logic of So, the solution maybe is let https://stackoverflow.com/questions/27177248/how-can-i-make-git-work-only-on-the-current-directory |
|
Hi, To generate .husky folder, we can approach the below line of code in the script tag for any nested project folder "prepare": "cd ../../ && husky install .husky", Regards, |
## Summary - Add [`actions/github-script`](https://github.com/marketplace/actions/github-script) types - Add [`@octokit/webhook-types`](https://www.npmjs.com/package/@octokit/webhooks-types) for improved payload typing - Use JSDoc wizardry to typecheck the JavaScript files used by our workflows ## Notes I got a husky error when installing the `github-script` types. Here is a related issue: typicode/husky#851 Upgrading husky resolves the error, so I created a pull request: actions/github-script#482 I installed `github-script` using the PR number for now. We can unpin the PR once it's merged by re-installing via the [command in the doc](https://github.com/actions/github-script/#use-scripts-with-jsdoc-support): ```sh npm i -D @types/github-script@github:actions/github-script ```
## Summary - Add [`actions/github-script`](https://github.com/marketplace/actions/github-script) types - Add [`@octokit/webhook-types`](https://www.npmjs.com/package/@octokit/webhooks-types) for improved payload typing - Use JSDoc wizardry to typecheck the JavaScript files used by our workflows ## Notes I got a husky error when installing the `github-script` types. Here is a related issue: typicode/husky#851 Upgrading husky resolves the error, so I created a pull request: actions/github-script#482 I installed `github-script` using the PR number for now. We can unpin the PR once it's merged by re-installing via the [command in the doc](https://github.com/actions/github-script/#use-scripts-with-jsdoc-support): ```sh npm i -D @types/github-script@github:actions/github-script ```
yes! it is effective,You helped a Chinese boy, and I can't find the relevant information on the Chinese website。 |
I have a
postinstall
script in a NPM package:If I download the repository using Github UI (Code -> Download ZIP), after extracting it, executing
npm install
raisesError: .git can't be found
:postinstall error
I can prevent the error doing something like this:
But it seems a bit hacky. What would be the recommended way to solve this?
The text was updated successfully, but these errors were encountered: