fix(vibe): save .env API key file to project root instead of CWD#1322
Open
Ananya-Kaushal137 wants to merge 1 commit intomofa-org:mainfrom
Open
fix(vibe): save .env API key file to project root instead of CWD#1322Ananya-Kaushal137 wants to merge 1 commit intomofa-org:mainfrom
Ananya-Kaushal137 wants to merge 1 commit intomofa-org:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes an issue where the vibe command would save the user's OpenAI API key to a
.envfile in the current working directory instead of the project root. This effectively resolves the problem of "lost" API keys when running the command from a subdirectory.Closes #1258
Context
During the interactive
mofa vibesetup, if an OpenAI API key is missing, it prompts the user to enter and save it. Previously, the saving logic usedos.path.join(os.getcwd(), '.env')while the loading logic correctly used the project root.If a user ran
mofa vibefrom a subdirectory (e.g.,examples/), the key was written locally to that subdirectory. Subsequent runs from other directories would fail to locate the key, frustrating the user and continuously prompting for setup. This change unifies the file path logic.Changes
os.getcwd()path in mofa/commands/vibe.py with the existing _get_env_file_path() helper..envfile consistently.How you Tested
cd /path/to/project/subdirectory).OPENAI_API_KEYfrom the environment.mofa vibeCLI.Yto save it to.env..envfile was correctly generated in the project root, and no.envfile was created in the immediate working directory.