Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
When a hosted git dependency is installed, lifecycle scripts are not run (e.g. prepare
)
If the current behavior is a bug, please provide the steps to reproduce.
Run yarn add user/repo
or yarn add github:user/repo
. No lifecycle scripts will be run.
What is the expected behavior?
prepare
should be run on install (like with npm@5)
Please mention your node.js, yarn and operating system version.
Node.js 9.4.0
Yarn 1.3.2
MacOS 10.13
I've done some investigation as to why this broken. This is what I've found:
#3553 added the correct behavior, but only for git fetching, meaning the dependency was actually fetched via git.
Because Yarn recognizes certain git hosts, Yarn will install these dependencies via HTTP/tarball method instead of git (presumably for performance). So if this logic is triggered (which will happen with dependencies formatted like repo/user
or github:repo/user
, then the appropriate lifecycle scripts won't be run.
Related issues:
- add RFC for script run hooks rfcs#70
- yarn doesn't run prepublish script and include EVERTHING into the package when adding a local dependency #1671
- yarn does not run lifecycle scripts when installing from repository #2815
- Installing package from github URL doesn't trigger prepublish script #2875
- Workspaces don't run lifecycle scripts when linking local packages #3911
- Post-install scripts don't execute #4973
- Yarn does not run
prepack
when installing Git dependencies #5047
I'd be interested in making a PR to resolve this, but figured I'd make an issue first. I'm thinking that the logic for running lifecycle scripts in src/fetchers/git-fetcher.js
should probably be moved into the more generic src/fetchers/base-fetcher
, since per #3911 lifecycle scripts should be run for non-git dependencies as well.