Search code examples
google-chromeubuntuubuntu-16.04xdgutils

Google Chrome not launching on Ubuntu even after installing it


OS: Ubuntu 16.04.3 LTS

  1. I was trying to run unit test for an angular project using ng test but it failed to start browser giving error ERROR [launcher]: Cannot start Chrome.

  2. Even puppteer only runs in headless mode, for headless: false it gives error UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Failed to launch chrome!

  3. Also on xdg-open https://example.com it gives the log

    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: www-browser: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: links2: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: elinks: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: links: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: lynx: not found
    /usr/bin/xdg-open: 778: /usr/bin/xdg-open: w3m: not found
    xdg-open: no method available for opening 'https://example.com/
    

So it's safe to say there's a problem with Chrome, and not the application/technology I am running. But I also installed google chrome using the following

wget https://dl.google.com/linux/linux_signing_key.pub
sudo apt-key add linux_signing_key.pub
sudo apt update
sudo apt install google-chrome-stable

and yet, nothing changed.

EDIT

the /usr/bin/xdg-open file has the following, if it helps

# if BROWSER variable is not set, check some well known browsers instead
if [ x"$BROWSER" = x"" ]; then
    BROWSER=www-browser:links2:elinks:links:lynx:w3m
    if [ -n "$DISPLAY" ]; then
        BROWSER=x-www-browser:firefox:iceweasel:seamonkey:mozilla:epiphany:konqueror:chromium:google-chrome:$BROWSER
    fi
fi

Solution

  • First of all, the third case in my ques i.e. /usr/bin/xdg-open: 778: /usr/bin/xdg-open: links2: not found ... was occurring because I didn't had these text browsers installed on my ubuntu system, which I was accessing remotely using Putty.

    Secondly, most probably because of this remote access the $DISPLAY variable was coming null in usr/bin/zdg-open file. So in order to make it open a link on a DISPLAY setting available on my local system had to use x11 forwarding concept of Putty; first downloaded Xming for windows, then ran Putty with x11 enabled, after which the above problem (for all cases) was solved.

    If the x11 is disabled, the link will open in the text browsers I had installed like links