Debian sid amd64 環境で apt upgrade を行ったところ見慣れないエラーメッセージが表示され,処理もなかなか進みません.
sh: 0: getcwd() failed: No such file or directory
実際のメッセージはこんな感じで大量に出てきました.(以下は省略しています)
取得:131 http://ftp.debian.org/debian sid/main amd64 xpdf amd64 3.04+git20260802-1+b1 [147 kB] 574 MB を 6分 44秒 で取得しました (1,422 kB/s) sh: 0: getcwd() failed: No such file or directory sh: 0: getcwd() failed: No such file or directory sh: 0: getcwd() failed: No such file or directory sh: 0: getcwd() failed: No such file or directory : sh: 0: getcwd() failed: No such file or directory changelog を読み込んでいます... 完了 sh: 0: getcwd() failed: No such file or directory
getcwd() でメッセージを出しているようです.getcwd() は現在の作業ディレクトリを表示するものだったと思います.
$ echo '#include <stdio.h>
#include <unistd.h>
> int main(void) {
char path[4096];
> getcwd(path, sizeof path);
> puts(path);
> }
> ' > /tmp/pwd.c
$ gcc /tmp/pwd.c
$ cd `mktemp -d`
$ /tmp/a.out
/tmp/tmp.GsUokaUp4W
$ rm -rf `pwd`
$ /tmp/a.outので一旦 Ctrl + z して確認すると確かにもう存在しない場所でした.
$ ls -a $ touch hoge touch: 'hoge' に touch できません: そのようなファイルやディレクトリはありません
一旦 apt upgrade 中断してカレントディレクトリを変更して再度 apt upgrade をやり直すと普通に処理されました.
$ kill %1 $ cd $ sudo apt upgrade
カレントディレクトリが存在しない時の問題な感じなのでこんな感じで試すと再現できました.
$ cd `mktemp -d` $ rm -rf `pwd` $ ls -a $ sudo apt install hello sh: 0: getcwd() failed: No such file or directory Installing: hello sh: 0: getcwd() failed: No such file or directory Summary: Upgrading: 0, Installing: 1, Removing: 0, Not Upgrading: 151 sh: 0: getcwd() failed: No such file or directory Download size: 77.4 kB Space needed: 377 kB / 18.7 GB available 取得:1 http://ftp.debian.org/debian sid/main amd64 hello amd64 2.12.3-1 [77.4 kB] 77.4 kB を 1秒 で取得しました (126 kB/s) sh: 0: getcwd() failed: No such file or directory sh: 0: getcwd() failed: No such file or directory :
apt purge とか apt autoclean でも起きるようです.dpkg でも起きました.
$ sudo dpkg -i ~/Downloads/chawan-0-5-4-amd64.deb sh: 0: getcwd() failed: No such file or directory sh: 0: getcwd() failed: No such file or directory (データベースを読み込んでいます ... 現在 1003672 個のファイルとディレクトリがインストールされています。) .../chawan-0-5-4-amd64.deb を展開する準備をしています ... chawan (0.5.4) で (0.5.3-1 に) 上書き展開しています ... chawan (0.5.4) を設定しています ... man-db (2.13.3-1) のトリガを処理しています ... mailcap (3.77) のトリガを処理しています ... gnome-menus (3.38.1-3) のトリガを処理しています ... desktop-file-utils (0.28-1) のトリガを処理しています ...
ということで存在するパスで実行しましょう.
環境
$ dpkg-query -W apt dpkg apt 3.3.8 dpkg 1.23.12 $ lsb_release -dr Description: Debian GNU/Linux forky/sid Release: n/a $ arch x86_64
Reposts