1
0

More than 3 years have passed since last update.

DockerでRailsの開発環境を構築したあとにPryを導入する方法

Posted at

環境

macOS 10.15.5
Rails 5.2.4.2
Docker 19.03.12

はじめに

DockerでRailsの開発環境を構築したあとにConsoleを使用しようとする下記のようにIRBが表示されます。

irb(main):001:0>

しかしRailsの開発の役に立つPryをDockerでRailsの開発環境を構築したあとに導入するにはどうしたらいいのかその方法をご紹介します。

Gemfileを追加する

Gemfile
gem "pry-rails"
gem "pry-byebug"
terminal
$ bundle install

そしてConsoleを実行してみます。

terminal
$ rails console

しかしエラーになってしまいエラー文の末尾に下記のようなメッセージが表示されてしまいました。

terminal
`autodetect': Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

"JavaScript runtimeが見つかりません"というエラーのようです。なのでnode.jsのインストールを試みました。
node.jsをhomebrewを使ってインストールします。

terminal
$ brew install nodejs

そしてConcoleを実行します。

$ rails console
[1] pry(main)>

無事にPryの導入と実行に成功することができました!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0