Go chromedp failure

Even viewing the “Can’t find Chrome Binary” topic, wasn’t enough to solve my problem.

I have an API with a web crawler in go using chromedp, but each time I call the request with it, returns me the error:

exec: “google-chrome”: executable file not found in $PATH

this is my render-build.sh:

set -o errexit

STORAGE_DIR=/opt/render/project/.render

if [[ ! -d $STORAGE_DIR/chrome ]]; then
echo "...Downloading Chrome"
mkdir -p $STORAGE_DIR/chrome
cd $STORAGE_DIR/chrome
wget -P ./ https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
dpkg -x ./google-chrome-stable_current_amd64.deb $STORAGE_DIR/chrome
rm ./google-chrome-stable_current_amd64.deb
cd $HOME/project/src # Make sure we return to where we were
else
echo "...Using Chrome from cache"
fi

# be sure to add Chromes location to the PATH as part of your Start Command
# export PATH="${PATH}:/opt/render/project/.render/chrome/opt/google/chrome/"
# echo $STORAGE_DIR
# echo $PATH

go build -ldflags '-s -w' -o ./app main.go

My build command: ./render-build.sh

My start command: export PATH="${PATH}:/opt/render/project/.render/chrome/opt/google/chrome/"; ./app

Could someone help me? I intend to create after this a medium article about render + go + gin + chromedp

Ok, since no one has shown up, I start testing without a shell using the “render-build.sh” and now “render-start.sh”.

This leads me to a strange conclusion: in a “build time” I have chrome but in “start time” I don’t.

I made a test, and sent everything that was in “render-build.sh” to “render-start.sh”.

And then, boom, it worked, makes my compile time bigger and bugged? Maybe, but at least works.
(You only have to correct the “cd $HOME” part to your project path, just add an “echo $(pwd)” in the second line to see.

Hey,

Compiling a Go app and installing Chrome at runtime is going to be really inefficient, especially on a free instance type which spins-down after 15 minutes of inactivity. Every time it spins back up, it’ll be doing it doing all that work again, and will likely have less resource than a build container.

I’m not quite sure why you’re seeing the issue from your app. I’ve created a barebones Node app (based on the Render Express example), to double-check this build script (which seems like it’s taken from my gist). That repo is here GitHub - BigAlRender/chrome-install-test: chrome-test

I tried with both raw commands in the Start Command, and setting it to the start script in the repo. I also added logging the PATH from Node. All scenarios logged the PATH with Chrome install path included. I also run which google-chrome and that would also return the full path to the binary.

For example:

Mar 9 04:17:13 PM ==> Starting service with './render-start.sh'
Mar 9 04:17:13 PM === Checking for Chrome...
Mar 9 04:17:13 PM $PATH is:
Mar 9 04:17:13 PM /opt/render/project/nodes/node-19.7.0/bin:/opt/render/project/src/node_modules/.bin:/opt/render/project/src/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/render/project/.render/chrome/opt/google/chrome
Mar 9 04:17:13 PM 
Mar 9 04:17:13 PM which google-chrome:
Mar 9 04:17:13 PM /opt/render/project/.render/chrome/opt/google/chrome/google-chrome
Mar 9 04:17:13 PM
Mar 9 04:17:14 PM env PATH (in Node): /opt/render/project/nodes/node-19.7.0/bin:/opt/render/project/src/node_modules/.bin:/opt/render/project/src/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/render/project/.render/chrome/opt/google/chrome
Mar 9 04:17:14 PM Example app listening on port 10000!
Mar 9 04:17:23 PM Your service is live 🎉

One tiny thing that may be incorrect in your message is the trailing / on the export PATH... but I’m not sure if that would be enough to cause the error you shared.

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.