suzukinpの忘備録

AWS/Linux/グルメ

AWSフルコース04月度(3週目)③

Progateの、「Ruby on Rails5 学習コース II>データベースを使ってみよう>10. テーブルにデータを作成しよう」の箇所で、テーブルにデータを追加したところ、日本語を入力してもブランクになって入力されない。。

コマンドプロンプト文字コード(Shift-JIS)とsqlite3の文字コード(UTF-8)が合っていないせいかと思い、下記URLを参考にコマンドプロンプト文字コードUTF-8に変更してみる。

qiita.com

再試行したところ、日本語を入力したとたんコマンドプロンプトが落ちた。。
調べてみると、コマンドプロンプトから日本語は入力できないらしい。

qa.itmedia.co.jp

やはり、正式な?環境構築をしようと思い、「現場で使える Ruby on Rails 5速習実践ガイド」を参考にWSL(Ubuntu)&PostgreSQLに実行環境を変更する。

www.amazon.co.jp

進めていくと、今とバージョンが違うことによるエラーが頻発。。

【環境構築時のエラーその①】2-2-2 Windows(WSL)でrbenvをインストール

Ubuntuで下記コマンドを実行したところ、

sudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev

下記エラーが表示

E: Unable to locate package libgdbm3

調べてみると、libgdbm3が古いらしい。

Ubuntu パッケージ検索で調べる
packages.ubuntu.com

最新はlibgdbm6なので、下記実行したところ、既にインストールされていた。

suzukinp@[XXXXXXXX]:~$ sudo apt-get install libgdbm6
[sudo] password for suzukinp:
Reading package lists... Done
Building dependency tree
Reading state information... Done
libgdbm6 is already the newest version (1.18.1-5).
libgdbm6 set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

【環境構築時のエラーその②】2-4-1 Node.jpのインストール

Ubuntuで下記コマンドを実行したところ、

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

下記エラーが表示

================================================================================
================================================================================

                              DEPRECATION WARNING

  Node.js 8.x LTS Carbon is no longer actively supported!

  You will not receive security or critical stability updates for this version.

  You should migrate to a supported version of Node.js as soon as possible.
  Use the installation script that corresponds to the version of Node.js you
  wish to install. e.g.

   * https://deb.nodesource.com/setup_10.x — Node.js 10 LTS "Dubnium" (recommended)
   * https://deb.nodesource.com/setup_12.x — Node.js 12 LTS "Erbium"

  Please see https://github.com/nodejs/Release for details about which
  version may be appropriate for you.

  The NodeSource Node.js distributions repository contains
  information both about supported versions of Node.js and supported Linux
  distributions. To learn more about usage, see the repository:
    https://github.com/nodesource/distributions

================================================================================
================================================================================

Continuing in 20 seconds ...

sleep: cannot read realtime clock: Invalid argument

'## Installing the NodeSource Node.js 8.x LTS Carbon repo...


'## Populating apt-get cache...

+ apt-get update
Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done

'## Confirming "focal" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_8.x/dists/focal/Release'

'## Your distribution, identified as "focal", is not currently supported, please contact NodeSource at https://github.com/nodesource/distributions/issues if you think this is incorrect or would like your distribution to be considered for support

エラーの中の下記部分を見ると、バージョンが古い様なのでNode.jp 10で再試行

* https://deb.nodesource.com/setup_10.x — Node.js 10 LTS "Dubnium" (recommended)

下記コマンドを実行すると。。

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

新たなエラーが発生

'## Installing the NodeSource Node.js 10.x repo...


'## Populating apt-get cache...

+ apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done

'## Confirming "focal" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_10.x/dists/focal/Release'

'## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
gpg: can't connect to the agent: IPC connect call failed
Error executing command, exiting


curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -

gpg: can't connect to the agent: IPC connect call failed

下記URLを参考に記載のあったコマンドを実行(合っているかは不明) github.com

再試行すると。。

curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -  
OK

【環境構築時のエラーその③】2-5-2 データベースのインストールとセットアップ

下記コマンドを実行したところ、エラー

suzukinp@XXXXXXXX:~$ wget --quiet -0 - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
wget: invalid option -- '0'
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.
gpg: no valid OpenPGP data found.

下記URLを参考にコマンド実行すると、解消された

curl -O -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc  
sudo apt-key add ACCC4CF8.asc

yanor.net

これで環境構築は完了したと思うけど、バージョンが違うことによるエラーが結構あることを知った一日だった。。