FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix-windows-python-init by shettyvarun268 · Pull Request #10608 · firebase/firebase-tools · GitHub

fix-windows-python-init - #10608

Merged
shettyvarun268 merged 4 commits into
mainfrom
fix-windows-python-init
Jun 12, 2026
Merged

fix-windows-python-init#10608
shettyvarun268 merged 4 commits into
mainfrom
fix-windows-python-init

Conversation

Copy link
Copy Markdown
Contributor

This pull request fixes a bug on Windows where initializing Firebase Functions with Python fails during the dependency installation step, throwing a misleading error that says it cannot find the file activate.bat (ENOENT).

The Problem
During investigation, we found that this error is caused by two different issues. First, if a user does not have Python installed or configured in their system PATH, the step to create the virtual environment fails silently because the Firebase CLI does not check its exit code. The CLI then moves on to execute the activation script, which fails because the virtual environment folder was never actually created.

Second, even if a user has Python installed, the installation command tries to run pip3 directly to upgrade pip. On Windows, the operating system locks the pip3 executable while it is running, which causes the upgrade to fail. In both of these failure cases, a quirk in the command-spawning library on Windows translates the failure into a misleading "file not found" error for the activate.bat file, hiding the real root cause.

The Solution
To fix these issues, we updated the virtual environment creation step to output python errors directly to the terminal and to verify the command's exit code. If the virtual environment fails to build (due to a missing Python installation), the CLI now stops immediately and shows a clear error message.

We also changed the dependency commands to use python -m pip instead of calling pip3 directly. This approach is the recommended standard because it runs the command through the Python interpreter, avoiding the Windows file-locking issue. Finally, we added unit tests to ensure that the Python codebase is initialized with the correct configuration and that failures are caught and reported properly.

gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Code Review

This pull request improves the Python virtual environment setup and dependency installation during functions initialization by capturing process exit codes and throwing user-friendly FirebaseErrors on failure. It also adds corresponding unit tests. The review feedback correctly points out that if the spawned processes fail to execute (e.g., due to a missing binary), the 'error' event will reject the promise and bypass the FirebaseError checks. Resolving the promises with a non-zero exit code on error will ensure these failures are handled gracefully.

Comment thread src/init/features/functions/python.ts Outdated
Comment thread src/init/features/functions/python.ts Outdated
Comment thread src/init/features/functions/python.ts Outdated

Copy link
Copy Markdown
Contributor Author

/gemini review

gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Code Review

This pull request refactors the Python functions initialization process by introducing helper functions for virtual environment creation and dependency installation, resolving version-specific Python binaries, and upgrading pip safely on Windows. It also adds comprehensive unit tests for these flows. The reviewer suggests extracting the duplicated promise-based process waiting logic across the new helper functions into a single reusable waitForProcess helper to reduce duplication and align with the repository's style guide.

Comment thread src/init/features/functions/python.ts Outdated
shettyvarun268 marked this pull request as ready for review June 10, 2026 19:10

ajperel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm very unfamiliar with this code. It seems fine but might not be a bad idea to get a second review from someone more familiar. Left one quick comment.

Also... a few warnings in the tests that would be good to resolve.

Comment thread src/init/features/functions/python.ts Outdated
shettyvarun268 force-pushed the fix-windows-python-init branch from 18d25d9 to 72ebb20 Compare June 11, 2026 17:47
shettyvarun268 merged commit f77f891 into main Jun 12, 2026
58 of 74 checks passed
shettyvarun268 deleted the fix-windows-python-init branch June 12, 2026 18:05
bkendall pushed a commit that referenced this pull request Jul 9, 2026
bkendall pushed a commit that referenced this pull request Jul 9, 2026
yuichi0301 pushed a commit to yuichi0301/firebase-tools that referenced this pull request Aug 16, 2026
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL