go-rod / rod

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

Examples fail on Ubuntu 24.04 with "No usable sandbox!" #1070

Open dblueman opened 3 weeks ago

dblueman commented 3 weeks ago

When running an example (Rod Version: v0.116.0) with a stock Ubuntu 24.04 LTS install (Go 1.22) , we see:


❯ go test -run Example_search examples_test.go
--- FAIL: Example_search (2.04s)
panic: [launcher] Failed to get the debug url: [0605/084957.922134:FATAL:zygote_host_impl_linux.cc(126)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
#0 0x65379abf4402 base::debug::CollectStackTrace()
#1 0x65379abe1afe base::debug::StackTrace::StackTrace()
#2 0x65379ab3b4da logging::LogMessage::Flush()
#3 0x65379ab3c079 logging::LogMessageFatal::~LogMessageFatal()
#4 0x653799079afe content::ZygoteHostImpl::Init()
#5 0x65379a016823 content::ContentMainRunnerImpl::Initialize()
#6 0x65379a014569 content::RunContentProcess()
#7 0x65379a0149c7 content::ContentMain()
#8 0x65379a5ca818 headless::HeadlessShellMain()
#9 0x65379609429a ChromeMain
#10 0x7951e582a1ca (/usr/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9)
#11 0x7951e582a28b __libc_start_main
#12 0x65379609402a _start

 [recovered]
    panic: [launcher] Failed to get the debug url: [0605/084957.922134:FATAL:zygote_host_impl_linux.cc(126)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/main/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox.
#0 0x65379abf4402 base::debug::CollectStackTrace()
#1 0x65379abe1afe base::debug::StackTrace::StackTrace()
#2 0x65379ab3b4da logging::LogMessage::Flush()
#3 0x65379ab3c079 logging::LogMessageFatal::~LogMessageFatal()
#4 0x653799079afe content::ZygoteHostImpl::Init()
#5 0x65379a016823 content::ContentMainRunnerImpl::Initialize()
#6 0x65379a014569 content::RunContentProcess()
#7 0x65379a0149c7 content::ContentMain()
#8 0x65379a5ca818 headless::HeadlessShellMain()
#9 0x65379609429a ChromeMain
#10 0x7951e582a1ca (/usr/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9)
#11 0x7951e582a28b __libc_start_main
#12 0x65379609402a _start

goroutine 1 [running]:
testing.(*InternalExample).processRunResult(0xc00018fc08, {0x0, 0x0}, 0x18f601?, 0x0, {0x7faca0, 0xc000038fd0})
    /usr/lib/go-1.22/src/testing/example.go:91 +0x645
testing.runExample.func2()
    /usr/lib/go-1.22/src/testing/run_example.go:59 +0x116
panic({0x7faca0?, 0xc000038fd0?})
    /usr/lib/go-1.22/src/runtime/panic.go:770 +0x132
github.com/go-rod/rod/lib/utils.init.func2({0x7faca0?, 0xc000038fd0?})
    /tmp/rod/lib/utils/utils.go:69 +0x1d
command-line-arguments_test.Example_search.New.(*Browser).WithPanic.genE.func1({0xc000282000?, 0x410a45?, 0x10?})
    /tmp/rod/must.go:36 +0x62
github.com/go-rod/rod.(*Browser).MustConnect(0xc0000d05a0)
    /tmp/rod/must.go:51 +0x7f
command-line-arguments_test.Example_search()
    /tmp/rod/examples_test.go:219 +0x2d8
testing.runExample({{0x8c6c53, 0xe}, 0xb5c448, {0x8c2fda, 0x5}, 0x0})
    /usr/lib/go-1.22/src/testing/run_example.go:63 +0x2de
testing.runExamples(0xbcd280?, {0xe5dfc0, 0x9, 0x0?})
    /usr/lib/go-1.22/src/testing/example.go:40 +0x126
testing.(*M).Run(0xc0000b99a0)
    /usr/lib/go-1.22/src/testing/testing.go:2029 +0x75d
main.main()
    _testmain.go:63 +0x16c
FAIL    command-line-arguments  2.048s
FAIL```

From the above URL, go-rod may need to set the CHROME_DEVEL_SANDBOX environment variable.
ysmood commented 3 weeks ago

Make sure you can launch chromium without Rod on the machine.

dblueman commented 3 weeks ago

Thank you for responding ysmood!

Yes, 'sudo apt install chromium' installs a snap; it starts version 125.0.6422.141 (official snap) up just fine running 'chromium' from the terminal.

Let me know anything else I can check.

ysmood commented 3 weeks ago

Then it could be some default cli flags that the launcher sets fail the execution.

You can print the cli flags and launch it manually to check which flag is the cause:

https://github.com/go-rod/rod/blob/ab8740f76fca9fbcc138abab51afaead37f38e4a/lib/launcher/example_test.go#L30-L31

From your error message, you might want to try launcher.New().NoSandbox(true)

Dazmed707 commented 3 weeks ago

i have this error image

have guid for install all step for step? and need install stheal repo

ysmood commented 3 weeks ago

Your machine might not have enough memory or disk space?

Dazmed707 commented 2 weeks ago

I use ubuntu 22 with 30gb in vps

ysmood commented 1 week ago

From the error info, it's kill by something, maybe anti-virus software. The test works fine on github ubuntu actions, you can check the CI of rod.

dblueman commented 3 days ago

Then it could be some default cli flags that the launcher sets fail the execution.

You can print the cli flags and launch it manually to check which flag is the cause:

https://github.com/go-rod/rod/blob/ab8740f76fca9fbcc138abab51afaead37f38e4a/lib/launcher/example_test.go#L30-L31

From your error message, you might want to try launcher.New().NoSandbox(true)

Indeed, I found NoSandbox(true) is a successful workaround:

   u := launcher.New().
      NoSandbox(true). // workaround for launching failure in Ubuntu 24.04
      MustLaunch()
   page := rod.New().
      ControlURL(u).
      MustConnect().
      MustPage(path)

Many thanks ysmood!