🐟

Amazon Linux 2にfishを入れる方法

2023/08/04に公開

まとめ

  • Amazon Linux 2のyum経由でインストールされるfishがのバージョンが 2.3 と7年前にリリースされたバージョンなので新しいバージョンを利用しようとしました。
  • 簡単にはインストールできなかったので、試行錯誤した結果を掲載しておきます。
  • 結果としては、Cent OS 7用のrpmパッケージを直接入れるのが一番楽です。
  • Amazon Linux 2023 へのインストール記事はこちらです。

問題

現在のfishの最新バージョン3.6.1 になっています。

それに対して、Amazon Linux 2で利用しているRHELからインストールされるfishのバージョンは、2.3.1 となっています。
これは2016年11月8日にリリースされたバージョンなのでかなり古いです。

(そもそも、Amazon Linux 2は2023年6月30日までのサポートされないので注意です。)

そこで、tmuxのオフィシャルサイトにあるrpmパッケージ経由のインストール方法を試してみました。

Alt text

Amazon Linux 2のRHELのバージョンは7なので、

[ec2-user@ip-172-26-15-209 ~]$ rpm -E %{rhel}
7

Cent OSの7のrpm repositoryを使ってインストールを試みましたが、glibcの依存関係を満たせないので解決が困難そうです。

yum repositoryを追加してインストールしようとした際のエラーの内容を以下に記載しておきます。

[root@ip-172-26-15-209 ec2-user]# cd /etc/yum.repos.d/
[root@ip-172-26-15-209 yum.repos.d]# wget https://download.opensuse.org/repositories/shells:fish:release:3/CentOS_7/shells:fish:release:3.repo
--2023-08-04 03:00:38--  https://download.opensuse.org/repositories/shells:fish:release:3/CentOS_7/shells:fish:release:3.repo
Resolving download.opensuse.org (download.opensuse.org)... 2001:67c:2178:8::13, 195.135.221.134
Connecting to download.opensuse.org (download.opensuse.org)|2001:67c:2178:8::13|:443...
connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://download.opensuse.org/repositories/shells:fish:release:/3/CentOS_7/shells:fish:release:3.repo [following]
--2023-08-04 03:00:39--  https://download.opensuse.org/repositories/shells:fish:release:/3/CentOS_7/shells:fish:release:3.repo
Reusing existing connection to [download.opensuse.org]:443.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://download.opensuse.org/repositories/shells:fish:/release:/3/CentOS_7/shells:fish:release:3.repo [following]
--2023-08-04 03:00:40--  https://download.opensuse.org/repositories/shells:fish:/release:/3/CentOS_7/shells:fish:release:3.repo
Reusing existing connection to [download.opensuse.org]:443.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://download.opensuse.org/repositories/shells:/fish:/release:/3/CentOS_7/shells:fish:release:3.repo [following]
--2023-08-04 03:00:40--  https://download.opensuse.org/repositories/shells:/fish:/release:/3/CentOS_7/shells:fish:release:3.repo
Reusing existing connection to [download.opensuse.org]:443.
HTTP request sent, awaiting response... 200 OK
Length: 299 [application/x-download]
Saving to: 'shells:fish:release:3.repo'

100%[=====================================================================================================================================================================================================>] 299         --.-K/s   in 0s

2023-08-04 03:00:40 (46.6 MB/s) - 'shells:fish:release:3.repo' saved [299/299]

[root@ip-172-26-15-209 yum.repos.d]# yum install fish
Failed to set locale, defaulting to C
Loaded plugins: etckeeper, extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                                                                                                                              | 3.7 kB  00:00:00
shells_fish_release_3                                                                                                                                                                                                   | 1.7 kB  00:00:00
Not using downloaded shells_fish_release_3/repomd.xml because it is older than what we have:
  Current   : Sat Jul 29 04:23:36 2023
  Downloaded: Fri Apr 14 08:56:31 2023
290 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package fish.x86_64 0:3.6.1-1.2 will be updated
---> Package fish.x86_64 0:3.6.1-1.5 will be an update
--> Processing Dependency: libc.so.6(GLIBC_2.34)(64bit) for package: fish-3.6.1-1.5.x86_64
--> Processing Dependency: libstdc++.so.6(GLIBCXX_3.4.29)(64bit) for package: fish-3.6.1-1.5.x86_64
--> Processing Dependency: libstdc++.so.6(CXXABI_1.3.13)(64bit) for package: fish-3.6.1-1.5.x86_64
--> Processing Dependency: libm.so.6(GLIBC_2.29)(64bit) for package: fish-3.6.1-1.5.x86_64
--> Finished Dependency Resolution
Error: Package: fish-3.6.1-1.5.x86_64 (shells_fish_release_3)
           Requires: libstdc++.so.6(GLIBCXX_3.4.29)(64bit)
Error: Package: fish-3.6.1-1.5.x86_64 (shells_fish_release_3)
           Requires: libc.so.6(GLIBC_2.34)(64bit)
Error: Package: fish-3.6.1-1.5.x86_64 (shells_fish_release_3)
           Requires: libm.so.6(GLIBC_2.29)(64bit)
Error: Package: fish-3.6.1-1.5.x86_64 (shells_fish_release_3)
           Requires: libstdc++.so.6(CXXABI_1.3.13)(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

また、こちらの記事を見る感じではLinuxにhomebrewを入れてhomebrew経由でfishをインストールすることによって最新のfishがインストールできそうです。しかしながら、fishのためだけにhomebrewをインストールしたくはありません。

色々試行錯誤した結果、fishのオフィシャルサイトが直接提供しているCent OS 7向けのrpmパッケージをインストールしたら比較的すんなりインストールできたので紹介します。

Alt text

インストール

[ec2-user@ip-172-26-15-209 ~]$ sudo yum install pcre2-devel
Failed to set locale, defaulting to C
Loaded plugins: etckeeper, extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                                                                                                                                                                                                                                                                                                                                                                              | 3.7 kB  00:00:00
290 packages excluded due to repository priority protections
Resolving Dependencies
--> Running transaction check
---> Package pcre2-devel.x86_64 0:10.23-11.amzn2.0.1 will be installed
--> Processing Dependency: pcre2-utf32(x86-64) = 10.23-11.amzn2.0.1 for package: pcre2-devel-10.23-11.amzn2.0.1.x86_64
--> Processing Dependency: pcre2-utf16(x86-64) = 10.23-11.amzn2.0.1 for package: pcre2-devel-10.23-11.amzn2.0.1.x86_64
--> Processing Dependency: libpcre2-32.so.0()(64bit) for package: pcre2-devel-10.23-11.amzn2.0.1.x86_64
--> Processing Dependency: libpcre2-16.so.0()(64bit) for package: pcre2-devel-10.23-11.amzn2.0.1.x86_64
--> Running transaction check
---> Package pcre2-utf16.x86_64 0:10.23-11.amzn2.0.1 will be installed
---> Package pcre2-utf32.x86_64 0:10.23-11.amzn2.0.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
 Package                                                                                                              Arch                                                                                                            Version                                                                                                                        Repository                                                                                                           Size
===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
Installing:
 pcre2-devel                                                                                                          x86_64                                                                                                          10.23-11.amzn2.0.1                                                                                                             amzn2-core                                                                                                          547 k
Installing for dependencies:
 pcre2-utf16                                                                                                          x86_64                                                                                                          10.23-11.amzn2.0.1                                                                                                             amzn2-core                                                                                                          192 k
 pcre2-utf32                                                                                                          x86_64                                                                                                          10.23-11.amzn2.0.1                                                                                                             amzn2-core                                                                                                          183 k

Transaction Summary
===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 923 k
Installed size: 2.6 M
Is this ok [y/d/N]: ^Y
Is this ok [y/d/N]: y
Downloading packages:
(1/3): pcre2-devel-10.23-11.amzn2.0.1.x86_64.rpm                                                                                                                                                                                                                                                                                                                                                                                                                        | 547 kB  00:00:00
(2/3): pcre2-utf16-10.23-11.amzn2.0.1.x86_64.rpm                                                                                                                                                                                                                                                                                                                                                                                                                        | 192 kB  00:00:00
(3/3): pcre2-utf32-10.23-11.amzn2.0.1.x86_64.rpm                                                                                                                                                                                                                                                                                                                                                                                                                        | 183 kB  00:00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                                                                                                                                                                                                                                                                          3.1 MB/s | 923 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
etckeeper: pre transaction commit
  Installing : pcre2-utf16-10.23-11.amzn2.0.1.x86_64                                                                                                                                                                                                                                                                                                                                                                                                                                       1/3
  Installing : pcre2-utf32-10.23-11.amzn2.0.1.x86_64                                                                                                                                                                                                                                                                                                                                                                                                                                       2/3
  Installing : pcre2-devel-10.23-11.amzn2.0.1.x86_64                                                                                                                                                                                                                                                                                                                                                                                                                                       3/3
etckeeper: post transaction commit
  Verifying  : pcre2-utf32-10.23-11.amzn2.0.1.x86_64                                                                                                                                                                                                                                                                                                                                                                                                                                       1/3
  Verifying  : pcre2-utf16-10.23-11.amzn2.0.1.x86_64                                                                                                                                                                                                                                                                                                                                                                                                                                       2/3
  Verifying  : pcre2-devel-10.23-11.amzn2.0.1.x86_64                                                                                                                                                                                                                                                                                                                                                                                                                                       3/3

Installed:
  pcre2-devel.x86_64 0:10.23-11.amzn2.0.1

Dependency Installed:
  pcre2-utf16.x86_64 0:10.23-11.amzn2.0.1                                                                                                                                                                                                        pcre2-utf32.x86_64 0:10.23-11.amzn2.0.1

Complete!
[ec2-user@ip-172-26-15-209 ~]$ sudo rpm -Uvh https://download.opensuse.org/repositories/shells:/fish:/release:/3/CentOS_7/x86_64/fish-3.6.1-1.2.x86_64.rpm
Retrieving https://download.opensuse.org/repositories/shells:/fish:/release:/3/CentOS_7/x86_64/fish-3.6.1-1.2.x86_64.rpm
warning: /var/tmp/rpm-tmp.WSduVM: Header V3 RSA/SHA256 Signature, key ID d880c8e4: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:fish-3.6.1-1.2                   ################################# [100%]
[ec2-user@ip-172-26-15-209 ~]$ which fish
/usr/bin/fish

確認

無事入りました。

[ec2-user@ip-172-26-15-209 ~]$ /usr/bin/fish --version
fish, version 3.6.1

しかしながら、rpmのレポジトリを設定したわけではないので自動更新は行われません。

余談

tmuxも最新をインストールしてターミナル関連のバージョンを一新しました。

ついでに、tmuxとfishでpowerlineテーマを使って統一感を出しました。

Alt text

最新の設定ファイルは以下においてあります。
https://github.com/matsubo/matsu-shell-setting

Discussion