LoginSignup
0
0

More than 1 year has passed since last update.

WSL2のUbuntu(genieインストール済み)にSSHで接続した場合のエラー対応

Last updated at Posted at 2022-07-18

はじめに

UbuntuにSSHで接続する際にgenie: already inside the bottle; cannot proceed
というエラーが発生した場合の対処方法

現象

$ ssh ubuntu
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.10.102.1-microsoft-standard-WSL2 x86_64)

# 中略

*** System restart required ***
Last login: Mon Jul 18 17:58:00 2022 from 172.23.176.1
Starting genie:
genie: already inside the bottle; cannot proceed
Connection to 172.23.182.158 closed.

原因

genieを起動時に実行するスクリプト(.bashrcに追加)が、SSH経由で実行時に重複して実行されているようです。

if [[ ! -v INSIDE_GENIE ]]; thenで2重起動しないようにチェックしていますが・・・・
SSH経由では、環境変数にセットされていない模様

# Are we in the bottle?
if [[ ! -v INSIDE_GENIE ]]; then
  echo "Starting genie:"
  exec /usr/bin/genie -s
fi
if [[ ]] ;
bashの条件判断
!
否定
-v
変数が定義されていた
INSIDE_GENIE
GENIEが実行時に定義される変数

対応方法

下記ページを参考に.bashrcを修正
https://github.com/arkane-systems/genie/issues/101

SSHから接続した場合export $(systemctl show-environment)を実行して、不足している環境変数を取り込む。

if [[ -v SSH_CLIENT ]]; then
  export $(systemctl show-environment)
fi

# Are we in the bottle?
if [[ ! -v INSIDE_GENIE ]]; then
    echo "Starting genie:"
    exec /usr/bin/genie -s
fi
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0