sindresorhus / open

Open stuff like URLs, files, executables. Cross-platform.
MIT License
3.18k stars 219 forks source link

Windows Command Prompt support broken #205

Open WillieRuemmele opened 3 years ago

WillieRuemmele commented 3 years ago

Hello, with this PR https://github.com/sindresorhus/open/pull/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 commented 3 years ago

How is it broken?

WillieRuemmele commented 3 years ago

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 commented 3 years ago

// @tim-stasse @Pytal

tabarra commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

oliverfoster commented 3 years ago

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

alvinlys commented 2 years ago

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