WSL(Ubuntu)でVivliostyleのvivliostyle preview
でエラーが発生し、ブラウザが立ち上がらなかった。
解決方法を記載する。
環境
- WSL (Ubuntu 22.04 LTS)
- Vivliostyle CLI 8.10.0
- Vivliostyle Core 2.29.0
エラー内容
$ vivliostyle preview
✖ launch =launch =Target page, context or browser has been closed
Browser logs:
<launching> /home/<username>/.cache/ms-playwright/chromium-1112/chrome-linux/chrome --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --no-sandbox --allow-file-access-from-files --disable-web-security --lang=en --user-data-dir=/tmp/playwright_chromiumdev_profile-7QTpYX --remote-debugging-pipe --no-startup-window
<launched> pid=1818
[pid=1818] <process did exit =exitCode=127, signal=null>
[pid=1818] starting temporary directories cleanup
Call log:
- <launching> /home/<username>/.cache/ms-playwright/chromium-1112/chrome-linux/chrome --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --no-sandbox --allow-file-access-from-files --disable-web-security --lang=en --user-data-dir=/tmp/playwright_chromiumdev_profile-7QTpYX --remote-debugging-pipe --no-startup-window
- <launched> pid=1818
- [pid=1818] <process did exit =exitCode=127, signal=null>
- [pid=1818] starting temporary directories cleanup
at <anonymous> (/home/<username>/<repository-name>/<book-name>/node_modules/@vivliostyle/cli/dist/browser.js:25:34)
at launchBrowser (/home/<username>/<repository-name>/<book-name>/node_modules/@vivliostyle/cli/dist/browser.js:5:36)
at <anonymous> (/home/<username>/<repository-name>/<book-name>/node_modules/@vivliostyle/cli/dist/preview.js:94:12)
at openPreview (/home/<username>/<repository-name>/<book-name>/node_modules/@vivliostyle/cli/dist/preview.js:92:23)
at <anonymous> (/home/<username>/<repository-name>/<book-name>/node_modules/@vivliostyle/cli/dist/preview.js:129:16)
If you think this is a bug, please report at https://github.com/vivliostyle/vivliostyle-cli/issues
error =script "preview" exited with code 1
解決策
lddコマンドで、依存関係にあるパッケージを確認する。
今回は、プレビュー用ブラウザのパッケージが足りないと思い、not found
が出ているパッケージをインストールした。
ldd /home/<username>/.cache/ms-playwright/chromium-1112/chrome-linux/chrome | grep "not found”
自分の環境では下記のパッケージが足りていなかった。
sudo apt install libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon0 libatspi2.0-0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2
インストール後、再度vivliostyle preview
を実行すると、ブラウザが起動することを確認できた。