Skip to content

fix the exec.LookPath issue #112

Closed

Description

@AnnatarHe

in file https://github.com/shelltime/cli/blob/main/model/ccusage_service.go#L213 and https://github.com/shelltime/cli/blob/main/model/ccusage_service.go#L214, we call exec.LookPath to get the executable bunx or npx. But it could not find the daemon service. maybe because the PATH is not inherited from the env.

pls create a custom LookPath function try to find the properly executable binary.

@claude

Activity

  1. claude commented on Oct 2, 2025

    @claude
    Contributor

    Claude finished @AnnatarHe's task —— View job • claude/issue-112-20251002-0939 • Create PR ➔


    Fixed the exec.LookPath issue ✓

    Analysis

    Found the issue at model/ccusage_service.go:213-214. The code uses exec.LookPath to find bunx and npx executables, but when running as a daemon service, the PATH environment variable may not include user-specific Node.js installation paths.

    Solution

    Created a custom lookPath function that:

    • First tries the standard exec.LookPath (checks system PATH)
    • Falls back to checking common installation locations for Node.js package managers
    • Supports multiple platforms (Windows, macOS, Linux)
    • Handles various package managers (npm, pnpm, bun, nvm)
    • Checks for executable permissions on Unix-like systems

    The function searches these locations:

    • User-specific paths: ~/.npm-global/bin, ~/.npm/bin, ~/.local/share/pnpm, ~/.bun/bin, ~/.nvm/current/bin
    • Homebrew paths (macOS): /usr/local/bin, /opt/homebrew/bin
    • System paths: /usr/bin, /bin
    • Windows paths: AppData npm/bun installations, Program Files nodejs
    • NVM paths: Uses NVM_DIR environment variable when available

    Changes

    • Added lookPath() function in model/ccusage_service.go:212-296
    • Replaced exec.LookPath calls with lookPath at lines 301-302
    • Added imports for filepath and runtime packages

    Tasks

    • Read and understand the current implementation in model/ccusage_service.go
    • Design a custom LookPath function for finding node package managers
    • Implement the custom lookup function
    • Replace existing exec.LookPath calls with the new function
    • Commit and push changes
    • Provide PR link

    Next Steps

    --- | Branch: claude/issue-112-20251002-0939

  2. added a commit that references this issue on Oct 2, 2025
    dd10653
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions