Skip to content

fix(model): implement custom lookPath for node package managers#113

Merged
AnnatarHe merged 5 commits intomainfrom
claude/issue-112-20251002-0939
Oct 2, 2025
Merged

fix(model): implement custom lookPath for node package managers#113
AnnatarHe merged 5 commits intomainfrom
claude/issue-112-20251002-0939

Conversation

@AnnatarHe
Copy link
Copy Markdown
Contributor

Replace exec.LookPath with a custom lookPath function that checks common installation locations for bunx and npx executables. This fixes the issue where the daemon service cannot find these executables because the PATH environment variable doesn't include user-specific Node.js installation paths.

Fixes #112


Generated with Claude Code

Replace exec.LookPath with a custom lookPath function that checks
common installation locations for bunx and npx executables. This
fixes the issue where the daemon service cannot find these executables
because the PATH environment variable doesn't include user-specific
Node.js installation paths.

The custom lookPath function:
- First tries standard exec.LookPath (system PATH)
- Falls back to checking common locations (npm, pnpm, bun, nvm)
- Supports multiple platforms (Windows, macOS, Linux)
- Checks for executable permissions on Unix-like systems

Fixes #112

Co-authored-by: Le He <AnnatarHe@users.noreply.github.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @AnnatarHe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where the daemon service could not locate bunx or npx executables because the system's PATH environment variable often lacks user-specific Node.js installation directories. To fix this, a custom lookPath function has been implemented. This new function intelligently searches a comprehensive set of common installation locations for these package managers across different operating systems, ensuring the service can reliably find and utilize them.

Highlights

  • Custom Executable Search: A new lookPath function has been introduced to locate bunx and npx executables more reliably.
  • Daemon Service Compatibility: This change addresses an issue where daemon services failed to find bunx or npx due to limitations in the PATH environment variable, which often lacks user-specific Node.js installation paths.
  • Expanded Search Paths: The custom lookPath now intelligently searches a comprehensive set of common installation locations for Node.js package managers (e.g., user-specific npm, pnpm, bun, NVM, Homebrew directories) in addition to the standard system PATH.
  • Cross-Platform Support: The new lookPath function includes specific search logic tailored for both Windows and Unix-like operating systems.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 2, 2025

Codecov Report

❌ Patch coverage is 0% with 81 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
model/ccusage_service.go 0.00% 81 Missing ⚠️
Flag Coverage Δ
unittests 20.53% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
model/ccusage_service.go 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AnnatarHe
Copy link
Copy Markdown
Contributor Author

you also need to support search fnm folder as well @claude

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Oct 2, 2025

Claude finished @AnnatarHe's task —— View job


Added fnm support ✓

  • Read current implementation in model/ccusage_service.go
  • Add fnm directory paths to custom lookPath function
  • Commit and push changes

I've added support for fnm (Fast Node Manager) to the custom lookPath function in model/ccusage_service.go:254-255,274-279. The implementation includes:

  1. Standard fnm installation paths:

    • ~/.local/share/fnm/node-versions/*/installation/bin/
    • ~/.fnm/node-versions/*/installation/bin/
  2. FNM_DIR environment variable support (similar to NVM_DIR):

    • Checks for the FNM_DIR environment variable
    • Searches $FNM_DIR/node-versions/*/installation/bin/ if set

These paths follow the same glob pattern approach used for nvm, allowing the function to find executables across different Node.js versions managed by fnm.


Job RunBranch

Copy link
Copy Markdown
Contributor

@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 introduces a custom lookPath function to locate Node.js package manager executables like bunx and npx beyond the system's PATH. This is a good approach to handle cases where daemon services run with a minimal environment. The implementation is generally solid, but I've identified a few areas for improvement to enhance its correctness and maintainability. My suggestions focus on using filepath.Join consistently for path construction, refining the logic for selecting NVM versions to prefer newer ones, and updating an error message for better clarity.

Comment thread model/ccusage_service.go
Comment thread model/ccusage_service.go Outdated
Comment thread model/ccusage_service.go Outdated
github-actions Bot and others added 4 commits October 2, 2025 09:51
Add Fast Node Manager (fnm) installation paths to the custom lookPath
function. This includes both standard fnm locations (~/.local/share/fnm
and ~/.fnm) as well as support for the FNM_DIR environment variable.

The implementation mirrors the existing NVM support, searching for
executables in fnm's node-versions subdirectories.

Co-authored-by: Le He <AnnatarHe@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@AnnatarHe AnnatarHe merged commit 63020ad into main Oct 2, 2025
2 of 3 checks passed
@AnnatarHe AnnatarHe deleted the claude/issue-112-20251002-0939 branch October 2, 2025 16:14
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.

fix the exec.LookPath issue

1 participant