Skip to content

Lifecycle scripts for hosted git and local dependencies not run on install #5235

Closed
@rtsao

Description

@rtsao

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:

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.

Metadata

Metadata

Assignees

Labels

fixed-in-modernThis issue has been fixed / implemented in Yarn 2+.triaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions