fern-api / fern

Input OpenAPI. Output SDKs and Docs.
https://buildwithfern.com
Apache License 2.0
2.59k stars 136 forks source link

[Bug] `fern login` throwing exception on Ubuntu 22.04.3 #2287

Open charliettaylor opened 10 months ago

charliettaylor commented 10 months ago

Describe the bug I attempted to run fern init on my development server and had an exception thrown when it asked me to login

To Reproduce Steps to reproduce the behavior:

  1. SSH into an Ubuntu 22.04.3 server
  2. Run fern login

Expected behavior Normal login behavior should proceed

Screenshots

➜  fern login
node:events:492
      throw er; // Unhandled 'error' event
      ^

Error: spawn xdg-open ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:286:19)
    at onErrorNT (node:internal/child_process:484: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:292:12)
    at onErrorNT (node:internal/child_process:484:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn xdg-open',
  path: 'xdg-open',
  spawnargs: [
    'https://fern-prod.us.auth0.com/authorize?client_id=syaWnk6SjNoo5xBf1omfvziU3q7085lh&response_type=code&connection=github&scope=openid+profile+email+offline_access&redirect_uri=http%3A%2F%2Flocalhost%3A3129&audience=venus-prod'
  ]
}

Node.js v20.9.0

Installing xdg-utils onto my system does not resolve the issue, as now fern login hangs forever. Also, users in headless environments should still be able to login without needing desktop utils.

Desktop:

dannysheridan commented 7 months ago

Hey @charliettaylor this issue hasn't been reported by any other customers and thus isn't a priority for us right now. If this is still preventing you from using Fern, let me know!

TechQuery commented 1 week ago

@dannysheridan Online development environments like GitHub codespaces, GitPod.io, etc will throw this error, could Fern echo the opening URL to console for accessing manually? Just like npm login or vercel login?

It's so important for those users who has a bad Internet connection locally, we can use GitPod-like IDE normally, but disconnected from local CLI:

$ fern init --openapi http://localhost:8080/docs/spec
Failed.
Request timed out  // This isn't my `localhost`, it's `fern login`...
dannysheridan commented 1 week ago

@TechQuery I've reopened this issue based on your feedback. Interested in contributing this change?


Join the Slack Community

charliettaylor commented 6 days ago

@dannysheridan I would be down to take a look at it, seems like the issue is using the npm open package to automatically open the URL in browser. We could wrap those calls in a try-catch and log the URL when an exception is thrown, I'm not sure if there is a way to detect if someone is in a headless env, would be nice to do that instead of having to catch an exception.

dannysheridan commented 6 days ago

@charliettaylor sounds great. Feel free to post in our Slack community if you have questions while making this contribution.