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

AIO app undeploy throws an error on Windows terminal (Powershell path invalid) #80

Closed
elagun opened this issue Jun 15, 2023 · 7 comments · Fixed by #81
Closed

AIO app undeploy throws an error on Windows terminal (Powershell path invalid) #80

elagun opened this issue Jun 15, 2023 · 7 comments · Fixed by #81
Labels
bug Something isn't working

Comments

@elagun
Copy link

elagun commented Jun 15, 2023

Expected Behaviour

aio app undeploy runs successfully from Windows CMD terminal and undeploys the AB app

Actual Behaviour

aio app undeploy throws an error in latest app plugin 10.2.2. Apparently this is because the Windows root path is undefined. The Powershell is not used itself however to run the undeploy command.

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: spawn undefined\System32\WindowsPowerShell\v1.0\powershell ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
    at onErrorNT (node:internal/child_process:485:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
    at onErrorNT (node:internal/child_process:485:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn undefined\\System32\\WindowsPowerShell\\v1.0\\powershell',
  path: 'undefined\\System32\\WindowsPowerShell\\v1.0\\powershell',
  spawnargs: [
    '-NoProfile',
    '-NonInteractive',
    '–ExecutionPolicy',
    'Bypass',
    '-EncodedCommand',
  'UwB0AGEAcgB0ACAAIgBoAHQAdABwAHMAOgAvAC8AYQBpAG8ALQBsAG8AZwBpAG4ALgBhAGQAbwBiAGUAaQBvAHIAdQBuAHQAaQBtAGUALgBuAGUAdAAvAGEAcABpAC8AdgAxAC8AdwBlAGIALwBkAGUAZgBhAHUAbAB0AC8AYQBwAHAAbABvAGcAaQBuAD8AaQBkAD0AYwBiAGQAYQA2ADAAMQA5ACYAcABvAHIAdAA9ADUANwA2ADkAMAAmAHIAZQBkAGkAcgBlAGMAdABfAHUAcgBpAD0AaAB0AHQAcABzACUAMwBBACUAMgBGACUAMgBGAGEAaQBvAC0AbABvAGcAaQBuAC4AYQBkAG8AYgBlAGkAbwByAHUAbgB0AGkAbQBlAC4AbgBlAHQAJQAyAEYAYQBwAGkAJQAyAEYAdgAxACUAMgBGAHcAZQBiACUAMgBGAGQAZQBmAGEAdQBsAHQAJQAyAEYAYQBwAHAAbABvAGcAaQBuACUAMgBGAGwAbwBnAGkAbgAtAHMAdQBjAGMAZQBzAHMAIgA='
  ]
}

Steps to Reproduce

Run aio app undeploy on Windows in CMD terminal

Environment Info

  System:
    OS: Windows 10 10.0.22621
    CPU: (8) x64 Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz
    Memory: 20.88 GB / 31.73 GB
  Binaries:
    Node: 16.20.0
    Yarn: Not Found
    npm: 8.19.4
  Virtualization:
    Docker: 20.10.21
  npmGlobalPackages:
    @adobe/aio-cli: Not Found

  Proxies:
    http: (not set)
    https: (not set)
  CLI plugins:
    core:
      @adobe/aio-cli 9.3.0
      @adobe/aio-cli-plugin-app 10.2.2
      @adobe/aio-cli-plugin-app-templates 1.5.2
      @adobe/aio-cli-plugin-auth 3.2.0
      @adobe/aio-cli-plugin-certificate 1.0.1
      @adobe/aio-cli-plugin-config 4.0.1
      @adobe/aio-cli-plugin-console 4.1.0
      @adobe/aio-cli-plugin-events 3.0.1
      @adobe/aio-cli-plugin-info 3.0.1
      @adobe/aio-cli-plugin-runtime 6.0.2
      @adobe/aio-cli-plugin-telemetry 1.2.0
      @oclif/plugin-autocomplete 1.4.6
      @oclif/plugin-help 5.2.9
      @oclif/plugin-not-found 2.3.25
      @oclif/plugin-plugins 2.4.7
      @oclif/plugin-warn-if-update-available 2.0.37
    user:
      @adobe/aio-cli-plugin-aem 1.1.1
      @adobe/aio-cli-plugin-aem-rde 1.0.1
      @adobe/aio-cli-plugin-asset-compute 4.0.3
      @adobe/aio-cli-plugin-cloudmanager 4.0.0
    link:

Reference

https://adobe-acs.slack.com/archives/C013UDBFBGB/p1686579180629279

@gra85207adobe
Copy link

Output of aio info:
`System:
OS: Windows 10 10.0.19045
CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
Memory: 520.98 MB / 7.74 GB
Binaries:
Node: 16.13.0
Yarn: Not Found
npm: 9.6.6
Virtualization:
Docker: Not Found
npmGlobalPackages:
@adobe/aio-cli: Not Found

Proxies:
http: (not set)
https: (not set)
CLI plugins:
core:
@adobe/aio-cli 9.3.0
@adobe/aio-cli-plugin-app 10.2.2
@adobe/aio-cli-plugin-app-templates 1.5.2
@adobe/aio-cli-plugin-auth 3.2.0
@adobe/aio-cli-plugin-certificate 1.0.1
@adobe/aio-cli-plugin-config 4.0.1
@adobe/aio-cli-plugin-console 4.1.0
@adobe/aio-cli-plugin-events 3.0.1
@adobe/aio-cli-plugin-info 3.0.1
@adobe/aio-cli-plugin-runtime 6.0.2
@adobe/aio-cli-plugin-telemetry 1.2.0
@oclif/plugin-autocomplete 1.4.6
@oclif/plugin-help 5.2.9
@oclif/plugin-not-found 2.3.25
@oclif/plugin-plugins 2.4.7
@oclif/plugin-warn-if-update-available 2.0.37
user:
link:`

@gra85207adobe
Copy link

Here is the output of:
node -e "console.log(process.env.SYSTEMROOT)"
Output: C:\Windows
image

Please let me know if more info is needed.

Thanks,
Parul Goyal

@elagun
Copy link
Author

elagun commented Jun 27, 2023

Issue occurs with various aio commands, e.g. also aio console workspace list so switching workspaces is currently not possible

@shazron shazron added the bug Something isn't working label Jun 27, 2023
@aiojbot
Copy link
Collaborator

aiojbot commented Jun 27, 2023

JIRA issue created: https://jira.corp.adobe.com/browse/ACNA-2336

@elagun
Copy link
Author

elagun commented Jun 28, 2023

Root Cause

Issue is not in the actual aio commands, but the fact that login is required at some point. aio login which internally uses @oclif/core/src/cli-ux/open.ts to open the browser window fails, as the spawned process apparently does not receive the proper env vars.
Reference:
https://github.com/adobe/aio-lib-ims-oauth/blob/5.0.2/src/login.js
https://github.com/oclif/core/blob/1.21.0/src/cli-ux/open.ts

Woraround

When error occurs run aio login --no-open to login manually and then run the actual aio command again.

@shazron
Copy link
Member

shazron commented Jun 28, 2023

Doing a separate login command is just a workaround, not a solution. The env var is definitely the problem since as you can see from the log there is an undefined in undefined\System32\WindowsPowerShell\v1.0\powershell

We use open

open(uri, { app })
--
"open": "^8.4.2",

and this is where it is failing: https://github.com/sindresorhus/open/blob/cbc008bab21f657475b54e33a823b2941737da6f/index.js#L147

This is probably the actual issue sindresorhus/open#292

Might have to do this patch/workaround. It's probably an underlying node issue sanity-io/sanity#4221

@shazron
Copy link
Member

shazron commented Jun 30, 2023

PR #81

@adobe adobe deleted a comment from aiojbot Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants