gildas-lormeau / single-file-cli

CLI tool for saving a faithful copy of a complete web page in a single HTML file (based on SingleFile)
GNU Affero General Public License v3.0
539 stars 57 forks source link

unknown error: no chrome binary at "/usr/bin/chromium-browser" #49

Closed gemini0x2 closed 10 months ago

gemini0x2 commented 10 months ago

It appears that my npm automatically updated all my packages including single-file-cli, because after this event my args.js got overwritten and I lost all my configurations :( [it would be great if there was a flag option so the user can provide path to our own custom args.js that way we don't have to mess with the original, which can get overwritten after update]

Anyways, the problem now is that for some reason now I'm getting "no chrome binary" Error! I have tried uninstalling and installing both chromedriver and chromium-browser, but no luck. I'm not sure if the issue is with selenium or single-file-cli is not setting the paths correctly. I think selenium 4.11.0 should support Chromium 116, but I'm not completely sure.

Here is what I have:

Note: Both chromedriver and chromium-browser files are present and located in /usr/bin/ chromedriver --version ChromeDriver 116.0.5845.96 chromium-browser --version Chromium 116.0.5845.96 snap

my args.js

        "back-end": "webdriver-chromium",
        ...
        "browser-executable-path": "/usr/bin/chromium-browser",
        ...
        "web-driver-executable-path": "/usr/bin/chromedriver",

LOGS:

Selenium Manager binary found at /home/arc/.nvm/versions/node/v18.14.2/lib/node_modules/single-file-cli/node_modules/selenium-webdriver/bin/linux/selenium-manager
Driver path: /usr/bin/chromedriver
Browser path: "/usr/bin/chromium-browser"
unknown error: no chrome binary at "/usr/bin/chromium-browser" URL: https://mysite.com/
Stack: WebDriverError: unknown error: no chrome binary at "/usr/bin/chromium-browser"
    at Object.throwDecodedError (/home/arc/.nvm/versions/node/v18.14.2/lib/node_modules/single-file-cli/node_modules/selenium-webdriver/lib/error.js:524:15)
    at parseHttpResponse (/home/arc/.nvm/versions/node/v18.14.2/lib/node_modules/single-file-cli/node_modules/selenium-webdriver/lib/http.js:601:13)
    at Executor.execute (/home/arc/.nvm/versions/node/v18.14.2/lib/node_modules/single-file-cli/node_modules/selenium-webdriver/lib/http.js:529:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

WebDriverError: unknown error: no chrome binary at "/usr/bin/chromium-browser"
    at Object.throwDecodedError (/home/arc/.nvm/versions/node/v18.14.2/lib/node_modules/single-file-cli/node_modules/selenium-webdriver/lib/error.js:524:15)
    at parseHttpResponse (/home/arc/.nvm/versions/node/v18.14.2/lib/node_modules/single-file-cli/node_modules/selenium-webdriver/lib/http.js:601:13)
    at Executor.execute (/home/arc/.nvm/versions/node/v18.14.2/lib/node_modules/single-file-cli/node_modules/selenium-webdriver/lib/http.js:529:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  remoteStacktrace: '#0 0x55b439b8fee3 <unknown>\n' +
    '#1 0x55b4398cab77 <unknown>\n' +
    '#2 0x55b4398f33f9 <unknown>\n' +
    '#3 0x55b4398f1f19 <unknown>\n' +
    '#4 0x55b439931da1 <unknown>\n' +
    '#5 0x55b4399313ef <unknown>\n' +
    '#6 0x55b439928ef3 <unknown>\n' +
    '#7 0x55b4398fd132 <unknown>\n' +
    '#8 0x55b4398fdede <unknown>\n' +
    '#9 0x55b439b5478d <unknown>\n' +
    '#10 0x55b439b59017 <unknown>\n' +
    '#11 0x55b439b625e8 <unknown>\n' +
    '#12 0x55b439b59a50 <unknown>\n' +
    '#13 0x55b439b2a92e <unknown>\n' +
    '#14 0x55b439b7a7f8 <unknown>\n' +
    '#15 0x55b439b7a9ea <unknown>\n' +
    '#16 0x55b439b894e8 <unknown>\n' +
    '#17 0x7f2c6eee1b43 <unknown>\n'
}

Node.js v18.14.2
gspinoza commented 10 months ago

Adding the driverPath directly in webdriver-chromium.js using the setChromeService fixed the issue for me in Linux Ubuntu.

const driverPath = '/usr/bin/chromedriver';
builder.setChromeService(new chrome.ServiceBuilder(driverPath));
gemini0x2 commented 10 months ago

Thanks, that fixed it.

gildas-lormeau commented 10 months ago

I was not able to repoduce your issue on Ubuntu 22.04. On my machine, the executable of chromium is also located in /usr/bin (installed via apt). I installed the driver by running sudo apt install chromium-chromedriver. Then, I can simply run for example ./single-file https://example.com --back-end=webdriver-chromium without needing to pass any additional parameters.

However, I fixed the support of --web-driver-executable-path with an implementation based on the fix proposed by @gspinoza.

gemini0x2 commented 10 months ago

@gildas-lormeau thanks for adding the fix.

gildas-lormeau commented 10 months ago

@Gavriik You're welcome :)