Ubuntu22.04からOpenSSLが3.0になった。 OpenSSL3.0には後方互換があるようだが、いくつかのライブラリではうまく動かない場合がある。 例えば、Rubyのnet-sshである。 wordmoveを実行するとデータベースの移行のところで、ERROR: OpenSSL::PKey::PKeyError: rsa#set_key= is incompatible with OpenSSL 3.0
というエラーが出てしまう。net-sshのバージョンを上げる方法を試みたがubuntu22.04の標準的なインストール方法でRubyをインストールしているため失敗した。土台のRubyをubuntu標準のインストールから脱却し、違う方法でインストールし、OpenSSLとnet-sshが上手く動く環境を構築しないとwordmoveのエラーは解消できないと思われる。以下の環境であれば問題なさそうであるが、asdfを入れてやってみる。
環境1:Ruby、OpenSSL、net-sshのすべてを最新版にした環境
環境2:OpenSSL1.1をベースにしてRubyとnet-sshは依存関係が成り立つ環境
asdfを公式サイトに沿ってインストールする。
Install Dependencies
hbirds@hbirds-Lenovo-G580:~$ sudo apt install curl git
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
curl is already the newest version (7.81.0-1ubuntu1.7).
git is already the newest version (1:2.34.1-1ubuntu1.6).
git set to manually installed.
Download asdf
hbirds@hbirds-Lenovo-G580:~$ git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.1
Cloning into '/home/hbirds/.asdf'...
remote: Enumerating objects: 7951, done.
remote: Counting objects: 100% (441/441), done.
remote: Compressing objects: 100% (243/243), done.
remote: Total 7951 (delta 265), reused 302 (delta 192), pack-reused 7510
Receiving objects: 100% (7951/7951), 2.16 MiB | 6.29 MiB/s, done.
Resolving deltas: 100% (4663/4663), done.
Note: switching to '27c8a101e5fef2b8de29053cbe56f75fc06a3aca'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
Install asdf
hbirds@hbirds-Lenovo-G580:~$ . $HOME/.asdf/asdf.sh
hbirds@hbirds-Lenovo-G580:~$ . $HOME/.asdf/completions/asdf.bash
$ echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.bashrc
$ echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc
確認
hbirds@hbirds-Lenovo-G580:~$ asdf version
v0.11.1-27c8a10
Install a Plugin
Plugin Dependencies
hbirds@hbirds-Lenovo-G580:~$ sudo apt-get install dirmngr gpg curl gawk
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
curl is already the newest version (7.81.0-1ubuntu1.7).
dirmngr is already the newest version (2.2.27-3ubuntu2.1).
dirmngr set to manually installed.
gpg is already the newest version (2.2.27-3ubuntu2.1).
gpg set to manually installed.
The following packages were automatically installed and are no longer required:
libevent-pthreads-2.1-7 libhtml-template-perl libmecab2 mecab-ipadic
mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-common mysql-server-8.0
mysql-server-core-8.0
Use 'sudo apt autoremove' to remove them.
Suggested packages:
gawk-doc
The following NEW packages will be installed:
gawk
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.
Need to get 447 kB of archives.
After this operation, 1,720 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://jp.archive.ubuntu.com/ubuntu jammy/main amd64 gawk amd64 1:5.1.0-1build3 [447 kB]
Fetched 447 kB in 3s (174 kB/s)
Selecting previously unselected package gawk.
(Reading database ... 268376 files and directories currently installed.)
Preparing to unpack .../gawk_1%3a5.1.0-1build3_amd64.deb ...
Unpacking gawk (1:5.1.0-1build3) ...
Setting up gawk (1:5.1.0-1build3) ...
Processing triggers for man-db (2.10.2-1) ...
Install Plugin
hbirds@hbirds-Lenovo-G580:~$ asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
Install a Version
birds@hbirds-Lenovo-G580:~$ asdf install nodejs latest
Trying to update node-build... ok
Downloading node-v19.5.0-linux-x64.tar.gz...
-> https://nodejs.org/dist/v19.5.0/node-v19.5.0-linux-x64.tar.gz
Installing node-v19.5.0-linux-x64...
Installed node-v19.5.0-linux-x64 to /home/hbirds/.asdf/installs/nodejs/19.5.0
Set a Version
Global
hbirds@hbirds-Lenovo-G580:~$ asdf global nodejs latest
Local
hbirds@hbirds-Lenovo-G580:~$ asdf local nodejs latest
確認
hbirds@hbirds-Lenovo-G580:~$ cat $HOME/.tool-versions
nodejs 19.5.0
ruby install
hbirds@hbirds-Lenovo-G580:~$ asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
asdf でRuby をインストールする前にubuntu標準で入れた Ruby をpurge しておく。
hbirds@hbirds-Lenovo-G580:~$ sudo apt purge ruby
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
fonts-lato javascript-common libevent-pthreads-2.1-7 libgmp-dev
libgmpxx4ldbl libhtml-template-perl libjs-jquery libmecab2 mecab-ipadic
mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-common mysql-server-8.0
mysql-server-core-8.0 ruby-net-telnet ruby-webrick ruby-xmlrpc ruby3.0-doc
rubygems-integration
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
libruby3.0* rake* ri* ruby* ruby-dev* ruby-full* ruby-rubygems* ruby3.0*
ruby3.0-dev*
0 upgraded, 0 newly installed, 9 to remove and 9 not upgraded.
After this operation, 26.7 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 268532 files and directories currently installed.)
Removing ruby-full (1:3.0~exp1) ...
Removing ruby-dev:amd64 (1:3.0~exp1) ...
Removing ruby3.0-dev:amd64 (3.0.2-7ubuntu2.3) ...
Removing ri (1:3.0~exp1) ...
Removing ruby (1:3.0~exp1) ...
Removing ruby3.0 (3.0.2-7ubuntu2.3) ...
dpkg: warning: while removing ruby3.0, directory '/var/lib/gems/3.0.0' not empty
so not removed
Removing libruby3.0:amd64 (3.0.2-7ubuntu2.3) ...
Removing ruby-rubygems (3.3.5-2) ...
Removing rake (13.0.6-2) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
birds@hbirds-Lenovo-G580:~$ sudo apt autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be REMOVED:
fonts-lato javascript-common libevent-pthreads-2.1-7 libgmp-dev
libgmpxx4ldbl libhtml-template-perl libjs-jquery libmecab2 mecab-ipadic
mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-common mysql-server-8.0
mysql-server-core-8.0 ruby-net-telnet ruby-webrick ruby-xmlrpc ruby3.0-doc
rubygems-integration
0 upgraded, 0 newly installed, 20 to remove and 9 not upgraded.
After this operation, 210 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 265437 files and directories currently installed.)
Removing fonts-lato (2.0-2.1) ...
dpkg: warning: while removing fonts-lato, directory '/usr/share/fonts/truetype/l
ato' not empty so not removed
Removing javascript-common (11+nmu1) ...
Removing mysql-server-8.0 (8.0.32-0buntu0.22.04.1) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.c
nf (my.cnf) in auto mode
Removing mysql-server-core-8.0 (8.0.32-0buntu0.22.04.1) ...
Removing libevent-pthreads-2.1-7:amd64 (2.1.12-stable-1build3) ...
Removing libgmp-dev:amd64 (2:6.2.1+dfsg-3ubuntu1) ...
Removing libgmpxx4ldbl:amd64 (2:6.2.1+dfsg-3ubuntu1) ...
Removing libhtml-template-perl (2.97-1.1) ...
Removing libjs-jquery (3.6.0+dfsg+~3.5.13-1) ...
Removing mecab-ipadic-utf8 (2.7.0-20070801+main-3) ...
update-alternatives: using /var/lib/mecab/dic/ipadic to provide /var/lib/mecab/d
ic/debian (mecab-dictionary) in auto mode
Removing mecab-ipadic (2.7.0-20070801+main-3) ...
Removing mecab-utils (0.996-14build9) ...
Removing libmecab2:amd64 (0.996-14build9) ...
Removing mysql-client-8.0 (8.0.32-0buntu0.22.04.1) ...
Removing mysql-common (5.8+1.0.8) ...
Removing ruby-net-telnet (0.1.1-2) ...
Removing ruby-xmlrpc (0.3.2-1ubuntu0.1) ...
Removing ruby-webrick (1.7.0-3) ...
Removing ruby3.0-doc (3.0.2-7ubuntu2.3) ...
Removing rubygems-integration (1.18) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for fontconfig (2.13.1-4.2ubuntu5) ...
hbirds@hbirds-Lenovo-G580:~$ asdf install ruby latest
To follow progress, use 'tail -f /tmp/ruby-build.20230126140906.7494.log' or pass --verbose
No system openssl version was found, ensure openssl headers are installed (https://github.com/rbenv/ruby-build/wiki#suggested-build-environment)
Downloading openssl-3.0.7.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/83049d042a260e696f62406ac5c08bf706fd84383f945cf21bd61e9ed95c396e
Installing openssl-3.0.7...
Installed openssl-3.0.7 to /home/hbirds/.asdf/installs/ruby/3.2.0
Downloading ruby-3.2.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.0.tar.gz
Installing ruby-3.2.0...
BUILD FAILED (Ubuntu 22.04 using ruby-build 20230124)
Inspect or clean up the working tree at /tmp/ruby-build.20230126140906.7494.0lEiQf
Results logged to /tmp/ruby-build.20230126140906.7494.log
Last 10 log lines:
*** Fix the problems, then remove these directories and try again if you want.
make[1]: Leaving directory '/tmp/ruby-build.20230126140906.7494.0lEiQf/ruby-3.2.0'
Generating RDoc documentation
/tmp/ruby-build.20230126140906.7494.0lEiQf/ruby-3.2.0/lib/yaml.rb:3: warning: It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
uh-oh! RDoc had a problem:
cannot load such file -- psych
run with --debug for full backtrace
make: *** [uncommon.mk:598: rdoc] Error 1
libyaml-dev をInstall
hbirds@hbirds-Lenovo-G580:~$ sudo apt install libyaml-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
libyaml-doc
The following NEW packages will be installed:
libyaml-dev
0 upgraded, 1 newly installed, 0 to remove and 9 not upgraded.
Need to get 62.8 kB of archives.
After this operation, 257 kB of additional disk space will be used.
Get:1 http://jp.archive.ubuntu.com/ubuntu jammy/main amd64 libyaml-dev amd64 0.2.2-1build2 [62.8 kB]
Fetched 62.8 kB in 2s (30.7 kB/s)
Selecting previously unselected package libyaml-dev:amd64.
(Reading database ... 251891 files and directories currently installed.)
Preparing to unpack .../libyaml-dev_0.2.2-1build2_amd64.deb ...
Unpacking libyaml-dev:amd64 (0.2.2-1build2) ...
Setting up libyaml-dev:amd64 (0.2.2-1build2) ...
hbirds@hbirds-Lenovo-G580:~$
hbirds@hbirds-Lenovo-G580:~$ asdf install ruby latest
To follow progress, use 'tail -f /tmp/ruby-build.20230126142727.39377.log' or pass --verbose
No system openssl version was found, ensure openssl headers are installed (https://github.com/rbenv/ruby-build/wiki#suggested-build-environment)
Downloading openssl-3.0.7.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/83049d042a260e696f62406ac5c08bf706fd84383f945cf21bd61e9ed95c396e
Installing openssl-3.0.7...
Installed openssl-3.0.7 to /home/hbirds/.asdf/installs/ruby/3.2.0
Downloading ruby-3.2.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.0.tar.gz
Installing ruby-3.2.0...
BUILD FAILED (Ubuntu 22.04 using ruby-build 20230124)
Inspect or clean up the working tree at /tmp/ruby-build.20230126142727.39377.mpEITa
Results logged to /tmp/ruby-build.20230126142727.39377.log
Last 10 log lines:
The Ruby openssl extension was not compiled.
ERROR: Ruby install aborted due to missing extensions
Try running `apt-get install -y libssl-dev` to fetch missing dependencies.
Configure options used:
--prefix=/home/hbirds/.asdf/installs/ruby/3.2.0
--with-openssl-dir=/home/hbirds/.asdf/installs/ruby/3.2.0/openssl
--enable-shared
LDFLAGS=-L/home/hbirds/.asdf/installs/ruby/3.2.0/lib
CPPFLAGS=-I/home/hbirds/.asdf/installs/ruby/3.2.0/include
hbirds@hbirds-Lenovo-G580:~$ sudo apt-get install -y libssl-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
libssl-doc
The following NEW packages will be installed:
libssl-dev
0 upgraded, 1 newly installed, 0 to remove and 9 not upgraded.
Need to get 2,372 kB of archives.
After this operation, 12.4 MB of additional disk space will be used.
Get:1 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libssl-dev amd64 3.0.2-0ubuntu1.7 [2,372 kB]
Fetched 2,372 kB in 3s (846 kB/s)
Selecting previously unselected package libssl-dev:amd64.
(Reading database ... 251898 files and directories currently installed.)
Preparing to unpack .../libssl-dev_3.0.2-0ubuntu1.7_amd64.deb ...
Unpacking libssl-dev:amd64 (3.0.2-0ubuntu1.7) ...
Setting up libssl-dev:amd64 (3.0.2-0ubuntu1.7) ...
やっと成功した。
hbirds@hbirds-Lenovo-G580:~$ asdf install ruby latest
To follow progress, use 'tail -f /tmp/ruby-build.20230126143911.71318.log' or pass --verbose
Downloading ruby-3.2.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.0.tar.gz
Installing ruby-3.2.0...
Installed ruby-3.2.0 to /home/hbirds/.asdf/installs/ruby/3.2.0