Automatic chrome download does not seem to work?
FrankenApps opened this issue · comments
I have a simple repro:
Cargo.toml
[package]
name = "basic_pdf"
version = "0.1.0"
edition = "2021"
[dependencies]
headless_chrome = { version = "0.9.0", features= ["fetch"] }
main.rs
use headless_chrome::{Browser, LaunchOptionsBuilder};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let launch_opts = LaunchOptionsBuilder::default()
.headless(true)
.build()?;
let browser = Browser::new(launch_opts)?;
println!("Wohoo we have a browser.");
let tab = browser.wait_for_initial_tab()?;
let wikidata = tab
.navigate_to("https://www.wikipedia.org")?
.wait_until_navigated()?
.print_to_pdf(None)?;
std::fs::write("wiki.pdf", &wikidata)?;
println!("PDF successfully created from internet web page.");
Ok(())
}
when I run this using cargo run
, the application hangs for about 5 minutes and then finally exits with:
Error: Compat { error: NoAvailablePorts }
Version 0.9.0
on macos. I also tried:
headless_chrome = { git = "https://github.com/atroche/rust-headless-chrome", features= ["fetch"] }
but it does not build due to a missing dependency.
I have a simple repro:
Cargo.toml
[package] name = "basic_pdf" version = "0.1.0" edition = "2021" [dependencies] headless_chrome = { version = "0.9.0", features= ["fetch"] }main.rs
use headless_chrome::{Browser, LaunchOptionsBuilder}; fn main() -> Result<(), Box<dyn std::error::Error>> { let launch_opts = LaunchOptionsBuilder::default() .headless(true) .build()?; let browser = Browser::new(launch_opts)?; println!("Wohoo we have a browser."); let tab = browser.wait_for_initial_tab()?; let wikidata = tab .navigate_to("https://www.wikipedia.org")? .wait_until_navigated()? .print_to_pdf(None)?; std::fs::write("wiki.pdf", &wikidata)?; println!("PDF successfully created from internet web page."); Ok(()) }when I run this using
cargo run
, the application hangs for about 5 minutes and then finally exits with:Error: Compat { error: NoAvailablePorts }
Version
0.9.0
on macos. I also tried:headless_chrome = { git = "https://github.com/atroche/rust-headless-chrome", features= ["fetch"] }but it does not build due to a missing dependency.
Can you try the github version again this PR #293 fixed the fetcher.
Yes, I think the fetcher might work now (not exactly sure how to test it), but whenever I try to use this version, I now get this panic which does not occur when I use a chromium version from a path:
Error: There are no available ports between 8000 and 9000 for debugging
I think we can close this.
Just for future reference, this is manifesting for me if I run as root without the --no-sandbox
flag and I pushed a fix on this PR: