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 npm package doesn't work when installed with esy #623
Comments
Hey @giltho , thanks for the issue! Just curious - what version of
I know the feeling 😄 I was curious if I looked at this briefly - Line 294 in d59ec6c
( husky uses the 'install' script to hook everything up).
Husky makes some assumptions about the path - it tries to look upward to see where it needs to set up the hooks:
I suspect that these assumptions might not be valid in the install environment we use for One starting point we need is to log the output of the lifecycle scripts - it doesn't look like we do that today. I don't see it written to a file anywhere but @andreypopp might know for sure. There's some information in the logging of husky that could help guide us to see exactly what's wrong. |
Yeah, I think I've tried to add
Then after installing it with yarn — hooks weren't activated for me. I've tried to find if In the future I think we need to add sandboxing to npm's lifecycle (install/postinstall/...) like we do for builds on macOS — so that lifecycle can only modify files inside their corresponding package's directory. It is much safer. |
Sorry indeed, I forgot my configuration :
The weird thing that I don't understand is how the |
Indeed but it is husky's philosophy right ? The point is to force users to install your hooks so they cannot commit without going through hooks. You lose that if they have to manually execute husky |
The published npm package has
Maybe, I still think hooks are for convenience — you'd still want to validate invariants hooks are trying to force on CI or something like that. |
I understand your point, although I don't think husky is going to change. Do you believe esy should implement commands that execute install scripts for packages ? |
I can't say for sure at this point. Maybe husky can be changed to work with yarn's pnp — then it will be working with esy automatically (before the point we add sandboxing but then we can implement whitelist or something like that). |
To come back on @bryphe point, how should I proceed if I want to make a PR that logs the output of lifecycle scripts ? |
We really have to add sandboxing to npm lifecycle:
https://twitter.com/garybernhardt/status/1062760973457514496 |
@giltho I suggest checking out esy@0.4.0 Then look at https://github.com/esy/esy/blob/master/esyi/FetchStorage.ml#L295 for how it executes hooks. I think the problem is that husky expects itself to be in some |
Yes sorry I misspoke, I've read a bit about plug'n'play and I understood better how husky is installing hooks after your comments. And indeed, the issue seems to be on husky's side. What I meant is that it is still interesting to have the logs of lifecycle scripts printed out when executing esy. I've started modifying FetchStorage on my side and I have something that I believe works. I simply redirect the output of the process to stdout & stderr. The thing is that I do not know what you think about that. I do not like to use pervasives constants like |
We use You can add logging by adding lines like
I think debug level is the right one for that kind of log messages. |
I don't really know how it works, I was just speculating. |
That would mean we do not write things as they happen but only once everything happens. (I'll ping you on discord) |
This PR adds a script that generates a new Reason module named `Fnm__Package` and a script that verifies that it is up to date. `Fnm__Package` will have `package.json` information necessary for the app, like its version. Unfortunately, [`husky` doesn't work with esy](esy/esy#623) so I can't use it for generating git hooks and have a `pre-commit` script that verifies `Fnm__Package` and reformats using `refmt`
For the sake of completeness on this issue. Husky is now compatible with yarn 2 (and therefore pnp), but there's a bit of yarn-specific configuration that happens there. I.e, there's a configuration in Husky to use it with Yarn, when it is activated, nice things happen that are compatible with yarn pnp. Mostly, it tells husky to call scripts through yarn instead of npm (typicode/husky#511 and yarnpkg/berry#102). |
In general, how difficult would it be to build a pre-commit hook solution that's perfectly compatible (maybe even recommended) by I have some time in the next few weeks, so I'd love to investigate building a sort of "official" pre-commit formaatting hook for Reason/OCaml, though I'd definitely need some input before starting. |
Hey @dylanirlbeck, I wanted to answer that 9 days ago when you pinged me and I felt like this wasn't really constructive, but I changed my mind:
|
Hello,
I was using esy to work on a small project, and I have a bad habit of writing terrible commit messages, which is why I installed
husky
+ commitlint through esy. However, it does not seem that the hooks were properly installed (as it would be the case when installing through npm).The thing is, I have no idea when the
_install
script ofhusky
is called. And I don't thinkdevinstall
is one of the npm scripts...The text was updated successfully, but these errors were encountered: