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

scripts are not running by correct order in workspace recursive install #7811

Open
2 of 4 tasks
zxd65885152 opened this issue Mar 20, 2024 · 5 comments
Open
2 of 4 tasks

Comments

@zxd65885152
Copy link

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

8.15.5

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI, Hooks

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

In a monorepo organized by pnpm workspace:

pkg A has a prepare scripts to build itself and output to dist/ folder
{
"name": "A",
"version": "0.0.0",
"scripts": {
"prepare": "(build scripts)",
},
"publishConfig": {
"directory": "dist"
}
}

pkg B use pkg A in workspace with injected flag
{
"name": "B",
"version": "0.0.0",
"scripts": {
"prepare": "(build scripts)",
},
"dependencies": {
"A": "workspace:^"
},
"dependenciesMeta": {
"A": {
"injected": true
}
}
}

run pnpm install in pkg B, will get a response
 ENOENT  ENOENT: no such file or directory, scandir '..../A/dist'

Describe the Bug

in workspace, pnpm run install command in A & B with following order:

  1. parallel install deps of A & B
  2. run prepare scripts of A
  3. run prepare scripts of B

but to install deps of B, firstly it needs to run the prepare scripts of A.
without injected flag, pnpm can still create a symbol link to the unexist dist/ folder.
with injected flag, pnpm can only throw an error.

Expected Behavior

with injected flag, the order should be:

  1. install deps of A
  2. run prepare scripts of A
  3. install deps of B
  4. run prepare scripts of B

or give a option to disable parallel install.

Which Node.js version are you using?

18.18.2

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

@buqiyuan
Copy link

Duplicate of #6088

@alvis
Copy link
Contributor

alvis commented Apr 28, 2024

@buqiyuan probably it has the same cause as #6088, but the description of the problem isn't identical.

@alvis
Copy link
Contributor

alvis commented Apr 28, 2024

@zkochan any idea which files I can check to look for the cause of the issue? I can help

@alvis
Copy link
Contributor

alvis commented Apr 29, 2024

In fact it's a duplicate of #6976 and I have made a more or less similar MRE
https://github.com/alvis/mre_pnpm_monorepo_package_injected_peer_build_skipped

Here is the summary of the issue:

If you ignore shared-workspace-lockfile=false, the prepare script of the injected package is executed prior to the consuming package and everything is fine. But if you set shared-workspace-lockfile=false, the prepare script of the injected package is skipped before the prepare script of the consuming package is executed

@zxd65885152
Copy link
Author

thx a lot for @alvis 's work.
I've rechecked my repo's pnpm config and unfortunately found the shared-workspace-lockfile=false.
Hope that this issue will be fixed soon or I need to consider whether to ignore that config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants