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

Failure of install of packages when using git dependency with husky as prepare script #1213

Open
piranna opened this issue Nov 7, 2022 · 6 comments

Comments

@piranna
Copy link

piranna commented Nov 7, 2022

I'm installing a project from a git repo that I've downloaded locally. This project has a git dependency that itself is running husky install as a prepare script, as documentation recommends. This execution fails with error husky - .git can't be found (see https://typicode.github.io/husky/#/?id=custom-directory). I think it should not be executed at all, both by using a different script, or detect when it's not being run from a top level package.

@titan-ron
Copy link

titan-ron commented Nov 8, 2022

Hi!

I encountered this too, I'm using it everywhere:

"prepare": "husky install || exit 0"

I wonder if it's relevant as the standard for husky package 🤔

Another idea:

"prepare": "npx husky install"

The first option is good to me for cases when on CI I don't mind if it will fail and don't install the hooks

Of course, the new HUSKY=0 could help as well

@piranna
Copy link
Author

piranna commented Nov 9, 2022

These solutions are fine, but not smart enough. We just only want to don't crash when used as git dependency, when your first one will just swallow all errors, and second one will do an extra global install of husky. Maybe look if it's being run from inside a node_modules subfolder?

@famu1hundred
Copy link

Also having this issue with version 8.0.2
.husky and .git are at the same level in directory, however getting

husky - .git can't be found (see https://typicode.github.io/husky/#/?id=custom-directory)

@paescuj
Copy link
Contributor

paescuj commented Jan 6, 2023

@piranna Would you be able to provide a quick reproduction? I wasn't able to reproduce it on the rapid...

@famu1hundred Sounds like a different issue or is this about a git dependency, too?

@piranna
Copy link
Author

piranna commented Jan 6, 2023

@piranna Would you be able to provide a quick reproduction? I wasn't able to reproduce it on the rapid...

Since they were git dependencies that didn't changed too much, I've just published them as private packages of GPR, and problem dissapeared, so it would be a bit difficult to create a new reproduction of the issue.

@paescuj
Copy link
Contributor

paescuj commented Jan 6, 2023

@piranna Would you be able to provide a quick reproduction? I wasn't able to reproduce it on the rapid...

Since they were git dependencies that didn't changed too much, I've just published them as private packages of GPR, and problem dissapeared, so it would be a bit difficult to create a new reproduction of the issue.

I see! Actually, I rather thought of some quick steps / commands to reproduce this. Here is what I did (as mentioned above the problem didn't arise):

echo "Node: $(node -v) | npm: $(npm -v)"

# Some git repo with husky
git clone git@github.com:open-cli-tools/concurrently.git

mkdir test && cd test
npm init

npm install ../concurrently
Node: v18.12.1 | npm: 9.2.0

Edit: Okay, while writing this I've just realized that you probably meant a git dependency without being a git repo anymore...

# Download zip of a git repo with husky
wget https://github.com/open-cli-tools/concurrently/archive/refs/heads/main.zip
unzip main.zip && rm main.zip && mv concurrently-main concurrently

mkdir test && cd test
npm init

npm install ../concurrently

However in my case I'm getting this (probably because npm installs dependencies in ./test):

npm ERR! code 127
npm ERR! path /Users/<...>/concurrently
npm ERR! command failed
npm ERR! command sh -c husky install
npm ERR! sh: husky: command not found

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

No branches or pull requests

4 participants