しふみんのブログ

しふみんのブログです。

ソースコードからインストールしたGitをアンインストールできない問題

問題

さくらVPSCentOSソースコードからインストールしたGit(2.3.1)をアンインストールして最新版のGit(2.4.5)をインストールしようとしたところ、アンインストールできなかった。

# cd /usr/local/src/git-2.3.1/
# make uninstall
make: *** ターゲット `uninstall' を make するルールがありません.  中止.
# find . -type f -name "Makefile"
(前略)
./Makefile
(後略)

Makefileはあるけど、Uninstallに関する記述がない?

環境

CentOS 6.6

Git 2.3.1 # アンインストールできなかったバージョン
(インストールディレクトリは $ ./configure --prefix=/usr/local/ と指定した)

解決

適当なディレクトリにもう一度インストールしてみて、その時インストールされたファイルをリストにしてそれを元に消すという方法。

まず、適当なディレクトリを作成し、そこにGitをインストールする。

# mkdir /tmp/test_git
# cd /usr/local/src/git-2.3.1/
# make prefix=/tmp/test_git install

次に、インストールされたファイルをリストとして出力する。

# find /tmp/test_git -type f -print > /tmp/git-installlist.txt

そして、出力されたファイルの全行の /tmp/test_git/usr/local (元のインストールディレクトリ)に置換する。

# vim /tmp/git-installlist.txt
:%s/\/tmp\/test_git/\/usr\/local/g

置換した結果

/tmp/test_git/libexec/git-core/git-send-pack
/tmp/test_git/libexec/git-core/git-am
/tmp/test_git/libexec/git-core/git
(後略)

↓↓↓

/usr/local/libexec/git-core/git-send-pack
/usr/local/libexec/git-core/git-am
/usr/local/libexec/git-core/git
(後略)

最後に、| xargsでgit-installlist.txtの内容をrmに渡してファイルを消す。

# cat /tmp/git-installlist.txt | xargs rm -f

アンインストール完了。 これにて一件落着です。

参考

ja.stackoverflow.com

qiita.com