[RUBY] Rails Tutorial Memorandum (Chapter 3, 3.1)

environment

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.

3.1 Setup

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

Rails Tutorial Memorandum (Chapter 3, 3.1)
Rails Tutorial Memorandum (Chapter 3, 3.3.2)
rails tutorial Chapter 6
rails tutorial Chapter 1
Rails tutorial memorandum 1
Rails tutorial memorandum 2
rails tutorial Chapter 7
rails tutorial Chapter 10
rails tutorial Chapter 9
rails tutorial Chapter 8
Rails Tutorial Chapter 5 Notes
Rails Tutorial Chapter 10 Notes
Rails Tutorial Chapter 3 Notes
Rails Tutorial Chapter 3 Learning
Rails Tutorial Chapter 4 Notes
Rails Tutorial Chapter 4 Learning
Rails Tutorial Chapter 1 Learning
Rails Tutorial Chapter 2 Learning
Rails Tutorial Chapter 8 Notes
rails tutorial
Rails Tutorial Records and Memorandum # 0
Rails memorandum
rails tutorial
rails tutorial
rails tutorial
[Rails Tutorial Chapter 4] Rails-flavored Ruby
[Rails tutorial] A memorandum of "Chapter 11 Account Activation"
rails tutorial
rails tutorial
rails tutorial
[Rails Struggle/Rails Tutorial] Summary of Rails Tutorial Chapter 2
[Rails Tutorial Chapter 5] Create a layout
rails tutorial chapter 10 summary (for self-learning)
Chewing Rails Tutorial [Chapter 2 Toy Application]
Rails Tutorial (4th Edition) Memo Chapter 6
Rails tutorial test
Start Rails Tutorial
[Beginner] Rails Tutorial
Rails Tutorial 6th Edition Learning Summary Chapter 7
Rails Tutorial 6th Edition Learning Summary Chapter 9
Rails Tutorial 6th Edition Learning Summary Chapter 2
Rails Tutorial Chapter 0: Preliminary Basic Knowledge Learning 5
Rails Tutorial 6th Edition Learning Summary Chapter 3
Rails Tutorial 6th Edition Learning Summary Chapter 8
Chapter 4 Rails Flavored Ruby
[Rails Struggle/Rails Tutorial] What you learned in Rails Tutorial Chapter 3
Rails Tutorial cheat sheet
Rails Tutorial Chapter 1 From Zero to Deployment [Try]
Rails version upgrade memorandum 5.0 → 5.1
[Rails] Learning with Rails tutorial
Chewing Rails Tutorial [Chapter 3 Creating Almost Static Pages]
rails tutorial fighting notes Ⅲ
Resolve Gem :: FilePermissionError when running gem install rails (Rails Tutorial Chapter 1)
[Ruby on Rails Tutorial] Error in the test in Chapter 3
Rails Tutorial 4th Edition: Chapter 1 From Zero to Deployment
Resolve ActiveRecord :: NoDatabaseError when doing rails test (Rails tutorial Chapter 3)
11.1 AccountActivations Resources: Rails Tutorial Notes-Chapter 11
Rails Tutorial (4th Edition) Summary
[Rails] Rails version upgrade error memorandum
I tried Rails beginner [Chapter 2]
[Rails] Implementation of tutorial function