Skip to content

Improve PnP mode detection and Berry-compatible install options#313

Merged
dd-jy merged 2 commits into
mainfrom
yarn
Jun 1, 2026
Merged

Improve PnP mode detection and Berry-compatible install options#313
dd-jy merged 2 commits into
mainfrom
yarn

Conversation

@dd-jy
Copy link
Copy Markdown
Contributor

@dd-jy dd-jy commented Jun 1, 2026

Description

Improve PnP mode detection and Berry-compatible install options

Summary by CodeRabbit

Release Notes

Bug Fixes

  • Improved Yarn Berry (v2+) compatibility and PnP mode detection for more reliable dependency resolution.
  • Enhanced handling when node_modules directory is missing during installation.
  • Better automatic configuration detection across different Yarn versions and setup modes.

@dd-jy dd-jy self-assigned this Jun 1, 2026
@dd-jy dd-jy added the enhancement [PR/Issue] New feature or request label Jun 1, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

Warning

Review limit reached

@dd-jy, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 14 minutes and 59 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f8f95f02-bb56-479d-b626-47d9f5438bd4

📥 Commits

Reviewing files that changed from the base of the PR and between 8c3b0ed and 4a03be0.

📒 Files selected for processing (1)
  • src/fosslight_dependency/package_manager/Yarn.py
📝 Walkthrough

Walkthrough

Enhanced Yarn Berry (v2+) PnP mode detection by checking for .pnp.cjs/.pnp.js files or parsing .yarnrc.yml for nodeLinker configuration. When node_modules is missing, the yarn install command varies by detected Yarn version and PnP mode to properly initialize the workspace.

Changes

Yarn Berry PnP mode detection and installation

Layer / File(s) Summary
PnP mode detection
src/fosslight_dependency/package_manager/Yarn.py
Regex import enables multi-step PnP detection: checks for .pnp.cjs/.pnp.js files, otherwise reads .yarnrc.yml and extracts nodeLinker via regex to determine PnP mode, defaulting to PnP when nodeLinker is unset.
Version and mode-aware yarn install
src/fosslight_dependency/package_manager/Yarn.py
yarn install command now varies by Yarn major version and PnP mode: Yarn Berry uses --mode=skip-build with optional YARN_NODE_LINKER=node-modules in PnP mode; Yarn Classic uses --production --ignore-scripts.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: improved PnP mode detection logic and better Yarn Berry install command handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yarn

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/fosslight_dependency/package_manager/Yarn.py`:
- Around line 67-84: The detection logic in Yarn.py leaves is_pnp_mode False
when .yarnrc.yml is missing even though Yarn Berry defaults to pnp; update the
check so that if .yarnrc.yml does not exist you inspect for the presence of
.pnp.cjs or .pnp.js and, if neither exists, set is_pnp_mode = True (treat as
default PnP); adjust the branch around the existing nodeLinker parsing
(referencing is_pnp_mode, yarnrc_path, node_linker and the log messages) so
missing .yarnrc.yml + no .pnp.* files triggers the PnP log and behavior.
- Around line 91-101: The current code constructs yarn_install_cmd with a
POSIX-style env assignment ("YARN_NODE_LINKER=node-modules yarn ...") and calls
subprocess.run(..., shell=True), which fails on Windows; change the logic in the
function/method that builds and executes yarn_install_cmd (referencing
yarn_install_cmd and the subprocess.run call) to set the environment variable
via a modified env dict passed to subprocess.run (e.g., copy os.environ, set
YARN_NODE_LINKER='node-modules' when is_pnp_mode) and keep the command string as
"yarn install --mode=skip-build" (without inline assignment), removing the
POSIX-only assignment and ensuring subprocess.run receives env=env_dict (and you
can drop or keep shell=True as appropriate for the plain command).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 07be7958-7055-4a5c-96bb-beced34917a6

📥 Commits

Reviewing files that changed from the base of the PR and between 9edefb6 and 8c3b0ed.

📒 Files selected for processing (1)
  • src/fosslight_dependency/package_manager/Yarn.py

Comment thread src/fosslight_dependency/package_manager/Yarn.py Outdated
Comment thread src/fosslight_dependency/package_manager/Yarn.py Outdated
…tions

Signed-off-by: 석지영/책임연구원/SW공학(연)Open Source TP <jiyeong.seok@lge.com>
Signed-off-by: 석지영/책임연구원/SW공학(연)Open Source TP <jiyeong.seok@lge.com>
@dd-jy dd-jy merged commit 32fee48 into main Jun 1, 2026
14 checks passed
@dd-jy dd-jy deleted the yarn branch June 1, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement [PR/Issue] New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant