zaki work log

作業ログやら生活ログやらなんやら

IUSリポジトリのパッケージでCentOS 7にGit version 2をインストールした

VS CodeのGitHistoryやGitLens拡張がいつの間にか動かなくなってた。
エラーの通りGit Versionが1系なのが原因なのでアップデートしてみる。

f:id:zaki-hmkc:20200912103920p:plain

こんなエラー

git shortlog -e -s -n HEAD  (completed in 0.008s)
git log --full-history --pretty=oneline --date-order --decorate=full --skip=0 --max-count=100 master --  (completed in 0.015s)
git rev-list --full-history --count master --  (completed in 0.023s)
git show --pretty=oneline --decorate=full --numstat 87662dc26e01e584e2f728ca625010b4323fbc7a  (completed in 0.009s)
git show --name-status --pretty=oneline -M --first-parent 87662dc26e01e584e2f728ca625010b4323fbc7a  (completed in 0.006s)
Unrecognized file stat status 'c

IUSリポジトリの追加

Yumリポジトリリストはこんな感じ

[zaki@cloud-dev ~]$ yum repolist
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
リポジトリー ID               リポジトリー名                                        状態
azure-cli                     Azure CLI                                                 80
base/7/x86_64                 CentOS-7 - Base                                       10,070
docker-ce-stable/x86_64       Docker CE Stable - x86_64                                 79
epel/x86_64                   Extra Packages for Enterprise Linux 7 - x86_64        13,445
extras/7/x86_64               CentOS-7 - Extras                                        413
kubernetes                    Kubernetes                                               561
updates/7/x86_64              CentOS-7 - Updates                                     1,127
repolist: 25,775
[zaki@cloud-dev ~]$ rpm -qa | grep git
git-1.8.3.1-23.el7_8.x86_64
linux-firmware-20191203-76.gite8a0f4c.el7.noarch
crontabs-1.11-6.20121102git.el7.noarch

Git公式のダウンロードページに行くとRHELCentOSについてはこう書かれている。

Red Hat Enterprise Linux, Oracle Linux, CentOS, Scientific Linux, et al.

RHEL and derivatives typically ship older versions of git. You can download a tarball and build from source, or use a 3rd-party repository such as the IUS Community Project to obtain a more recent version of git.

ius.io

IUSなんてあったんだ、知らなかった。
セットアップのページを見ると、RHEL/CentOS7の場合はこの通り。

yum install \
https://repo.ius.io/ius-release-el7.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

インストールするとリポジトリリストが更新される。

[zaki@cloud-dev ~]$ yum repolist
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
ius                                                                | 1.3 kB  00:00:00
ius/x86_64/primary                                                 | 107 kB  00:00:00
ius                                                                               440/440
リポジトリー ID               リポジトリー名                                        状態
azure-cli                     Azure CLI                                                 80
base/7/x86_64                 CentOS-7 - Base                                       10,070
docker-ce-stable/x86_64       Docker CE Stable - x86_64                                 79
epel/x86_64                   Extra Packages for Enterprise Linux 7 - x86_64        13,445
extras/7/x86_64               CentOS-7 - Extras                                        413
ius/x86_64                    IUS for Enterprise Linux 7 - x86_64                      440
kubernetes                    Kubernetes                                               561
updates/7/x86_64              CentOS-7 - Updates                                     1,127
repolist: 26,215
[zaki@cloud-dev ~]$

gitをsearchしてみる

$ yum search git

[...]

git.x86_64 : Fast Version Control System
git222.x86_64 : Fast Version Control System
git224.x86_64 : Fast Version Control System

なるほど、この辺だな。(git.x86_64は既存のもの)

$ yum info git224
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.riken.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.riken.jp
 * updates: ftp.riken.jp
利用可能なパッケージ
名前                : git224
アーキテクチャー    : x86_64
バージョン          : 2.24.3
リリース            : 1.el7.ius
容量                : 140 k
リポジトリー        : ius/x86_64
要約                : Fast Version Control System
URL                 : https://git-scm.com/
ライセンス          : GPLv2
説明                : Git is a fast, scalable, distributed revision control system with an
                    : unusually rich command set that provides both high-level operations
                    : and full access to internals.
                    :
                    : The git rpm installs common set of tools which are usually using
                    : with small amount of dependencies. To install all git packages,
                    : including tools for integrating with other SCMs, install the git-all
                    : meta-package.

インストール

before

[zaki@cloud-dev ~]$ git --version
git version 1.8.3.1

installとコンフリクト解消

以下は作業順の記述だけど、結論としては既存gitは削除の必要がある。

$ sudo yum install git224
[zaki@cloud-dev ~]$ sudo yum install git224
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp-srv2.kddilabs.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp-srv2.kddilabs.jp
 * updates: ftp-srv2.kddilabs.jp
ius                                                                | 1.3 kB  00:00:00
ius/x86_64/primary                                                 | 107 kB  00:00:00
ius                                                                               440/440
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ git224.x86_64 0:2.24.3-1.el7.ius を インストール
--> 依存性の処理をしています: perl-Git = 2.24.3-1.el7.ius のパッケージ: git224-2.24.3-1.el7.ius.x86_64
--> 依存性の処理をしています: git-core-doc = 2.24.3-1.el7.ius のパッケージ: git224-2.24.3-1.el7.ius.x86_64
--> 依存性の処理をしています: git-core = 2.24.3-1.el7.ius のパッケージ: git224-2.24.3-1.el7.ius.x86_64
--> 依存性の処理をしています: emacs-filesystem >= 24.3 のパッケージ: git224-2.24.3-1.el7.ius.x86_64
--> 依存性の処理をしています: libsecret-1.so.0()(64bit) のパッケージ: git224-2.24.3-1.el7.ius.x86_64
--> トランザクションの確認を実行しています。
---> パッケージ emacs-filesystem.noarch 1:24.3-23.el7 を インストール
---> パッケージ git224-core.x86_64 0:2.24.3-1.el7.ius を インストール
--> 依存性の処理をしています: libpcre2-8.so.0()(64bit) のパッケージ: git224-core-2.24.3-1.el7.ius.x86_64
---> パッケージ git224-core-doc.noarch 0:2.24.3-1.el7.ius を インストール
---> パッケージ git224-perl-Git.noarch 0:2.24.3-1.el7.ius を インストール
---> パッケージ libsecret.x86_64 0:0.18.6-1.el7 を インストール
--> トランザクションの確認を実行しています。
---> パッケージ pcre2.x86_64 0:10.23-2.el7 を インストール
--> 衝突を処理しています: git224-2.24.3-1.el7.ius.x86_64 は git < 2.24.3-1.el7.ius と衝突
しています
--> 衝突を処理しています: git224-core-2.24.3-1.el7.ius.x86_64 は git-core < 2.24.3-1.el7.ius と衝突しています
--> 衝突を処理しています: git224-perl-Git-2.24.3-1.el7.ius.noarch は perl-Git < 2.24.3-1.el7.ius と衝突しています
--> 依存性解決を終了しました。
エラー: git224-core conflicts with git-1.8.3.1-23.el7_8.x86_64
エラー: git224 conflicts with git-1.8.3.1-23.el7_8.x86_64
エラー: git224-perl-Git conflicts with perl-Git-1.8.3.1-23.el7_8.noarch
 問題を回避するために --skip-broken を用いることができます。
 これらを試行できます: rpm -Va --nofiles --nodigest

既存のGit 1.8とコンフリクトしてるみたい。

[zaki@cloud-dev ~]$ sudo yum remove git
読み込んだプラグイン:fastestmirror
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ git.x86_64 0:1.8.3.1-23.el7_8 を 削除
--> 依存性の処理をしています: git = 1.8.3.1-23.el7_8 のパッケージ: perl-Git-1.8.3.1-23.el7_8.noarch
--> トランザクションの確認を実行しています。
---> パッケージ perl-Git.noarch 0:1.8.3.1-23.el7_8 を 削除
--> 依存性解決を終了しました。

依存性を解決しました

==========================================================================================
 Package            アーキテクチャー バージョン                  リポジトリー        容量
==========================================================================================
削除中:
 git                x86_64           1.8.3.1-23.el7_8            @updates            22 M
依存性関連での削除をします:
 perl-Git           noarch           1.8.3.1-23.el7_8            @updates            57 k

トランザクションの要約
==========================================================================================
削除  1 パッケージ (+1 個の依存関係のパッケージ)

インストール容量: 22 M
上記の処理を行います。よろしいでしょうか? [y/N]

これでコンフリクトしてたものが消えて、インストールできる。

$ sudo yum install git224

after

[zaki@cloud-dev ~]$ git --version
git version 2.24.3

これでGitLensやGit Historyもちゃんと動いた。

f:id:zaki-hmkc:20200912104420p:plain