【Ubuntu】[ERROR] Needs systemd (systemctl --user)の原因と対策
2024-2-21 | Ubuntu
Ubuntuで[ERROR] Needs systemd (systemctl --user)が発生する原因と対策を講じてなんとかしたい!
概要
今回の記事では、Ubuntuで[ERROR] Needs systemd (systemctl --user)が発生する原因と対策を掲載する。
仕様書
環境
- Ubuntu 22.04.2 LTS
原因
containerdをrootlessで起動できるようにスクリプトを実行したらこのエラーが発生した。
具体的に載せると下記のような感じになっちゃった。
$ containerd-rootless-setuptool.sh install
[ERROR] Needs systemd (systemctl --user)
インターネットで調べるとsystemdにパスが通ってないのがこのエラーの原因ということだったんだけどもそんなことある?
上記のページによるとrootでログインしてsuでユーザーを切り替えると環境変数が変な感じになるらしい。
だから、systemdにパスが通らないということっぽい。
対策
環境変数が変な感じになるのを防止するには、rootを介さず最初からユーザーでログインするかsystemd-containerに含まれるmachinectlコマンドでユーザーを切り替える。
machinectlコマンドでユーザーを切り替える例。
apt install systemd-container
machinectl shell <username>@
まとめ(感想文)
依存関係を解決するのに使えるかもね!
![【Ubuntu】[ERROR] Needs systemd (systemctl --user)の原因と対策](https://blog.nekonium.com/wp-content/themes/pdl-nekonium/images/cover-nekonium.png)