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

Windows Command Prompt support broken #205

Open
WillieRuemmele opened this issue Nov 11, 2020 · 11 comments
Open

Windows Command Prompt support broken #205

WillieRuemmele opened this issue Nov 11, 2020 · 11 comments

Comments

@WillieRuemmele
Copy link

Hello, with this PR #188 all of the command prompt users were broken. Is there a way this library could try to open with powershell and then, if that fails, revert to opening with command prompt?

@sindresorhus
Copy link
Owner

How is it broken?

@WillieRuemmele
Copy link
Author

we, the sfdx-cli have users who CANNOT install powershell on their computers and when they try to use one of our commands that relies on this library, their command blows up with open spawn UNKNOWN.. It seems like the linked PR above was when it was changed - I'm hoping to keep the current behavior but have it fall back to cmd if it fails

@sindresorhus
Copy link
Owner

// @tim-stasse @Pytal

@tabarra
Copy link

tabarra commented Nov 22, 2020

I'm not sure if that PR is the cause, but I can attest this update broke things.
Had a few dozen people report this issue to me.

Managed to grab the following screenshot:
spawn undefined
Unfortunately I do not have more information. For now I'm downgrading.

@BillyHams
Copy link

I'm in the same situation. Access to Powershell is blocked by Group Policies for me and all my teammates. We are not 100% clear on how to downgrade easily.

@DebuggingYou
Copy link

Hello together,
are there any news about this issue? I have here the same issue on Windows 10 Pro (Version: 1809 / OS build: 17763.1397), and with my user I don't have access to PowerShell.

I have received the following message from the SFDX CLI command, that might help?

ERROR running auth:web:login: spawn UNKNOWN
*** Internal Diagnostic ***

Error: spawn UNKNOWN
at ChildProcess.spawn (internal/child_process.js:403:11)
at Object.spawn (child_process.js:553:9)
at module.exports (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\open\index.js:175:34)
at async Login.executeLoginFlow (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\@salesforce\plugin-auth\lib\commands\auth\web\login.js:54:9)
at async Login.run (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\@salesforce\plugin-auth\lib\commands\auth\web\login.js:35:30)
at async Login._run (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\@salesforce\command\lib\sfdxCommand.js:81:40)
at async Config.runCommand (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\@oclif\config\lib\config.js:173:24)
at async Main.run (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\@oclif\command\lib\main.js:27:9)
at async Main._run (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\@oclif\command\lib\command.js:43:20)
at async Object.run (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\dist\cli.js:114:21)
Outer stack:
at Function.wrap (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\@salesforce\core\lib\sfdxError.js:171:27)
at Login.catch (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\@salesforce\command\lib\sfdxCommand.js:248:67)
at async Login._run (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\@salesforce\command\lib\sfdxCommand.js:85:13)
at async Config.runCommand (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\@oclif\config\lib\config.js:173:24)
at async Main.run (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\@oclif\command\lib\main.js:27:9)
at async Main._run (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\node_modules\@oclif\command\lib\command.js:43:20)
at async Object.run (C:\Users\xxx\AppData\Roaming\npm\node_modules\sfdx-cli\dist\cli.js:114:21)
******

 sfdx:Login ERROR [
sfdx:Login '\x1B[1mERROR running auth:web:login: \x1B[22m',
sfdx:Login '\x1B[31mspawn UNKNOWN\x1B[39m',
sfdx:Login '\x1B[31m\x1B[39m\n' +
sfdx:Login '\x1B[31m*** Internal Diagnostic ***\x1B[39m\n' +
sfdx:Login '\x1B[31m\x1B[39m\n' +
sfdx:Login '\x1B[31mError: spawn UNKNOWN\x1B[39m\n' +
sfdx:Login '\x1B[31m at ChildProcess.spawn (internal/child_process.js:403:11)\x1B[39m\n' +
sfdx:Login '\x1B[31m at Object.spawn (child_process.js:553:9)\x1B[39m\n' +
sfdx:Login '\x1B[31m at module.exports (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\open\\index.js:175:34)\x1B[39m\n' +
sfdx:Login '\x1B[31m at async Login.executeLoginFlow (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\@salesforce\\plugin-auth\\lib\\commands\\auth\\web\\login.js:54:9)\x1B[39m\n' +
sfdx:Login '\x1B[31m at async Login.run (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\@salesforce\\plugin-auth\\lib\\commands\\auth\\web\\login.js:35:30)\x1B[39m\n' +
sfdx:Login '\x1B[31m at async Login._run (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\@salesforce\\command\\lib\\sfdxCommand.js:81:40)\x1B[39m\n' +
sfdx:Login '\x1B[31m at async Config.runCommand (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\@oclif\\config\\lib\\config.js:173:24)\x1B[39m\n' +
sfdx:Login '\x1B[31m at async Main.run (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\@oclif\\command\\lib\\main.js:27:9)\x1B[39m\n' +
sfdx:Login '\x1B[31m at async Main._run (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\@oclif\\command\\lib\\command.js:43:20)\x1B[39m\n' +
sfdx:Login '\x1B[31m at async Object.run (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\dist\\cli.js:114:21)\x1B[39m\n' +
sfdx:Login '\x1B[31mOuter stack:\x1B[39m\n' +
sfdx:Login '\x1B[31m at Function.wrap (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\@salesforce\\core\\lib\\sfdxError.js:171:27)\x1B[39m\n' +
sfdx:Login '\x1B[31m at Login.catch (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\@salesforce\\command\\lib\\sfdxCommand.js:248:67)\x1B[39m\n' +
sfdx:Login '\x1B[31m at async Login._run (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\@salesforce\\command\\lib\\sfdxCommand.js:85:13)\x1B[39m\n' +
sfdx:Login '\x1B[31m at async Config.runCommand (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\@oclif\\config\\lib\\config.js:173:24)\x1B[39m\n' +
sfdx:Login '\x1B[31m at async Main.run (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\@oclif\\command\\lib\\main.js:27:9)\x1B[39m\n' +
sfdx:Login '\x1B[31m at async Main._run (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\node_modules\\@oclif\\command\\lib\\command.js:43:20)\x1B[39m\n' +
sfdx:Login '\x1B[31m at async Object.run (C:\\Users\\xxx\\AppData\\Roaming\\npm\\node_modules\\sfdx-cli\\dist\\cli.js:114:21)\x1B[39m\n' +
sfdx:Login '\x1B[31m******\x1B[39m\n' +
sfdx:Login '\x1B[31m\x1B[39m'
sfdx:Login ] +167ms
@oclif/config start postrun hook +212ms
@oclif/config postrun hook done +24ms

I know, that it's an issue within sfdx-cli, but as @WillieRuemmele already said, it seems to be related here.

Thank you :)

PS: I have also created an issue for the SFDX developers.

@DebuggingYou
Copy link

Hello together,
I can confirm, that my issue is solved by enabling PowerShell on my PC. After my admins have given me access to it, the error did not appear anymore :) Thank you @BillyHams for the hint!

@oliverfoster
Copy link

oliverfoster commented Sep 16, 2021

It would be nice to have the option to not use powershell or to define a default terminal. This issue has cropped up for me in a number of bits of software from a variety of users inside corporate networks who's access to powershell has been revoked.

image

@tabarra
Copy link

tabarra commented Sep 17, 2021

@oliverfoster consider downgrading to v7.1.0, it works without powershell.

@oliverfoster
Copy link

Thanks for that. I'm looking for a long term solution.

@alvinlys
Copy link

alvinlys commented Nov 8, 2021

I'm not sure if that PR is the cause, but I can attest this update broke things. Had a few dozen people report this issue to me.

Managed to grab the following screenshot: spawn undefined Unfortunately I do not have more information. For now I'm downgrading.

I face the same issue and able to solve it by
process.env.SYSTEMROOT = process.env.SystemRoot

byCedric added a commit to expo/expo that referenced this issue Jul 4, 2023
…rs on Windows (#23287)

# Why

Fixes #23252

# How

- `open` has a bug on Windows, where it [uses
`process.env.SYSTEMROOT`](https://github.com/sindresorhus/open/blob/main/index.js#L173)
instead of
[`process.env.SystemRoot`](https://en.wikipedia.org/wiki/Environment_variable#:~:text=The%20%25SystemRoot%25%20variable%20is%20a,including%20the%20drive%20and%20path.)
- This causes the executed command to run with `undefined\\...`
- There has been no fix yet, and due to `open` being fully ESM now, we
probably can't upgrade too

> See various issues
[#300](sindresorhus/open#300),
[#292](sindresorhus/open#292),
[#270](sindresorhus/open#270), or
[#205](sindresorhus/open#205)

This basically sets the missing `SYSTEMROOT` when trying to open a
browser on Windows. It's fixed in both `@expo/cli` as well as
`@expo/dev-server` (to open the Chrome DevTools).

# Test Plan

This has to be tested on Windows.

- `$ yarn create expo ./test-browser -t tabs@beta`
- `$ cd ./test-browser`
- `$ yarn start`
- Try pressing the following keys:
- `j` -> to open the Chrome DevTools, after connecting a device. Should
work as expected.
  - `w` -> to open the browser with Metro web. Should work as expected.

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

---------

Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
byCedric added a commit to expo/expo that referenced this issue Jul 4, 2023
…rs on Windows (#23287)

# Why

Fixes #23252

# How

- `open` has a bug on Windows, where it [uses
`process.env.SYSTEMROOT`](https://github.com/sindresorhus/open/blob/main/index.js#L173)
instead of
[`process.env.SystemRoot`](https://en.wikipedia.org/wiki/Environment_variable#:~:text=The%20%25SystemRoot%25%20variable%20is%20a,including%20the%20drive%20and%20path.)
- This causes the executed command to run with `undefined\\...`
- There has been no fix yet, and due to `open` being fully ESM now, we
probably can't upgrade too

> See various issues
[#300](sindresorhus/open#300),
[#292](sindresorhus/open#292),
[#270](sindresorhus/open#270), or
[#205](sindresorhus/open#205)

This basically sets the missing `SYSTEMROOT` when trying to open a
browser on Windows. It's fixed in both `@expo/cli` as well as
`@expo/dev-server` (to open the Chrome DevTools).

# Test Plan

This has to be tested on Windows.

- `$ yarn create expo ./test-browser -t tabs@beta`
- `$ cd ./test-browser`
- `$ yarn start`
- Try pressing the following keys:
- `j` -> to open the Chrome DevTools, after connecting a device. Should
work as expected.
  - `w` -> to open the browser with Metro web. Should work as expected.

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

---------

Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
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

No branches or pull requests

7 participants