Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Functions Emulator raises an error when path has spaces #5830

Closed
aalej opened this issue May 12, 2023 · 0 comments
Closed

Python Functions Emulator raises an error when path has spaces #5830

aalej opened this issue May 12, 2023 · 0 comments

Comments

@aalej
Copy link
Contributor

aalej commented May 12, 2023

When trying to start the Cloud Functions emulator that uses Python, an error is being raised when the path has spaces. An error is also raised when trying to deploy.

[REQUIRED] Environment info

firebase-tools: 12.0.0

Platform: macOS

Node: v18.15.0

Python: v3.11.3

[REQUIRED] Steps to reproduce

  1. Run mkdir 'i like spaces'
  2. Run cd i\ like\ spaces or cd 'i like spaces'
  3. Run firebase init functions --project <project_id>
    1. Select Python
    2. Do you want to install dependencies now? Yes
  4. Run cd functions
  5. Run firebase emulators:start
    1. Error is raised.
  6. Uncomment code in main.py to deploy
  7. Run firebase deploy --only functions
    1. Error is raised.

Notes:
No issues are raised running either firebase emulators:start or firebase deploy commands when using a path that has no spaces. Replace steps 1 & 2 from above with:

  1. Run mkdir 'no-spaces'
  2. Run cd no-spaces

[REQUIRED] Expected behavior

Functions emulator to start without any issues and functions to deploy without any issues.

[REQUIRED] Actual behavior

Error is raised after running firebase emulators:start. Relevant logs:

[debug] [2023-05-11T23:15:42.977Z] Customer code is not Node
[debug] [2023-05-11T23:15:42.979Z] Validating python source
[debug] [2023-05-11T23:15:42.980Z] Building python source
[debug] [2023-05-11T23:15:42.984Z] Could not find functions.yaml. Must use http discovery
[debug] [2023-05-11T23:15:42.997Z] Running command with virtualenv: command=., args=["<path>/i like spaces/functions/venv/bin/activate","&&","python3.11","-c","\"import firebase_functions; import os; print(os.path.dirname(firebase_functions.__file__))\""]
[debug] [2023-05-11T23:15:43.011Z] stderr: /bin/sh: <path>/i: No such file or directory

[error] ⬢  functions: Failed to load function definition from source: FirebaseError: Failed to find location of Firebase Functions SDK. Did you forget to run '.<path>/i like spaces/functions/venv/bin/activate && python3.11 -m pip install -r requirements.txt'? {"metadata":{"emulator":{"name":"functions"},"message":"Failed to load function definition from source: FirebaseError: Failed to find location of Firebase Functions SDK. Did you forget to run '. <path>/i like spaces/functions/venv/bin/activate && python3.11 -m pip install -r requirements.txt'?"}}

Error is raised after running firebase deploy --only functions. Relevant logs:

[debug] [2023-05-11T23:41:48.475Z] Customer code is not Node
[debug] [2023-05-11T23:41:48.477Z] Validating python source
[debug] [2023-05-11T23:41:48.477Z] Building python source
[debug] [2023-05-11T23:41:48.479Z] Could not find functions.yaml. Must use http discovery
[debug] [2023-05-11T23:41:48.495Z] Running command with virtualenv: command=., args=["<path>/i like spaces/functions/venv/bin/activate","&&","python3.11","-c","\"import firebase_functions; import os; print(os.path.dirname(firebase_functions.__file__))\""]
[debug] [2023-05-11T23:41:48.510Z] stderr: /bin/sh: <path>/i: No such file or directory

[error] 
[error] Error: Failed to find location of Firebase Functions SDK. Did you forget to run '. <path>/i like spaces/functions/venv/bin/activate && python3.11 -m pip install -r requirements.txt'?
taeold pushed a commit that referenced this issue May 12, 2023
Proposed fix for #5830 

Issue seems to be caused by [spawn](https://github.com/firebase/firebase-tools/blob/f8f19dc060e6daf060b87d38fd2a38d24bab8210/src/functions/python.ts#L38) raising an error when path provided has spaces. Might be related to nodejs/node#38490. 

### Scenarios Tested

Similar to steps provided in #5830 

1. Run `mkdir 'i like spaces'`
2. Run `cd i\ like\ spaces` or `cd 'i like spaces'`
3. Run `firebase init functions --project <project_id>`
    1. Select `Python`
    2. Do you want to install dependencies now? Yes
4. Run `cd functions`
5. Run `firebase emulators:start`
    1. Emulators start with no issues
7. Uncomment code in `main.py` to deploy
8. Run `firebase deploy --only functions`
    1. Functions deployed with no issues

### Sample Commands

`firebase emulators:start` && `firebase deploy --only functions`
@aalej aalej closed this as completed May 12, 2023
taeold pushed a commit that referenced this issue May 17, 2023
<!--

Thank you for contributing to the Firebase community! Please fill out the form below.

Run the linter and test suite
==============================
Run `npm test` to make sure your changes compile properly and the tests all pass on your local machine. We've hooked up this repo with continuous integration to double check those things for you.

-->

### Description

<!-- Are you fixing a bug? Implementing a new feature? Make sure we have the context around your change. Link to other relevant issues or pull requests. -->

Proposed fix for #5854.

Related to  #5830. Issue seems to be similar as the error message shows the incomplete path when path has spaces.  e.g. if path is `/Users/<user>/Desktop/project directory/function`, error message will shows path `/Users/<user>/Desktop/project`.

### Scenarios Tested

<!-- Write a list of all the user journeys and edge cases you've tested. Instructions for manual testing can be found at https://github.com/firebase/firebase-tools/blob/master/.github/CONTRIBUTING.md#development-setup -->

1. Create a directory with a space 
2. Run `firebase init functions` and run through the setup for Python functions.
3. Run `firebase init emulators` and setup the functions emulator
4. Run `firebase emulators:start`


### Sample Commands

<!-- Proposing a change to commands or flags? Provide examples of how they will be used. -->

`firebase emulators:start`
tonyjhuang pushed a commit that referenced this issue May 22, 2023
Proposed fix for #5830 

Issue seems to be caused by [spawn](https://github.com/firebase/firebase-tools/blob/f8f19dc060e6daf060b87d38fd2a38d24bab8210/src/functions/python.ts#L38) raising an error when path provided has spaces. Might be related to nodejs/node#38490. 

### Scenarios Tested

Similar to steps provided in #5830 

1. Run `mkdir 'i like spaces'`
2. Run `cd i\ like\ spaces` or `cd 'i like spaces'`
3. Run `firebase init functions --project <project_id>`
    1. Select `Python`
    2. Do you want to install dependencies now? Yes
4. Run `cd functions`
5. Run `firebase emulators:start`
    1. Emulators start with no issues
7. Uncomment code in `main.py` to deploy
8. Run `firebase deploy --only functions`
    1. Functions deployed with no issues

### Sample Commands

`firebase emulators:start` && `firebase deploy --only functions`
tonyjhuang pushed a commit that referenced this issue May 22, 2023
<!--

Thank you for contributing to the Firebase community! Please fill out the form below.

Run the linter and test suite
==============================
Run `npm test` to make sure your changes compile properly and the tests all pass on your local machine. We've hooked up this repo with continuous integration to double check those things for you.

-->

### Description

<!-- Are you fixing a bug? Implementing a new feature? Make sure we have the context around your change. Link to other relevant issues or pull requests. -->

Proposed fix for #5854.

Related to  #5830. Issue seems to be similar as the error message shows the incomplete path when path has spaces.  e.g. if path is `/Users/<user>/Desktop/project directory/function`, error message will shows path `/Users/<user>/Desktop/project`.

### Scenarios Tested

<!-- Write a list of all the user journeys and edge cases you've tested. Instructions for manual testing can be found at https://github.com/firebase/firebase-tools/blob/master/.github/CONTRIBUTING.md#development-setup -->

1. Create a directory with a space 
2. Run `firebase init functions` and run through the setup for Python functions.
3. Run `firebase init emulators` and setup the functions emulator
4. Run `firebase emulators:start`


### Sample Commands

<!-- Proposing a change to commands or flags? Provide examples of how they will be used. -->

`firebase emulators:start`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant