
mastodonのインストール、アップデート時に発生するワーニングの解消方法です。
【使用環境】
Ubuntu 18.04.2 LTS (AWS)
docker使用
Mastodon 2.7.4
とあるマストドンのサーバーを運営、管理しています。
mastodonは頻繁にバージョンアップが行われるのですが、そのセットアップのたびに表示されるワーニングをいつも無視していました。
今回思い立って、いくつか解決できたので公開します。
同じサーバー管理者のお役に立てれば幸いです。
Webpacker is installed ? ?
インストール中に「Webpacker is installed ? ?」と表示される。
これは「Webpacker入ってますか??」と言う意味ではなく、
「Webpacker is installed 🎉 🍰」がターミナル上で文字化けしたもの。
「Webpacker、入ってますよ」と言う意味です。
(履いてますよ、でもない・・)
Webpackerめっちゃ時間かかる
Compiling…
Compiled all packs in /mastodon/public/packs
メモリ不足みたいです。
When i run RAILS_ENV=production bundle exec rails assets:precompile -- trace I get this error ** Invoke assets:precompile (first_time) ** Invoke assets:environment (first_time) ** Execute assets:en...
現在のメモリ使用状況を確認します。
total used free shared buff/cache available
Mem: 1007528 274708 232640 12256 500180 564216
Swapファイルが確保されていませんでした。
2GBのスワップファイルを作成します。
$ sudo dd if=/dev/zero of=/var/swap/swap0 bs=1M count=2048
$ sudo chmod 600 /var/swap/swap0
$ sudo mkswap /var/swap/swap0
$ sudo swapon /var/swap/swap0
しかし、このままだとOSの再起動でクリアされてしまいます。
(これを忘れて、いつもメモリが足りなくなってた…)
恒久化したいのなら、
/etc/fstabに
の1行を追加します。
確認します。
Filename Type Size Used Priority
/var/swap/swap0 file 2097148 256 -1
あああ。
ただでさえバージョンアップに時間がかかるのに
他のことやっていて、うっかり
「実行中のTeratermの画面上でCtrl+Cを押してしまう」
あるあるです。
config.i18n.fallbacks
HEADS UP!(起きろ!)と言われてしまう。
次のメッセージが表示されるのを解消します。
But that may break your application.
Please check your Rails app for ‘config.i18n.fallbacks = true’.
If you’re using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
‘config.i18n.fallbacks = [I18n.default_locale]’.
If not, fallbacks will be broken in your app by I18n 1.1.x.
For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
Internationalization (i18n) library for Ruby. Contribute to ruby-i18n/i18n development by creating an account on GitHub.
を見てみましたが、たいしたことは書かれていません。
検索してみたところ、
http://railsdoc.com/config
にこのような記述がありました。
国際化対応のためのデフォルトのロケール。デフォルトは「:en」
使い方
i18n.default_locale = 国コード
例
i18n.default_locale = :ja
いや「trueだぞ!」と言われて怒られたんですから、いっそ「false」を指定してしまいましょう。
【対策】
/mastodon/config/environments/production.rb
のこの部分を修正します。
# English when a translation cannot be found).
config.i18n.fallbacks = [:en]
config.i18n.fallbacks = [:en]
を
config.i18n.fallbacks = false
に。
railsの再起動が必要です。
$ sudo docker restart
を実行します。
AES-*-GCM algorithms
【事象】
Encryptor v2.0.0で次のメッセージが表示される。
By default You will not be able to decrypt data that was previously encrypted using an AES-*-GCM algorithm.
Please see the README and https://github.com/attr-encrypted/encryptor/pull/22 for more information.
Post-install message from attr_encrypted:
【原因】
AES-*-GCMを使った場合、バグがあるようです。
しかし海外サイトを調べてみても、議論はされていましたが、特に現時点では解決する必要はなさそうです。
【対策】
ありません。
attr_encrypted v2.0.0.
次のワーニングが表示される。
Additionally, there was a bug in Encryptor v2.0.0 that insecurely encrypted data when using an AES-*-GCM algorithm.
This bug was fixed but introduced breaking changes between v2.x and v3.x.
Please see the README for more information regarding upgrading to attr_encrypted v3.0.0.
【原因】
上と同じ「AES-*-GCM algorithms」の問題のようですが。
「attr_encrypted v2.0.0」が古いため、セキュリティに問題があるようです。
ワーニングの中でも「attr_encrypted v3.0.0」にアップデートするように言っています。
【解決方法】
attr_encrypted v2.0.0.をattr_encrypted v3.0.0.にアップデートします。
コマンド:
実行結果:
Please be aware that Encryptor v2.0.0 had a major security bug when using AES-*-GCM algorithms.
By default You will not be able to decrypt data that was previously encrypted using an AES-*-GCM algorithm.
Please see the README and https://github.com/attr-encrypted/encryptor/pull/22 for more information.
Successfully installed encryptor-3.0.0
Fetching: attr_encrypted-3.1.0.gem (100%)
WARNING: Several insecure default options and features were deprecated in attr_encrypted v2.0.0.
Additionally, there was a bug in Encryptor v2.0.0 that insecurely encrypted data when using an AES-*-GCM algorithm.
This bug was fixed but introduced breaking changes between v2.x and v3.x.
Please see the README for more information regarding upgrading to attr_encrypted v3.0.0.
Successfully installed attr_encrypted-3.1.0
Parsing documentation for encryptor-3.0.0
Installing ri documentation for encryptor-3.0.0
Parsing documentation for attr_encrypted-3.1.0
Installing ri documentation for attr_encrypted-3.1.0
Done installing documentation for encryptor, attr_encrypted after 6 seconds
2 gems installed
ここでまた、WARNINGが発生していますが、解消してるはず?????
Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Bundlerのバージョンがロックファイルより古いと言っています。
これを解消しようとして、もう大変なことに。
rubyとrailsのバージョンアップ
bundlerのバージョンアップ
をご参照。(未完)
yarnのバージョンが古過ぎる
【事象】
yarn自体のバージョンが古過ぎる。
1.13.0
【対策】
yarnのアップデートを行う。
npm install yarn -g
/home/ubuntu/.nvm/versions/node/v10.15.3/bin/yarn -> /home/ubuntu/.nvm/versions/node/v10.15.3/lib/node_modules/yarn/bin/yarn.js
/home/ubuntu/.nvm/versions/node/v10.15.3/bin/yarnpkg -> /home/ubuntu/.nvm/versions/node/v10.15.3/lib/node_modules/yarn/bin/yarn.js
+ yarn@1.13.0
updated 1 package in 13.755s
$ yarn –version
1.13.0
変わらない。
npm upgrade yarn -g
$ yarn –version
1.13.0
変わらない。
$ yarn policies set-version nightly
Resolving nightly to a url…
Downloading https://nightly.yarnpkg.com/latest.js…
Saving it into /home/ubuntu/mastodon/.yarn/releases/yarn-nightly.js…
Updating /home/ubuntu/mastodon/.yarnrc…
Done!
$ yarn –version
1.16.0-20190324.1147
最新バージョンになった。
ca-certificatesの警告
【現象】
以下の警告が表示される。
【原因】
/etc/ssl/certs/ca-certificates.crt
の中に複数の証明書が存在するため。
【対策】
過去に各所で議論されていましたが、
「警告は警告であって、無視すればよい」らしいです。。
sudoユーザではrubyのパスが引き継がれない
rbenvのバージョンは上げられたのに
system
2.6.1
* 2.6.2 (set by /home/ubuntu/mastodon/.ruby-version)
rubyのバージョンがどうしても上がらない。
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
この場合、どのrubyが動いているのか確認する。
/usr/bin/ruby
デフォルトのrubyが動いてしまっている。
パスを確認してみる。
/home/ubuntu/.rbenv/shims:~/.rbenv/shims:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
正しい。
(実は変えた。ここまでにも紆余曲折あった)
export PATH=”~/.rbenv/bin:~/.rbenv/shims:$PATH”
eval “$(rbenv init -)”
などしたりして。
でもなぜか反映されない。
【結論】
/etc/sudoersというファイルに以下の(強制的?)設定がされているため。
このようにコメントアウト、修正する。
Defaults env_keep += “PATH”
こうすると
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux]
$ sudo which ruby
/home/ubuntu/.rbenv/shims/ruby
やっと直った。
bundlerのバージョンが古いと言われる
Warning: the running version of Bundler (1.17.2) is older than (1.17.3)
などと言われる。
Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
gem install bundlerしても変わらない。
もうGemfile.lockの以下の行を変更して逃げる。
1.17.3
↓
BUNDLED WITH
1.17.2
ワーニングはもちろん出なくなる。
(逃げてばかりでいいのか?この人生)
CLI interfaceの警告
【現象】
以下の警告が表示される。
「警告:aptは安定したCLIインタフェースを持っていません。スクリプト内では注意して使用してください」
【原因】
「apt」ではシェルスクリプト「&&(AND制御演算子)」が推奨されていないため。
【対策】
①警告を無視するか、②「apt-get」を使用する。
②の場合、./Dockerfileの中で以下に該当する全ての文を書き替える
apt -y dist-upgrade &&
apt -y install wget make gcc g++ python &&
↓
apt-get update &&
apt-get -y dist-upgrade &&
apt-get -y install wget make gcc g++ python &&
※ちなみに「APT」とは「Advanced Package Tool」の略。
フロントエンドツールとして「apt」と「apt-get」があるが機能の違いはない。
現在は「apt」が主流であり、「apt-get」から移行しつつある。
同じくフロントエンドとして「aptitude」があったが、今では使用されなくなった。
this statement may fall throughの警告
【現象】
*status = U_RESOURCE_TYPE_MISMATCH;
note: here
default:
と表示される。
【原因】
C++の「switch-case」文による意図しないフォールスルーによりバグが発生することを防止するため、コンパイル時にフォールスルーを検出し警告を出力している。
【対策】
意図された警告のため、解消はできません。
よって無視。
延々と、真っ赤な画面が表示されて、嫌になりますけど。
Failed to connect to ~ meta-release-lts. というエラーが発生する
【事象】
Ubuntuの起動時に以下のエラーが表示される。
【原因】
Anyone else getting this message on Ubuntu Server 18.04 LTS when you login (part of motd message)? Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings It comes from this motd file: /etc/update-motd.d/91-release-upgrade Which calls this file: /usr/lib/ubuntu-release-upgrader/release-upgrade-motd
以下のキャッシュファイルに該当のメッセージが作られている。
【対策】
このファイルを消す。
(再起動すると再作成される)
めっちゃ遅い
【事象】
アップデートに時間がかかり過ぎる。
【原因】
ネットワーク接続に問題がある。
【対策】その1
ダウンロード先を海外から国内のミラーサイトに変える。
理化学研究所(riken.go.jp)
北陸先端科学技術大学院大学(jaist.ac.jp)など
/etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu/ bionic main restricted
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb http://archive.ubuntu.com/ubuntu/ bionic universe
deb http://archive.ubuntu.com/ubuntu/ bionic-updates universe
deb http://archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
を書き替える。
deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ bionic-updates main restricted
deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ bionic universe
deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ bionic-updates universe
deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ bionic multiverse
deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ bionic-updates multiverse
deb http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
【対策】その2
パブリックDNSを使用する。
「Google Public DNS」や「Cloudflare」などのDNSを使用する。
インターネットに接続していて、遅いなあと感じることってたびたびありますよね。たいていの場合、契約している回線が遅かったり、みんなが接続している時間...
Check your Internet connection or proxy settingsが表示される
【事象】
Ubuntuの起動時に以下のメッセージが表示される。
Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
【原因】
以下のファイルにメッセージが記録されている。
/var/lib/ubuntu-release-upgrader/release-upgrade-available
ネットワークの接続は問題なくできている。
どうやらキャッシュが残っているらしい。
【対策】
上記のファイルを削除する。