ubuntudartchromiumdartium

Configuring dart content_shell on ubuntu trusty


I am trying to run xvfb-run -s '-screen 0 1024x768x24' pub run test -p content-shell on Ubuntu Trusty.

Dart and content shell are installed in the following way:

# Install Dart
curl https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --import --no-default-keyring --keyring /etc/apt/trusted.gpg.d/google.gpg
curl https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list
apt-get update
apt-get install --assume-yes  dart=1.15.0-1

# Content shell and dartium
curl https://storage.googleapis.com/dart-archive/channels/stable/release/1.15.0/dartium/dartium-linux-x64-release.zip> /dartium-linux-x64-release.zip && \
    unzip /dartium-linux-x64-release.zip -d /opt/google && \
    mv /opt/google/dartium-* /opt/google/dartium && \
    chmod -R 755 /opt/google/dartium

curl http://storage.googleapis.com/dart-archive/channels/stable/release/1.15.0/dartium/content_shell-linux-x64-release.zip > /content_shell-linux-x64-release.zip && \
    unzip /content_shell-linux-x64-release.zip -d /opt/google && \
    mv /opt/google/drt-* /opt/google/content_shell && \
    chmod -R 755 /opt/google/content_shell

with /opt/google/content_shell being included in my PATH variable.

# which content_shell
/opt/google/content_shell/content_shell

However, when I run that test attempt:

# xvfb-run -s '-screen 0 1024x768x24' pub run  test -p content-shell

I receive errors looking like:

Failed to run Content Shell: Content Shell failed with exit code 1..
  dart:async                              Future.Future.error
  package:async/src/result/error.dart 30  ErrorResult.asFuture
  package:async/src/result.dart 93        Result.release.<fn>
  ===== asynchronous gap ===========================
  dart:async                              _Future.then
  package:async/src/result.dart 93        Result.release

I do not see any more information. I am not sure if this should be concerning, though it looks ominous:

# content_shell --version
[1114:1114:0617/150811:9471556647:ERROR:browser_main_loop.cc(189)] Running without the SUID sandbox! See https://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment for more information on developing with the sandbox on.
[1116:1116:0100/000000:9471568304:ERROR:zygote_linux.cc(612)] write: Broken pipe

My questions is how can I configure content shell to install correctly so it will run tests with pub run test -p content-shell?


Solution

  • In my case, I needed some fonts.

    You can see what errors contentshell has by viewing the log file, for my install location this is:

    cat /opt/google/content_shell/content_shell.log
    

    This showed me I was missing a bunch of fonts, which caused contentshell to silently fail.

    The ones I had to install (or hack my way around since a lot of the fonts packages are huge, and since this is a Docker container I wanted to minimize bloat):

    apt-get update && apt-get install fonts-tlwg-garuda
    
    # fix dart content shell
    mkdir /usr/share/fonts/truetype/kochi
    cd /usr/share/fonts/truetype/kochi
    ln -s ../dejavu/DejaVuSans-Bold.ttf kochi-gothic.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf kochi-mincho.ttf
    
    mkdir /usr/share/fonts/truetype/ttf-indic-fonts-core/
    cd /usr/share/fonts/truetype/ttf-indic-fonts-core/
    ln -s ../dejavu/DejaVuSans-Bold.ttf lohit_hi.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf lohit_ta.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf MuktiNarrow.ttf
    
    mkdir /usr/share/fonts/truetype/ttf-punjabi-fonts/
    cd /usr/share/fonts/truetype/ttf-punjabi-fonts/
    ln -s ../dejavu/DejaVuSans-Bold.ttf lohit_pa.ttf
    ln -s dejavu/ ttf-dejavu
    cd /usr/share/fonts/truetype
    ln -s dejavu/ ttf-dejavu
    
    mkdir /usr/share/fonts/truetype/msttcorefonts/
    cd /usr/share/fonts/truetype/msttcorefonts/
    ln -s ../dejavu/DejaVuSans-Bold.ttf Arial.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Arial_Bold.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Arial_Bold_Italic.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Arial_Italic.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Comic_Sans_MS.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Comic_Sans_MS_Bold.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Courier_New.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Courier_New_Bold.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Courier_New_Bold_Italic.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Courier_New_Italic.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Georgia.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Georgia_Bold.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Georgia_Bold_Italic.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Georgia_Italic.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Impact.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Trebuchet_MS.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Trebuchet_MS_Bold.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Trebuchet_MS_Bold_Italic.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Trebuchet_MS_Italic.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Times_New_Roman.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Times_New_Roman_Bold.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Times_New_Roman_Bold_Italic.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Times_New_Roman_Italic.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Verdana.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Verdana_Bold.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Verdana_Bold_Italic.ttf
    ln -s ../dejavu/DejaVuSans-Bold.ttf Verdana_Italic.ttf
    

    Most of these were from this source code validation. It's far easier to find the list it's validating first instead of running the command and seeing the next one a million times.

    You may wish to actually install this package.