🫠
DevContainer接続エラー(Error reading shell environment.)
はじめに
最近、VSCodeで開発環境としてDevContainerを使用していた際に、接続エラーに直面しました。そのエラー内容と解決方法について説明します。
エラー内容
接続エラーが発生した際のログは以下の通りです。
[5591 ms] [05:34:26] Extension host agent started.
[5950 ms] [05:34:26] No uninstalled extensions found.
[8190 ms] Error reading shell environment.
[8190 ms] Command failed: /sbin/nologin -lic echo -n ********-****-****-****-************; cat /proc/self/environ; echo -n ********-****-****-****-************
[8190 ms] Start: Run in container: mkdir -p '/tmp/devcontainers-********-****-****-****-************' && cat > '/tmp/devcontainers-********-****-****-****-************/env-loginInteractiveShell.json' << 'envJSON'
[8206 ms]
[8206 ms]
[8213 ms] Initializing configuration support...
[8213 ms] Internal initialization of dev container support package...
[8224 ms] Port forwarding connection from 50616 > 38609 > 38609 in the container.
[8225 ms] Start: Run in container: /home/www-data/.vscode-server/bin/********/node -e
[8958 ms] Port forwarding 50616 > 38609 > 38609 stderr: Connection established
[9003 ms] Port forwarding connection from 50618 > 38609 > 38609 in the container.
[9003 ms] Start: Run in container: /home/www-data/.vscode-server/bin/********/node -e
[9071 ms] [05:34:29] [127.0.0.1][********][ManagementConnection] New connection established.
[9163 ms] [05:34:30] Log level changed to info
[9811 ms] Port forwarding 50618 > 38609 > 38609 stderr: Connection established
[10663 ms] [05:34:31] Installing extensions...
[10781 ms] [05:34:31] [127.0.0.1][********][ExtensionHostConnection] New connection established.
[11551 ms] [05:34:32] [127.0.0.1][********][ExtensionHostConnection] <********> Launched Extension Host Process.
[12894 ms] Extensions cache, remote removals: ms-ceintl.vscode-language-pack-ja-1.89.2024050109.sigzip
[14111 ms] [05:34:35] Installing extension 'ms-ceintl.vscode-language-pack-ja'...
[14123 ms] [05:34:35] Getting Manifest... ms-ceintl.vscode-language-pack-ja
[14257 ms] [05:34:35] Installing extension: ms-ceintl.vscode-language-pack-ja
[14617 ms] [05:34:35] ptyHost was unable to resolve shell environment Error: Unable to resolve your shell environment: Unexpected exit code from spawned shell (code 1, signal null)
at /home/www-data/.vscode-server/bin/********/out/vs/server/node/server.main.js:127:2626
at async /home/www-data/.vscode-server/bin/********/out/vs/server/node/server.main.js:95:24006
[14621 ms] [05:34:35] ptyHost was unable to resolve shell environment Error: Unable to resolve your shell environment: Unexpected exit code from spawned shell (code 1, signal null)
at /home/www-data/.vscode-server/bin/********/out/vs/server/node/server.main.js:127:2626
at async /home/www-data/.vscode-server/bin/********/out/vs/server/node/server.main.js:95:24006
[14622 ms] [05:34:35] ptyHost was unable to resolve shell environment Error: Unable to resolve your shell environment: Unexpected exit code from spawned shell (code 1, signal null)
at /home/www-data/.vscode-server/bin/********/out/vs/server/node/server.main.js:127:2626
at async /home/www-data/.vscode-server/bin/********/out/vs/server/node/server.main.js:95:24006
[14625 ms] [05:34:35] ptyHost was unable to resolve shell environment Error: Unable to resolve your shell environment: Unexpected exit code from spawned shell (code 1, signal null)
at /home/www-data/.vscode-server/bin/********/out/vs/server/node/server.main.js:127:2626
at async /home/www-data/.vscode-server/bin/********/out/vs/server/node/server.main.js:95:24006
[72912 ms] Extensions cache, remote removals: None
解決方法
ms-ceintl.vscode-language-pack-ja
という拡張機能が原因である可能性が高いと判断し、この拡張機能を一度無効化してみました。
code --uninstall-extension ms-ceintl.vscode-language-pack-ja
結果
拡張機能 ms-ceintl.vscode-language-pack-ja
を無効化することで問題が解決しました。この拡張機能に問題があった可能性が高いです。別の人の環境では問題はありません(無事にコンテナ側にインストールされています)。拡張機能のある特定のバージョンが問題を引き起こしたのが、そうでないのかまでは判断はできていません。
まとめ
VSCodeでDevContainerを使用する際に、拡張機能が原因でエラーが発生することがあります。今回のように、拡張機能を無効化することで問題が解決する場合があるので、同様の問題に直面した際にはぜひ試してみてください。
Let's happy coding
Discussion