agentic icon indicating copy to clipboard operation
agentic copied to clipboard

Incorrect assumption of Linux Chrome binary

Open luphoria opened this issue 2 years ago • 3 comments

Verify latest release

  • [X] I verified that the issue exists in the latest chatgpt release

Verify webapp is working

  • [X] I verify that the ChatGPT webapp is working properly for this account.

Verify resrictions

  • [X] I verify that I've double-checked all of the restrictions.

Environment details

Node.js version: v19.2.0 Browser version: ungoogled-chromium (flatpak) OS: Arch Linux

Link to the code that reproduces this issue

https://github.com/transitive-bullshit/chatgpt-api/blob/main/src/openai-auth.ts#L225

Describe the Bug

The puppeteer config for linux is lacking in that it simply hardcodes two potential paths to chrome (/usr/bin/google-chrome, /usr/bin/google-chrome-stable). This can be bypassed by editing the source at https://github.com/transitive-bullshit/chatgpt-api/blob/main/src/openai-auth.ts#L225 but it would be much more convenient for .env to include an optional variable like BROWSER_PUPPETEER_PATH.

To Reproduce

  • Don't have Chrome installed
  • be on Linux
  • Have ungoogled-chromium installed and set as default browser
  • Run
  • Error: Error: Failed to launch the browser process! spawn /usr/bin/google-chrome-stable ENOENT

Expected Behavior

Expectation would be that puppeteer either installs its own chromium instance, or doesn't assume the path to browser.

luphoria avatar Dec 15 '22 01:12 luphoria

@luphoria that sounds great which would override the default platform logic. Would you be down to open a PR for this?

transitive-bullshit avatar Dec 15 '22 03:12 transitive-bullshit

I might when I have a little more time. I'm much more of a monkeypatcher than I am a programmer :P

luphoria avatar Dec 15 '22 03:12 luphoria

I'll have a go at making a PR that adds a chromePath or browserPath vaiable to the ChatGPTAPIBrowser opts.

alex12058 avatar Dec 16 '22 13:12 alex12058

It is definitely worth adding something to work with other Linux distributions. However, there is already such a feature in puppeteer. import { executablePath } from 'puppeteer' Why not use it? It detects your path. And also you can use env variable PUPPETEER_EXECUTABLE_PATH with it.

Added PR. https://github.com/transitive-bullshit/chatgpt-api/pull/150

RusDyn avatar Dec 16 '22 21:12 RusDyn

https://github.com/transitive-bullshit/chatgpt-api/releases/tag/v2.5.1 should help.

@RusDyn see my comment on your PR; we can't use the default puppeteer executable path due to cloudflare.

transitive-bullshit avatar Dec 16 '22 23:12 transitive-bullshit