chrome-remote-desktop[xxxxx]: xdpyinfo: unable to open display “:20”.強制改使用xvfb預設啟動

之前有這篇文章的修改方式:
UBUNTU升級到24.04.2後,本來google remote desktop可以用,變成不能用的可能解法
https://jir.idv.tw/wordpress/?p=3246

一樣要再感嘆AI、讚嘆AI。
前幾天apy upgrade把chrome-remote-desktop版本升級後,又把它恢復成官方原始檔案。
再次出現錯誤訊息無法啟用:
Active: failed (Result: exit-code) since Sat 2025-09-27 19:51:16 CST; 3min 26s ago
Duration: 11.481s
Process: ExecStart=/opt/google/chrome-remote-desktop/chrome-remote-desktop --start --new-session (code=exited, status=1/FAILURE)
Main PID: (code=exited, status=1/FAILURE)
CPU: 5ms
9月 27 19:51:05 systemd[1]: Started chrome-remote-desktop@______.service - Chrome Remote Desktop instance for ______.
9月 27 19:51:09 chrome-remote-desktop[]: xdpyinfo: unable to open display ":20".
9月 27 19:51:10 chrome-remote-desktop[]: xdpyinfo: unable to open display ":20".
9月 27 19:51:15 chrome-remote-desktop[]: xdpyinfo: unable to open display ":20".

上次的改法有點複雜,然後我忘記自己有留文章記錄。
所以再問了一次AI,大概魔法咒語很明確,這次AI回答的方案整個超簡單。
修改這個檔案:
nano /opt/google/chrome-remote-desktop/chrome-remote-desktop
找到這行:
USE_XVFB_ENV_VAR = "CHROME_REMOTE_DESKTOP_USE_XVFB"
然後下面新增這行:
# Start custom modification: Force Xvfb driver to be used
os.environ[USE_XVFB_ENV_VAR] = '1'
# End custom modification

內容改成像這樣:
# This script has a sensible default for the initial and maximum desktop size,
# which can be overridden either on the command-line, or via a comma-separated
# list of sizes in this environment variable.
DEFAULT_SIZES_ENV_VAR = "CHROME_REMOTE_DESKTOP_DEFAULT_DESKTOP_SIZES"

# By default, this script launches Xorg as the virtual X display, using the
# dummy display driver and void input device, unless Xorg+Dummy is deemed
# unsupported.
When this environment variable is set, the script will instead
# launch Xvfb.
USE_XVFB_ENV_VAR = "CHROME_REMOTE_DESKTOP_USE_XVFB"
# Start custom modification: Force Xvfb driver to be used
os.environ[USE_XVFB_ENV_VAR] = '1'
# End custom modification

# If this environment variable is set, the script will launch a Wayland
# session instead of X11.
USE_WAYLAND_ENV_VAR = "CHROME_REMOTE_DESKTOP_USE_WAYLAND"
# ... 程式碼後面部分 ...

修改存檔之後,重新執行一次
sudo systemctl restart chrome-remote-desktop@username.service
應該馬上就會啟動正常了,XDDDD

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

請輸入下列驗證碼計算後阿拉伯數字 (Translate it, if not Taiwanese to post reply) *