go-rod / rod

A Chrome DevTools Protocol driver for web automation and scraping.
https://go-rod.github.io
MIT License
5.42k stars 356 forks source link

libgobject-2.0 error #1139

Closed RampantDespair closed 2 weeks ago

RampantDespair commented 2 weeks ago

Rod Version: v0.116.2

The code to demonstrate your question

FROM golang:1.23.3

RUN apt -y update && apt -y upgrade && apt -y install curl sudo wget

WORKDIR /app

COPY . .
RUN go mod tidy

RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt -y install ./google-chrome-stable_current_amd64.deb

RUN apt-get clean

What you got

2024-11-07 19:59:58 [launcher.Browser]2024/11/08 00:59:58 Download: https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/1321438/chrome-linux.zip
2024-11-07 19:59:58 [launcher.Browser]2024/11/08 00:59:58 Progress: 00%
2024-11-07 19:59:59 [launcher.Browser]2024/11/08 00:59:59 Progress: 32%
2024-11-07 20:00:00 [launcher.Browser]2024/11/08 01:00:00 Progress: 67%
2024-11-07 20:00:00 [launcher.Browser]2024/11/08 01:00:00 Unzip: /root/.cache/rod/browser/chromium-1321438
2024-11-07 20:00:00 [launcher.Browser]2024/11/08 01:00:00 Progress: 00%
2024-11-07 20:00:01 [launcher.Browser]2024/11/08 01:00:01 Progress: 26%
2024-11-07 20:00:02 [launcher.Browser]2024/11/08 01:00:02 Progress: 49%
2024-11-07 20:00:03 [launcher.Browser]2024/11/08 01:00:03 Progress: 94%
2024-11-07 20:00:04 [launcher.Browser]2024/11/08 01:00:04 Downloaded: /root/.cache/rod/browser/chromium-1321438
2024-11-07 20:00:05 panic: [launcher] Failed to launch the browser, the doc might help https://go-rod.github.io/#/compatibility?id=os: /root/.cache/rod/browser/chromium-1321438/chrome: error while loading shared libraries: libgobject-2.0.so.0: cannot open shared object file: No such file or directory
2024-11-07 20:00:05 exit status 2

What you expect to see

For Rod to run without issue.

What have you tried to solve the question

As shown in the above console log, rod panics and causes a system crash. I've tried installing libgobject-2.0 but this doesn't exist apparently. Am I doing something wrong in my Dockerfile?

RampantDespair commented 2 weeks ago

Upon further investigation, adding || apt -f -y install to the install command worked. Not sure if this is a universal fix or issue, but this was the solution for me:

FROM golang:1.23.3

RUN apt -y update && apt -y upgrade && apt -y install curl sudo wget

WORKDIR /app

COPY . .
RUN go mod tidy

RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN apt -y install ./google-chrome-stable_current_amd64.deb || apt -f -y install

RUN apt-get clean