rails new app_name -d postgresqlでエラー
rails new app_name -d postgresqlでデータベースをSQLite3ではなく、PostgreSQLに指定して新しいアプリを立ち上げようとした際にエラーが発生しました。
開発環境
Ruby: 2.6.3
Rails: 5.2.4.1
・Rails newした際にエラー
Terminal
An error occurred while installing pg (1.2.2), and Bundler cannot continue. Make sure that `gem install pg -v '1.2.2' --source 'https://rubygems.org/'` succeeds before bundling.
・解決方法
単にPostgreSQLが未インストールだっただけでした。
Terminal
$ gem install pg -v '1.2.2' --source 'https://rubygems.org/'
を実行し、PostgreSQLをインストール。
Terminal
$ gem install pg -v '1.2.2' --source 'https://rubygems.org/' Building native extensions. This could take a while... Successfully installed pg-1.2.2 1 gem installed
その後、bundle installを実行。
Terminal
~ Bundle complete! 18 Gemfile dependencies, 78 gems now installed. Use `bundle info [gemname]` to see where a bundled gem is installed.
無事にgemをインストールすることができました。