Tinker Board S R2.0 にRuby 3.2を入れるまでのメモ

## apt-get update

```
$ sudo apt-get update
Get:1 http://ftp.jp.debian.org/debian buster InRelease [122 kB]
Get:2 http://ftp.jp.debian.org/debian buster-updates InRelease [56.6 kB]
Get:3 http://ftp.jp.debian.org/debian buster-backports InRelease [51.4 kB]
Get:4 http://security.debian.org buster/updates InRelease [34.8 kB]
Get:5 http://security.debian.org buster/updates/main armhf Packages [565 kB]
Get:6 http://security.debian.org buster/updates/main Translation-en [309 kB]
Get:7 http://security.debian.org buster/updates/non-free armhf Packages [9940 B]
Get:8 http://security.debian.org buster/updates/non-free Translation-en [24.8 kB]
Reading package lists... Done                                    
N: Repository 'http://ftp.jp.debian.org/debian buster InRelease' changed its 'Suite' value from 'oldstable' to 'oldoldstable'
N: Repository 'http://ftp.jp.debian.org/debian buster-updates InRelease' changed its 'Suite' value from 'oldstable-updates' to 'oldoldstable-updates'
E: Release file for http://ftp.jp.debian.org/debian/dists/buster-backports/InRelease is expired (invalid since 5d 11h 19min 27s). Updates for this repository will not be applied.
N: Repository 'http://security.debian.org buster/updates InRelease' changed its 'Suite' value from 'oldstable' to 'oldoldstable'
```

Debian 10だからか、変なエラーになった。
https://qiita.com/forte-evolution/items/fcf7de702856712d7cea を参考に `--allow-releaseinfo-change` をつけて再実行。

```
$ sudo apt-get update --allow-releaseinfo-change
Hit:1 http://ftp.jp.debian.org/debian buster InRelease
Hit:2 http://ftp.jp.debian.org/debian buster-updates InRelease
Get:3 http://ftp.jp.debian.org/debian buster-backports InRelease [51.4 kB]
Hit:4 http://security.debian.org buster/updates InRelease 
Reading package lists... Done                             
E: Release file for http://ftp.jp.debian.org/debian/dists/buster-backports/InRelease is expired (invalid since 4d 23h 20min 1s). Updates for this repository will not be applied.
```

https://unix.stackexchange.com/questions/2544/how-to-work-around-release-file-expired-problem-on-a-local-mirror
を参考に、 `-o Acquire::Check-Valid-Until=false` オプションも付ける。

```
$ sudo apt-get -o Acquire::Check-Valid-Until=false update --allow-releaseinfo-change
Hit:1 http://security.debian.org buster/updates InRelease
Hit:2 http://ftp.jp.debian.org/debian buster InRelease
Hit:3 http://ftp.jp.debian.org/debian buster-updates InRelease
Get:4 http://ftp.jp.debian.org/debian buster-backports InRelease [51.4 kB]
Get:5 http://ftp.jp.debian.org/debian buster-backports/main armhf Packages.diff/Index [27.8 kB]
Get:6 http://ftp.jp.debian.org/debian buster-backports/main armhf Packages 2023-08-30-1418.39.pdiff [756 B]
Get:7 http://ftp.jp.debian.org/debian buster-backports/main armhf Packages 2023-10-02-2009.11.pdiff [858 B]
Get:8 http://ftp.jp.debian.org/debian buster-backports/main armhf Packages 2023-11-02-0803.41.pdiff [818 B]
Get:8 http://ftp.jp.debian.org/debian buster-backports/main armhf Packages 2023-11-02-0803.41.pdiff [818 B]
Fetched 81.6 kB in 3s (32.6 kB/s)
Reading package lists... Done
```

完了！

## rbenvを入れる

apt-getで入るrbenvは古いので、gitで直接入れる。

```
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
Cloning into '/home/linaro/.rbenv'...
remote: Enumerating objects: 3253, done.
remote: Counting objects: 100% (403/403), done.
remote: Compressing objects: 100% (203/203), done.
remote: Total 3253 (delta 226), reused 318 (delta 188), pack-reused 2850
Receiving objects: 100% (3253/3253), 658.42 KiB | 5.06 MiB/s, done.
Resolving deltas: 100% (2016/2016), done.
```

.profileにevalスクリプトを挿入。

```
$ echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.profile
```

```
$ rbenv install -l
rbenv: no such command `install'
```

おっと...

```
$ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
Cloning into '/home/linaro/.rbenv/plugins/ruby-build'...
remote: Enumerating objects: 15754, done.
remote: Counting objects: 100% (15754/15754), done.
remote: Compressing objects: 100% (3798/3798), done.
remote: Total 15754 (delta 11272), reused 15524 (delta 11118), pack-reused 0
Receiving objects: 100% (15754/15754), 3.04 MiB | 9.43 MiB/s, done.
Resolving deltas: 100% (11272/11272), done.
```

```
$ rbenv install -l
3.0.6
3.1.4
3.2.2
jruby-9.4.5.0
mruby-3.2.0
picoruby-3.0.0
truffleruby-23.1.1
truffleruby+graalvm-23.1.1

Only latest stable releases for each Ruby implementation are shown.
Use `rbenv install --list-all' to show all local versions.
```

これでOK！

## Ruby 3.2.2を入れる

```
$ rbenv install 3.2.2
==> Downloading ruby-3.2.2.tar.gz...
-> curl -q -fL -o ruby-3.2.2.tar.gz https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
error: failed to download ruby-3.2.2.tar.gz

BUILD FAILED (Debian 10 on armv7l using ruby-build 20231114-14-gd12f6e5)
```

https://qiita.com/kutunesirka/items/e4f894f870ee8b17cc82
を参考に、 `-k` オプションを付けてみる。

```
$ RUBY_BUILD_CURL_OPTS="-k" rbenv install 3.2.2
==> Downloading ruby-3.2.2.tar.gz...
-> curl -q -fL -k -o ruby-3.2.2.tar.gz https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.5M  100 19.5M    0     0  40.4M      0 --:--:-- --:--:-- --:--:-- 40.4M
==> Installing ruby-3.2.2...
-> ./configure "--prefix=$HOME/.rbenv/versions/3.2.2" --enable-shared --with-ext=openssl,psych,+
-> make -j 4
*** Following extensions are not compiled:
psych:
	Could not be configured. It will not be installed.
	Check /tmp/ruby-build.20231125134115.4527.BTbRyu/ruby-3.2.2/ext/psych/mkmf.log for more details.
readline:
	Could not be configured. It will not be installed.
	/tmp/ruby-build.20231125134115.4527.BTbRyu/ruby-3.2.2/ext/readline/extconf.rb:62: Neither readline nor libedit was found
	Check /tmp/ruby-build.20231125134115.4527.BTbRyu/ruby-3.2.2/ext/readline/mkmf.log for more details.

BUILD FAILED (Debian 10 on armv7l using ruby-build 20231114-14-gd12f6e5)

You can inspect the build directory at /tmp/ruby-build.20231125134115.4527.BTbRyu
See the full build log at /tmp/ruby-build.20231125134115.4527.log

```


mkmf.logみると

```
-Wunused-variable -Wundef  -fPIC   -c conftest.c"
conftest.c:3:10: fatal error: yaml.h: No such file or directory
 #include <yaml.h>
          ^~~~~~~~
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <yaml.h>
/* end */

--------------------
```

```
conftest.c:3:10: fatal error: editline/readline.h: No such file or directory
 #include <editline/readline.h>
          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <editline/readline.h>
/* end */

--------------------

/tmp/ruby-build.20231125134115.4527.BTbRyu/ruby-3.2.2/ext/readline/extconf.rb:62: Neither readline nor libedit was found
	/tmp/ruby-build.20231125134115.4527.BTbRyu/ruby-3.2.2/ext/readline/extconf.rb:62:in `<top (required)>'
	./ext/extmk.rb:223:in `load'
	./ext/extmk.rb:223:in `block in extmake'
	/tmp/ruby-build.20231125134115.4527.BTbRyu/ruby-3.2.2/lib/mkmf.rb:324:in `open'
	./ext/extmk.rb:219:in `extmake'
	./ext/extmk.rb:638:in `block in <main>'
	./ext/extmk.rb:634:in `each'
	./ext/extmk.rb:634:in `<main>'
```

こんなエラーになってた。


yaml.hについては https://ikm.hatenablog.jp/entry/2023/01/06/203425 あたりを参考に、editline/readline.hについては https://stackoverflow.com/questions/43703874/fatal-error-editline-readline-h-no-such-file-or-directory-compilation-terminat を参考に、

```
sudo apt-get install libyaml-dev libeditline-dev 
```

そして再度トライ...

```
$ RUBY_BUILD_CURL_OPTS="-k" rbenv install 3.2.2
==> Downloading ruby-3.2.2.tar.gz...
-> curl -q -fL -k -o ruby-3.2.2.tar.gz https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.5M  100 19.5M    0     0  29.5M      0 --:--:-- --:--:-- --:--:-- 29.5M
==> Installing ruby-3.2.2...
-> ./configure "--prefix=$HOME/.rbenv/versions/3.2.2" --enable-shared --with-ext=openssl,psych,+
-> make -j 4
-> make install
==> Installed ruby-3.2.2 to /home/linaro/.rbenv/versions/3.2.2
```