Skip to content

Fix npm CLI symlink entrypoint detection#19

Merged
fakechris merged 1 commit intomainfrom
fix/npm-cli-symlink-entrypoint
Apr 18, 2026
Merged

Fix npm CLI symlink entrypoint detection#19
fakechris merged 1 commit intomainfrom
fix/npm-cli-symlink-entrypoint

Conversation

@fakechris
Copy link
Copy Markdown
Owner

@fakechris fakechris commented Apr 18, 2026

Summary

  • resolve the CLI entrypoint guard against real paths instead of raw argv path comparison
  • keep the fallback URL comparison for direct execution
  • make npm-installed symlinked bin entrypoints execute the CLI instead of silently exiting

Validation

  • pnpm --filter @turnkeyai/involute build
  • node packages/cli/dist/index.js --help
  • symlinked entrypoint check against the built CLI

Open in Devin Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

Warning

Rate limit exceeded

@fakechris has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 28 minutes and 34 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 28 minutes and 34 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cb2cf551-9b98-4de5-9632-207ea0bab67f

📥 Commits

Reviewing files that changed from the base of the PR and between 9ac9833 and c5018d4.

📒 Files selected for processing (1)
  • packages/cli/src/index.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/npm-cli-symlink-entrypoint

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

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the CLI entry point detection logic by introducing a new isCliEntrypoint function that utilizes realpathSync for more reliable path comparison. A potential issue was identified in the fallback logic where an unhandled exception could occur if path resolution fails; a nested try-catch block was suggested to improve robustness.

Comment thread packages/cli/src/index.ts
Comment on lines +1203 to +1213
function isCliEntrypoint(entryPoint: string | undefined): boolean {
if (!entryPoint) {
return false;
}

try {
return realpathSync(entryPoint) === realpathSync(fileURLToPath(import.meta.url));
} catch {
return import.meta.url === pathToFileURL(entryPoint).href;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The fallback logic in the catch block uses pathToFileURL(entryPoint), which can throw a TypeError if entryPoint is a relative path (Node.js requires an absolute path for pathToFileURL). While realpathSync usually resolves relative paths to absolute ones, if it fails for other reasons (e.g., permission issues on a parent directory), the fallback will crash the process with an unhandled exception. Consider wrapping the fallback in a nested try-catch or ensuring the path is absolute before conversion.

Suggested change
function isCliEntrypoint(entryPoint: string | undefined): boolean {
if (!entryPoint) {
return false;
}
try {
return realpathSync(entryPoint) === realpathSync(fileURLToPath(import.meta.url));
} catch {
return import.meta.url === pathToFileURL(entryPoint).href;
}
}
function isCliEntrypoint(entryPoint: string | undefined): boolean {
if (!entryPoint) {
return false;
}
try {
return realpathSync(entryPoint) === realpathSync(fileURLToPath(import.meta.url));
} catch {
try {
return import.meta.url === pathToFileURL(entryPoint).href;
} catch {
return false;
}
}
}

@fakechris fakechris merged commit feb962d into main Apr 18, 2026
3 checks passed
@fakechris fakechris deleted the fix/npm-cli-symlink-entrypoint branch April 18, 2026 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant