fix(cli): properly parse project name on windows#5184
fix(cli): properly parse project name on windows#5184MichaelDoyle merged 2 commits intogenkit-ai:mainfrom
Conversation
Updated file path splitting to support both Windows and POSIX formats.
There was a problem hiding this comment.
Code Review
This pull request updates the projectNameFromGenkitFilePath function to support both Windows and POSIX path separators. A potential issue was identified where splitting by backslashes on POSIX systems could lead to incorrect results if a filename contains a backslash. It is recommended to use path.sep to determine the appropriate separator for the current operating system.
|
@CatoPaus thank you!! if you can apply the gemini suggestion above to use |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the projectNameFromGenkitFilePath function in genkit-tools/common/src/utils/utils.ts to use path.sep instead of a hardcoded forward slash when splitting file paths, which improves cross-platform compatibility. I have no feedback to provide.
Issue Description
Describe the bug
When launching the Genkit Developer UI (
genkit start) on a Windows machine without explicitly specifying anameinsidegenkit({ ... }), the Developer UI displays"unknown"for the project name (and falls back to something likeunknown (1234-3100)).This happens because
projectNameFromGenkitFilePathinside@genkit-ai/tools-commonrelies on splitting the.genkitruntime file path using a hardcoded forward slash (/). Because Windows file paths predominantly use backslashes (\), the function fails to locate the.genkitdirectory in the path string, resulting in the fallback"unknown".To Reproduce
nameproperty to yourgenkit()initialization.genkit start -- tsx --watch backend/index.ts.unknowninstead of the actual project directory or package name.Expected behavior
The Developer UI should correctly parse the project name from the file path on Windows exactly as it does on macOS and Linux.
Proposed Fix
Updating
projectNameFromGenkitFilePathto split the file path using a regular expression that accounts for both forward slashes and backslashes/[/\\]/resolves this issue entirely and remains safely cross-platform.File:
@genkit-ai/tools-common/src/utils/utils.tsCurrent Code:
Proposed Code: