SpellcraftAI / cli

All Spellcraft CLI tools.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`upg login` on fresh linux vm without xdg-open cause error

kaxing opened this issue Β· comments

commented

Trying out gsh and bumping into this inside a fresh vm; While there is no xdg-open installed.
Can be easily fix by install the package but figure might be good to put a note here.

  Attempting to open browser. Please visit this link if it does not open automatically.

  https://gptlabs.us.auth0.com/authorize?client_id=I3rJAbl7D09DuYG6dGeYWtBtpuGyeZrI&redirect_uri=http%3A%2F%2Flocalhost%3A23462&audience=https%3A%2F%2Fgptlabs.us.auth0.com%2Fapi%2Fv2%2F&code_challenge=OWb0vyyU9o1pTOeJIm8P8Vc98KMWCrcEhHn7BlRRILw&code_challenge_method=S256&response_type=code&scope=openid+profile+email

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

Error: spawn xdg-open ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn xdg-open',
  path: 'xdg-open',

Also, a very niche need, the callback url is using localhost, which qemu VM is not listening to the localhost, might be better UX if using outbound IP of the VM(?)

commented

This should actually be fixed in upg latest, at least the failure to open the browser shouldn't throw and exit the process. Try upg update.

You would have to visit the link manually, but you said you can't use localhost?

commented

If you're on the latest upg and the xdg-open shit is still throwing lmk.

commented

Yeah, I had to use the local IP assigned from the bridge(I think).

Still happening when xdg-open is not in place.

ubuntu@newborn-guinea:~$ upg version


    __  ______  ____ _    UPG CLI 0.1.14
   / / / / __ \/ __ `/    Public Beta
  / /_/ / /_/ / /_/ /
  \__,_/ .___/\__, /      πŸ‡ΊπŸ‡Έ  Built by GPT Labs
      /_/    /____/       The first software to land on the moon!
                          (c) 2022 GPT Labs License

    UPG version: 0.1.14.


ubuntu@newborn-guinea:~$ upg login


    __  ______  ____ _    UPG CLI 0.1.14
   / / / / __ \/ __ `/    Public Beta
  / /_/ / /_/ / /_/ /
  \__,_/ .___/\__, /      πŸ‡ΊπŸ‡Έ  Built by GPT Labs
      /_/    /____/       Used by every NASA engineer!
                          (c) 2022 GPT Labs License


  Attempting to open browser. Please visit this link if it does not open automatically.

  https://gptlabs.us.auth0.com/authorize?client_id=I3rJAbl7D09DuYG6dGeYWtBtpuGyeZrI&redirect_uri=http%3A%2F%2Flocalhost%3A23462&audience=https%3A%2F%2Fgptlabs.us.auth0.com%2Fapi%2Fv2%2F&code_challenge=DI9eCg8Lbh3-Wez0jcj3Lzfh6ZFhpB312Okpnm3XpVI&code_challenge_method=S256&response_type=code&scope=openid+profile+email


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

Error: spawn xdg-open ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn xdg-open',
  path: 'xdg-open',
  spawnargs: [
    'https://gptlabs.us.auth0.com/authorize?client_id=I3rJAbl7D09DuYG6dGeYWtBtpuGyeZrI&redirect_uri=http%3A%2F%2Flocalhost%3A23462&audience=https%3A%2F%2Fgptlabs.us.auth0.com%2Fapi%2Fv2%2F&code_challenge=DI9eCg8Lbh3-Wez0jcj3Lzfh6ZFhpB312Okpnm3XpVI&code_challenge_method=S256&response_type=code&scope=openid+profile+email'
  ]
}

Node.js v18.12.1
ubuntu@newborn-guinea:~$

Does this issue still matter with the new upg authorize command? Or is it something else we can address?

commented

@marinacabrera Yes, still happen with upg authorize

$ npm -g list
/usr/lib
β”œβ”€β”€ @gptlabs/gsh@0.0.11
β”œβ”€β”€ @gptlabs/upg@0.1.14
β”œβ”€β”€ corepack@0.17.1
└── npm@9.6.2

$ upg authorize


    __  ______  ____ _    UPG CLI 0.1.14
   / / / / __ \/ __ `/    Public Beta
  / /_/ / /_/ / /_/ /
  \__,_/ .___/\__, /      πŸ‡ΊπŸ‡Έ  Built by GPT Labs
      /_/    /____/       Google HATES us for this ONE WEIRD TRICK!
                          (c) 2022 GPT Labs License

βœ” Do you already have an authorization code, or would you like to generate one? β€Ί Generate Code

  Attempting to open browser. Please visit this link if it does not open automatically.

  https://gptlabs.us.auth0.com/authorize?client_id=I3rJAbl7D09DuYG6dGeYWtBtpuGyeZrI&redirect_uri=http%3A%2F%2Flocalhost%3A23462&audience=https%3A%2F%2Fgptlabs.us.auth0.com%2Fapi%2Fv2%2F&code_challenge=Wf5z1Rw1F_VlD_J3h3oEjn9B6tGvWlc4rWaZL6TKc3fAl&code_challenge_method=S256&response_type=code&scope=openid+profile+email


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

Error: spawn xdg-open ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn xdg-open',
  path: 'xdg-open',

Not certain which component in upg is requiring xdg-open;
Here is an unsafe detour for not wanting to install xdg-utils:

sudo sh -c 'echo "/usr/bin/true" > /usr/bin/xdg-open; chmod +x /usr/bin/xdg-open'