macOS Catalina 10.15.5 Rails 6.0.3
I'll write a Rails tutorial and a lot of it. The tutorial is compliant with the 6th edition because I want to get used to Github.
Modify the Gemfile according to Listing 3.2.
Taking advantage of the previous reflection, I changed gem'puma' from '4.3.4' to '4.3.6'.
Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'rails',      '6.0.3'
gem 'puma',       '4.3.6'
gem 'sass-rails', '5.1.0'
gem 'webpacker',  '4.0.7'
gem 'turbolinks', '5.2.0'
gem 'jbuilder',   '2.9.1'
gem 'bootsnap',   '1.4.5', require: false
group :development, :test do
  gem 'sqlite3', '1.4.1'
  gem 'byebug',  '11.0.1', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
  gem 'web-console',           '4.0.1'
  gem 'listen',                '3.1.5'
  gem 'spring',                '2.1.0'
  gem 'spring-watcher-listen', '2.0.1'
end
group :test do
  gem 'capybara',                 '3.28.0'
  gem 'selenium-webdriver',       '3.142.4'
  gem 'webdrivers',               '4.1.2'
  gem 'rails-controller-testing', '1.0.4'
  gem 'minitest',                 '5.11.3'
  gem 'minitest-reporters',       '1.3.8'
  gem 'guard',                    '2.16.2'
  gem 'guard-minitest',           '2.4.6'
end
group :production do
  gem 'pg', '1.1.4'
end
I did $ bundle update, but I got the following error.
An error occurred while installing pg (1.1.4), and Bundler cannot
continue.
Isn't it a problem that pg_config is missing because the error had the following contents? I thought.
(I referred to here. → https://elastictechdays.info/rails-postgresql-bundle-install-error/)
current directory:
/Users/user/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pg-1.1.4/ext
/Users/user/.rbenv/versions/2.7.0/bin/ruby -I
/Users/user/.rbenv/versions/2.7.0/lib/ruby/2.7.0 -r
./siteconf20201103-5783-kv6db3.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
Where is the pg_config? I searched variously,
It seems best to create postgresql with $ brew install postgresql.
(I referred to here. → https://qiita.com/youcune/items/5b783f7fde45d0fd4b35)
I ran $ brew install postgresql and tried $ bundle update again, but I still got the same error.
When I checked the reference site earlier, I changed the path to refer to when building postgresql, so
I checked the contents of $ brew install postgresql
As shown below, /usr/local/Cellar/postgresql/13.0 was installed.
==> Installing postgresql
==> Pouring postgresql-13.0.catalina.bottle.tar.gz
==> /usr/local/Cellar/postgresql/13.0/bin/initdb --locale=C -E UTF-8 /usr/local/
So I ran $ bundle config build.pg as below and changed the path.
$ bundle config build.pg --with-pg-config=/usr/local/Cellar/postgresql/13.0/bin/pg_config
You are replacing the current global value of build.pg, which is currently "--with-pg-config=/usr/pgsql-9.3/bin/pg_config"
The $ bundle install has passed successfully.
Recommended Posts