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

Handle PowerShell comma behavior for parsing command arguments #7506

Open
paulpv opened this issue Jul 29, 2024 · 4 comments
Open

Handle PowerShell comma behavior for parsing command arguments #7506

paulpv opened this issue Jul 29, 2024 · 4 comments

Comments

@paulpv
Copy link

paulpv commented Jul 29, 2024

[REQUIRED] Environment info

firebase-tools: 13.14.2

Platform: Windows

[REQUIRED] Test case

...

[REQUIRED] Steps to reproduce

Setup:
PowerShell v7 Administrator:

winget install nvm-windows
winget install -e --id Oracle.JDK.18

Close and reopen PowerShell (Admin), then:

nvm install 20
nvm use 20
npm install -g firebase-tools
firebase login
firebase target:apply hosting prod site-prod
firebase target:apply hosting dev site-dev
firebase init emulators
firebase emulators:start --only firestore,functions,hosting

[REQUIRED] Expected behavior

Emulator starts

[REQUIRED] Actual behavior

firebase emulators:start --only firestore,functions,hosting:dev --debug
[2024-07-29T22:50:35.978Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2024-07-29T22:50:35.979Z] > authorizing via signed-in user (distroavproject@gmail.com)
i  emulators: Shutting down emulators. {"metadata":{"emulator":{"name":"hub"},"message":"Shutting down emulators."}}

Error: No emulators to start, run firebase init emulators to get started.

Notes

Everything works fine if I run just:

firebase emulators:start

or even just

firebase emulators:start --only hosting

Seems like anything comma-separated --only a,b does not work.

This is using an existing project that runs fine on Mac/Linux, when I use --only firestore,functions,hosting.

Log of a successful non---only a,b command:

firebase emulators:start --debug                                       
[2024-07-29T22:59:26.809Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2024-07-29T22:59:26.811Z] > authorizing via signed-in user (distroavproject@gmail.com)
[2024-07-29T22:59:26.875Z] java version "18.0.2.1" 2022-08-18

[2024-07-29T22:59:26.876Z] Java(TM) SE Runtime Environment (build 18.0.2.1+1-1)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.2.1+1-1, mixed mode, sharing)

[2024-07-29T22:59:26.887Z] Parsed Java major version: 18
i  emulators: Starting emulators: functions, firestore, hosting {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions, firestore, hosting"}}
...
@aalej
Copy link
Contributor

aalej commented Jul 31, 2024

Hey @paulpv, thanks for the detailed report. I was able to reproduce this issue when using PowerShell, however, when I tried using Command Prompt, the command firebase emulators:start --only firestore,hosting works and does not raise any errors.

When using the Command Prompt, checking the generated firebase-debug.log shows that the command being run is:

C:\<PATH>\firebase.js emulators:start --only firestore,hosting --debug

However, when using PowerShell, I checked the generated firebase-debug.log file and noticed that the command being run is:

 C:\<PATH>\firebase.js emulators:start --only firestore hosting --debug

I noticed that the “,” separating firestore and hosting has been removed. This makes me think that this could be an issue with how PowerShell treats commas. I found this relevant Stack Overflow post.

Could you try adding quotes around the argument to see if you would be able to start the emulators? The command would look something like:

firebase emulators:start --only 'firestore,hosting' --debug

@aalej aalej added the Needs: Author Feedback Issues awaiting author feedback label Jul 31, 2024
@paulpv
Copy link
Author

paulpv commented Jul 31, 2024

Could you try adding quotes around the argument to see if you would be able to start the emulators? The command would look something like:

firebase emulators:start --only 'firestore,hosting' --debug

Purfect! Works just fine now!

I had a feeling it had something to do with the commas!

"Today I learned" that PS treats commas differently.

Hopefully this helps out anyone in the future that runs into this!

You may close as appropriate.
The only thing I could think of is maybe some example/mention in the docs on how to handle this.
PowerShell is being pushed more and more as the default Windows shell/terminal.
WindowKey and searching for "cmd" doesn't even bring up "Command Prompt" anymore. :/

@google-oss-bot google-oss-bot added Needs: Attention and removed Needs: Author Feedback Issues awaiting author feedback labels Jul 31, 2024
@aalej
Copy link
Contributor

aalej commented Aug 1, 2024

Awesome! It’s good to hear that the command now works. For now, I’ll go ahead and close this issue as it’s solved. Though, I’ll bring this up to our engineering team to see if we could update the docs.

@aalej aalej closed this as completed Aug 1, 2024
@aalej
Copy link
Contributor

aalej commented Aug 1, 2024

Quick update, re-opening this issue. Discussed this with our engineering team and we think we could add some logic to handle how PowerShell treats commas. I'll change the title of the issue to match this.

@aalej aalej reopened this Aug 1, 2024
@aalej aalej changed the title Windows firebase emulators:start --only firestore,functions,hosting not working; firebase emulators:start works fine Handle PowerShell comma behavior for parsing command arguments Aug 1, 2024
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

3 participants