TR kizaki Tech Memo

ruby...update with brew and rbenv →how to setup postgresql

.zhsrcの変更 rubyのlinkをHomebrewにしたい

元々のPATHはdelete

export PATH=$GEM_HOME/bin:$PATH export PATH=$PATH:/Users/$HOME/.gem/ruby/2.6.0/bin

brew upgrade のrubyを使いたいけど使えない

└─(16:32:30 on main ✖ ✹ ✭)──> brew link ruby                                                  ──(Tue,Jul11)─┘
Warning: Refusing to link macOS provided/shadowed software: ruby
If you need to have ruby first in your PATH, run:
  echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc

For compilers to find ruby you may need to set:
  export LDFLAGS="-L/usr/local/opt/ruby/lib"
  export CPPFLAGS="-I/usr/local/opt/ruby/include"

For pkg-config to find ruby you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"

brewでinstallしたrubyはrbenvでmanageするといいらしい。https://web-camp.io/magazine/archives/15051

PATHを変更してrbenvからlatest versionのrubyを引っ張るスタイルに変更する。

└─(17:30:50 on main ✖ ✹ ✭)──> rbenv install --list              ──(Tue,Jul11)─┘
2.7.8
3.0.6
3.1.4
3.2.2
jruby-9.4.2.0
mruby-3.2.0
picoruby-3.0.0
truffleruby-22.3.1
truffleruby+graalvm-22.3.1

Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all / -L' to show all local versions.
└─(17:34:30 on main ✖ ✹ ✭)──> rbenv install 3.2.2           1 ↵ ──(Tue,Jul11)─┘
To follow progress, use 'tail -f /var/folders/7c/xsq3zg0d4ybdxd8qvb6wgypw0000gn/T/ruby-build.20230711173456.66270.log' or pass --verbose
Downloading openssl-3.1.0.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/aaa925ad9828745c4cad9d9efeb273deca820f2cdcf2c3ac7d7c1212b7c497b4
Installing openssl-3.1.0...
Installed openssl-3.1.0 to /Users/$HOME/.rbenv/versions/3.2.2

Downloading ruby-3.2.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
Installing ruby-3.2.2...
ruby-build: using readline from homebrew
ruby-build: using libyaml from homebrew
ruby-build: using gmp from homebrew
Installed ruby-3.2.2 to /Users/$HOME/.rbenv/versions/3.2.2

NOTE: to activate this Ruby version as the new default, run: rbenv global 3.2.2

ref: https://stackoverflow.com/questions/60212356/rbenv-wrong-gem-installation-path-cant-find-gem

gemの位置関係の確認

gem pathを変えたいというかgemに最新バージョンのrubyをいれたい

└─(17:49:47 on main ✖ ✹ ✭)──> gem env home                  2 ↵ ──(Tue,Jul11)─┘
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0
└─(17:50:59 on main ✖ ✹ ✭)──> which ruby                        ──(Tue,Jul11)─┘
/usr/bin/ruby
┌─(~)───────────────────────────┐
└─(17:54:18 on main ✖ ✹ ✭)──> gem env                           ──(Tue,Jul11)─┘
RubyGems Environment:
  - RUBYGEMS VERSION: 3.4.16
  - RUBY VERSION: 2.6.10 (2022-04-12 patchlevel 210) [universal.x86_64-darwin21]
  - INSTALLATION DIRECTORY: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0
  - USER INSTALLATION DIRECTORY: /Users/$HOME/.gem/ruby/2.6.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
  - GIT EXECUTABLE: /usr/local/bin/git
  - EXECUTABLE DIRECTORY: /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin
  - SPEC CACHE DIRECTORY: /Users/$HOME/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
  - RUBYGEMS PLATFORMS:
     - ruby
     - universal-darwin-21
  - GEM PATHS:
     - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0
     - /Users/$HOME/.gem/ruby/2.6.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => true
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     Omitted

RubyのINSTALLATION DIRECTORYのPATHアドレスを.rbenvのshimsに変更する

ref: https://note.com/maimaineet/n/n1f526da613a2

└─(18:17:06 on main ✖ ✹ ✭)──> echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="$HOME/.rbenv/shims:$PATH"' >> ~/.zshrc
┌─(~)───────────────────────────┐
└─(20:13:54 on main ✖ ✹ ✭)──> exec $SHELL -l                    ──(Tue,Jul11)─┘
┌─(~)───────────────────────────┐
└─(20:14:12 on main ✖ ✹ ✭)──> which ruby                        ──(Tue,Jul11)─┘
/Users/$HOME/.rbenv/shims/ruby
┌─(~)───────────────────────────┐
└─(20:14:21 on main ✖ ✹ ✭)──> ruby -v                           ──(Tue,Jul11)─┘
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin21]

rubyがlatest version v3.2.2になったことが確認できた

railsをinstall

─(21:28:06 on main ✖ ✹ ✭)──> gem install rails                 ──(Tue,Jul11)─┘
Fetching thor-1.2.2.gem
Fetching method_source-1.0.0.gem
Fetching concurrent-ruby-1.2.2.gem
Fetching tzinfo-2.0.6.gem
Fetching i18n-1.14.1.gem
Fetching zeitwerk-2.6.8.gem
Fetching minitest-5.18.1.gem
Fetching activesupport-7.0.6.gem
Fetching nokogiri-1.15.3-x86_64-darwin.gem
Fetching crass-1.0.6.gem
Fetching loofah-2.21.3.gem
Fetching rails-html-sanitizer-1.6.0.gem
Fetching rails-dom-testing-2.1.1.gem
Fetching rack-2.2.7.gem
Fetching rack-test-2.1.0.gem
Fetching erubi-1.12.0.gem
Fetching builder-3.2.4.gem
Fetching actionview-7.0.6.gem
Fetching actionpack-7.0.6.gem
Fetching railties-7.0.6.gem
Fetching mini_mime-1.1.2.gem
Fetching marcel-1.0.2.gem
Fetching activemodel-7.0.6.gem
Fetching activerecord-7.0.6.gem
Fetching globalid-1.1.0.gem
Fetching activejob-7.0.6.gem
Fetching activestorage-7.0.6.gem
Fetching actiontext-7.0.6.gem
Fetching mail-2.8.1.gem
Fetching actionmailer-7.0.6.gem
Fetching actionmailbox-7.0.6.gem
Fetching websocket-extensions-0.1.5.gem
Fetching rails-7.0.6.gem
Fetching websocket-driver-0.7.5.gem
Fetching nio4r-2.5.9.gem
Fetching actioncable-7.0.6.gem
Successfully installed zeitwerk-2.6.8
Successfully installed thor-1.2.2
Successfully installed method_source-1.0.0
Successfully installed concurrent-ruby-1.2.2
Successfully installed tzinfo-2.0.6
Successfully installed minitest-5.18.1
Successfully installed i18n-1.14.1
Successfully installed activesupport-7.0.6
Successfully installed nokogiri-1.15.3-x86_64-darwin
Successfully installed crass-1.0.6
Successfully installed loofah-2.21.3
Successfully installed rails-html-sanitizer-1.6.0
Successfully installed rails-dom-testing-2.1.1
Successfully installed rack-2.2.7
Successfully installed rack-test-2.1.0
Successfully installed erubi-1.12.0
Successfully installed builder-3.2.4
Successfully installed actionview-7.0.6
Successfully installed actionpack-7.0.6
Successfully installed railties-7.0.6
Successfully installed mini_mime-1.1.2
Successfully installed marcel-1.0.2
Successfully installed activemodel-7.0.6
Successfully installed activerecord-7.0.6
Successfully installed globalid-1.1.0
Successfully installed activejob-7.0.6
Successfully installed activestorage-7.0.6
Successfully installed actiontext-7.0.6
Successfully installed mail-2.8.1
Successfully installed actionmailer-7.0.6
Successfully installed actionmailbox-7.0.6
Successfully installed websocket-extensions-0.1.5
Building native extensions. This could take a while...
Successfully installed websocket-driver-0.7.5
Building native extensions. This could take a while...
Successfully installed nio4r-2.5.9
Successfully installed actioncable-7.0.6
Successfully installed rails-7.0.6
Parsing documentation for zeitwerk-2.6.8
Installing ri documentation for zeitwerk-2.6.8
Parsing documentation for thor-1.2.2
Installing ri documentation for thor-1.2.2
Parsing documentation for method_source-1.0.0
Installing ri documentation for method_source-1.0.0
Parsing documentation for concurrent-ruby-1.2.2
Installing ri documentation for concurrent-ruby-1.2.2
Parsing documentation for tzinfo-2.0.6
Installing ri documentation for tzinfo-2.0.6
Parsing documentation for minitest-5.18.1
Couldn't find file to include 'README.rdoc' from lib/minitest.rb
Installing ri documentation for minitest-5.18.1
Parsing documentation for i18n-1.14.1
Installing ri documentation for i18n-1.14.1
Parsing documentation for activesupport-7.0.6
Installing ri documentation for activesupport-7.0.6
Parsing documentation for nokogiri-1.15.3-x86_64-darwin
Installing ri documentation for nokogiri-1.15.3-x86_64-darwin
Parsing documentation for crass-1.0.6
Installing ri documentation for crass-1.0.6
Parsing documentation for loofah-2.21.3
Installing ri documentation for loofah-2.21.3
Parsing documentation for rails-html-sanitizer-1.6.0
Installing ri documentation for rails-html-sanitizer-1.6.0
Parsing documentation for rails-dom-testing-2.1.1
Installing ri documentation for rails-dom-testing-2.1.1
Parsing documentation for rack-2.2.7
Installing ri documentation for rack-2.2.7
Parsing documentation for rack-test-2.1.0
Installing ri documentation for rack-test-2.1.0
Parsing documentation for erubi-1.12.0
Installing ri documentation for erubi-1.12.0
Parsing documentation for builder-3.2.4
Installing ri documentation for builder-3.2.4
Parsing documentation for actionview-7.0.6
Installing ri documentation for actionview-7.0.6
Parsing documentation for actionpack-7.0.6
Installing ri documentation for actionpack-7.0.6
Parsing documentation for railties-7.0.6
Installing ri documentation for railties-7.0.6
Parsing documentation for mini_mime-1.1.2
Installing ri documentation for mini_mime-1.1.2
Parsing documentation for marcel-1.0.2
Installing ri documentation for marcel-1.0.2
Parsing documentation for activemodel-7.0.6
Installing ri documentation for activemodel-7.0.6
Parsing documentation for activerecord-7.0.6
Installing ri documentation for activerecord-7.0.6
Parsing documentation for globalid-1.1.0
Installing ri documentation for globalid-1.1.0
Parsing documentation for activejob-7.0.6
Installing ri documentation for activejob-7.0.6
Parsing documentation for activestorage-7.0.6
Installing ri documentation for activestorage-7.0.6
Parsing documentation for actiontext-7.0.6
Installing ri documentation for actiontext-7.0.6
Parsing documentation for mail-2.8.1
Installing ri documentation for mail-2.8.1
Parsing documentation for actionmailer-7.0.6
Installing ri documentation for actionmailer-7.0.6
Parsing documentation for actionmailbox-7.0.6
Installing ri documentation for actionmailbox-7.0.6
Parsing documentation for websocket-extensions-0.1.5
Installing ri documentation for websocket-extensions-0.1.5
Parsing documentation for websocket-driver-0.7.5
Installing ri documentation for websocket-driver-0.7.5
Parsing documentation for nio4r-2.5.9
Installing ri documentation for nio4r-2.5.9
Parsing documentation for actioncable-7.0.6
Installing ri documentation for actioncable-7.0.6
Parsing documentation for rails-7.0.6
Installing ri documentation for rails-7.0.6
Done installing documentation for zeitwerk, thor, method_source, concurrent-ruby, tzinfo, minitest, i18n, activesupport, nokogiri, crass, loofah, rails-html-sanitizer, rails-dom-testing, rack, rack-test, erubi, builder, actionview, actionpack, railties, mini_mime, marcel, activemodel, activerecord, globalid, activejob, activestorage, actiontext, mail, actionmailer, actionmailbox, websocket-extensions, websocket-driver, nio4r, actioncable, rails after 29 seconds
36 gems installed

A new release of RubyGems is available: 3.4.10 → 3.4.16!
Run `gem update --system 3.4.16` to update your installation.
└─(21:29:19 on main ✖ ✹ ✭)──> gem update --system 3.4.16        ──(Tue,Jul11)─┘
Updating rubygems-update
Fetching rubygems-update-3.4.16.gem
Successfully installed rubygems-update-3.4.16
Parsing documentation for rubygems-update-3.4.16
Installing ri documentation for rubygems-update-3.4.16
Done installing documentation for rubygems-update after 43 seconds
Parsing documentation for rubygems-update-3.4.16
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 3.4.16
  Successfully built RubyGem
  Name: bundler
  Version: 2.4.16
  File: bundler-2.4.16.gem
Bundler 2.4.16 installed
RubyGems 3.4.16 installed
Regenerating binstubs
Regenerating plugins
Parsing documentation for rubygems-3.4.16
Installing ri documentation for rubygems-3.4.16

# 3.4.16 / 2023-07-10

## Enhancements:

* Installs bundler 2.4.16 as a default gem.

# 3.4.15 / 2023-06-29

## Enhancements:

* Installs bundler 2.4.15 as a default gem.

## Bug fixes:

* Autoload shellwords when it's needed. Pull request
  [#6734](https://github.com/rubygems/rubygems/pull/6734) by ioquatix

## Documentation:

* Update command to test local gem command changes. Pull request
  [#6761](https://github.com/rubygems/rubygems/pull/6761) by jenshenny

# 3.4.14 / 2023-06-12

## Enhancements:

* Load plugin immediately. Pull request
  [#6673](https://github.com/rubygems/rubygems/pull/6673) by kou
* Installs bundler 2.4.14 as a default gem.

## Documentation:

* Clarify what the `rubygems-update` gem is for, and link to source code
  and guides. Pull request
  [#6710](https://github.com/rubygems/rubygems/pull/6710) by davetron5000

# 3.4.13 / 2023-05-09

## Enhancements:

* Installs bundler 2.4.13 as a default gem.

# 3.4.12 / 2023-04-11

## Enhancements:

* [Experimental] Add WebAuthn Support to the CLI. Pull request
  [#6560](https://github.com/rubygems/rubygems/pull/6560) by jenshenny
* Installs bundler 2.4.12 as a default gem.

# 3.4.11 / 2023-04-10

## Enhancements:

* Installs bundler 2.4.11 as a default gem.

------------------------------------------------------------------------------

RubyGems installed the following executables:
	/Users/$HOME/.rbenv/versions/3.2.2/bin/gem
	/Users/$HOME/.rbenv/versions/3.2.2/bin/bundle
	/Users/$HOME/.rbenv/versions/3.2.2/bin/bundler

Ruby Interactive (ri) documentation was installed. ri is kind of like man 
pages for Ruby libraries. You may access it like this:
  ri Classname
  ri Classname.class_method
  ri Classname#instance_method
If you do not wish to install this documentation in the future, use the
--no-document flag, or set it as the default in your ~/.gemrc file. See
'gem help env' for details.

RubyGems system software updated

shell再起動後install success 確認

└─(21:34:19 on main ✖ ✹ ✭)──> rails --version                   ──(Tue,Jul11)─┘

Rails 7.0.6

このコマンドでshortcutだがlibpq,pgでerror

rails new monchifc0 --css tailwind --database=postgresql
Fetching tailwindcss-rails 2.0.29 (x86_64-darwin)
Using web-console 4.2.0
Using rails 7.0.6
Installing pg 1.5.3 with native extensions
Installing tailwindcss-rails 2.0.29 (x86_64-darwin)
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/pg-1.5.3/ext
/Users/$HOME/.rbenv/versions/3.2.2/bin/ruby extconf.rb
Calling libpq with GVL unlocked
checking for pg_config... no
checking for libpq per pkg-config... no
Using libpq from 
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*****************************************************************************

Unable to find PostgreSQL client library.

Please install libpq or postgresql client package like so:
  brew install libpq

or try again with:
  gem install pg -- --with-pg-config=/path/to/pg_config

or set library paths manually with:
gem install pg -- --with-pg-include=/path/to/libpq-fe.h/
--with-pg-lib=/path/to/libpq.so/

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/$HOME/.rbenv/versions/3.2.2/bin/$(RUBY_BASE_NAME)
	--with-pg
	--without-pg
	--enable-gvl-unlock
	--disable-gvl-unlock
	--enable-windows-cross
	--disable-windows-cross
	--with-pg-config
	--without-pg-config
	--with-pg_config
	--without-pg_config
	--with-libpq-dir
	--without-libpq-dir
	--with-libpq-include
	--without-libpq-include=${libpq-dir}/include
	--with-libpq-lib
	--without-libpq-lib=${libpq-dir}/lib
	--with-libpq-config
	--without-libpq-config
	--with-pkg-config
	--without-pkg-config
	--with-pg-dir
	--without-pg-dir
	--with-pg-include
	--without-pg-include=${pg-dir}/include
	--with-pg-lib
	--without-pg-lib=${pg-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/extensions/x86_64-darwin-21/3.2.0/pg-1.5.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/pg-1.5.3
for inspection.
Results logged to
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/extensions/x86_64-darwin-21/3.2.0/pg-1.5.3/gem_make.out

/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:118:in
`run'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:27:in
`build'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:186:in
`build_extension'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:220:in
`block in build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:217:in
`each'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:217:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/installer.rb:845:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/rubygems_gem_installer.rb:72:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/rubygems_gem_installer.rb:28:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/source/rubygems.rb:202:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/gem_installer.rb:54:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/parallel_installer.rb:156:in
`do_install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/parallel_installer.rb:147:in
`block in worker_pool'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:62:in
`apply_func'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:57:in
`block in process_queue'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:54:in
`loop'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:54:in
`process_queue'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:90:in
`block (2 levels) in create_threads'

An error occurred while installing pg (1.5.3), and Bundler cannot
continue.

In Gemfile:
  pg
         run  bundle binstubs bundler
Could not find gem 'pg (~> 1.1)' in locally installed gems.
       rails  importmap:install
Could not find gem 'pg (~> 1.1)' in locally installed gems.
Run `bundle install` to install missing gems.
       rails  turbo:install stimulus:install
Could not find gem 'pg (~> 1.1)' in locally installed gems.
Run `bundle install` to install missing gems.
       rails  tailwindcss:install
Could not find gem 'pg (~> 1.1)' in locally installed gems.
Run `bundle install` to install missing gems.

installできなかったpgはこれで解決

└─(07:59:11 on main ✭)──> gem install pg -v '1.5.3' -- --with-cflags="-Wno-error=implicit-function-declaration"

Building native extensions with: '--with-cflags=-Wno-error=implicit-function-declaration'
This could take a while...
Successfully installed pg-1.5.3
Parsing documentation for pg-1.5.3
Installing ri documentation for pg-1.5.3
Done installing documentation for pg after 3 seconds
1 gem installed

ref: https://zenn.dev/tmasuyama1114/articles/b2bb8bc141dcbd

└─(08:00:09 on main ✭)──> bundle install                        ──(Wed,Jul12)─┘
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Using rake 13.0.6
Using concurrent-ruby 1.2.2
Using minitest 5.18.1
Using builder 3.2.4
Using erubi 1.12.0
Using crass 1.0.6
Using nio4r 2.5.9
Using websocket-extensions 0.1.5
Using marcel 1.0.2
Using mini_mime 1.1.2
Using date 3.3.3
Using timeout 0.4.0
Using regexp_parser 2.8.1
Using io-console 0.6.0
Using msgpack 1.7.1
Using method_source 1.0.0
Using zeitwerk 2.6.8
Using matrix 0.4.2
Using public_suffix 5.0.3
Using bindex 0.8.1
Using bundler 2.4.16
Using racc 1.7.1
Using thor 1.2.2
Using websocket-driver 0.7.5
Using puma 5.6.6
Using net-protocol 0.2.1
Using rubyzip 2.3.2
Using bootsnap 1.16.0
Using reline 0.3.6
Using addressable 2.8.4
Using nokogiri 1.15.3 (x86_64-darwin)
Using websocket 1.2.9
Using i18n 1.14.1
Using xpath 3.2.0
Using net-pop 0.1.2
Using rexml 3.2.5
Using irb 1.7.2
Using loofah 2.21.3
Using debug 1.8.0
Using selenium-webdriver 4.10.0
Using tzinfo 2.0.6
Using net-imap 0.3.6
Using rack 2.2.7
Using webdrivers 5.2.0
Using net-smtp 0.3.3
Using activesupport 7.0.6
Using rack-test 2.1.0
Using sprockets 4.2.0
Using rails-html-sanitizer 1.6.0
Using rails-dom-testing 2.1.1
Using capybara 3.39.2
Using actionview 7.0.6
Using globalid 1.1.0
Using mail 2.8.1
Using activemodel 7.0.6
Using actionpack 7.0.6
Using activejob 7.0.6
Using jbuilder 2.11.5
Using actioncable 7.0.6
Using activerecord 7.0.6
Using railties 7.0.6
Using sprockets-rails 3.4.2
Using actionmailer 7.0.6
Using activestorage 7.0.6
Using importmap-rails 1.2.1
Using web-console 4.2.0
Using tailwindcss-rails 2.0.29 (x86_64-darwin)
Using turbo-rails 1.4.0
Using actiontext 7.0.6
Using stimulus-rails 1.2.1
Using actionmailbox 7.0.6
Using rails 7.0.6
Installing pg 1.5.3 with native extensions
Bundle complete! 16 Gemfile dependencies, 73 gems now installed.
Bundled gems are installed into `./.bundle`

bundle installの後にGemfile.lockが生成される

bundle install --path=.bundle でinstallすればプロジェクト内にGemfile.lockが生成されて便利

Postgresqlに対応

How To Use PostgreSQL with Your Ruby on Rails Application on macOS

まずPATHを設定

# postgresql
export PATH="/usr/local/opt/postgresql@14/bin:$PATH"

postgresql起動

└─(17:05:34 on main ✹ ✭)──> brew services start postgresql@14
==> Successfully started `postgresql@14` (label: homebrew.mxcl.postgresql@14)

versionがなぜか確認できない icu4cに原因がある様子

─(17:06:11 on main ✹ ✭)──> postgres -V                   127 ↵ ──(Thu,Jul13)─┘
dyld[53233]: Library not loaded: '/usr/local/opt/icu4c/lib/libicui18n.72.dylib'
  Referenced from: '/usr/local/Cellar/postgresql@14/14.7/bin/postgres'
  Reason: tried: '/usr/local/opt/icu4c/lib/libicui18n.72.dylib' (no such file), '/usr/local/lib/libicui18n.72.dylib' (no such file), '/usr/lib/libicui18n.72.dylib' (no such file), '/usr/local/Cellar/icu4c/73.2/lib/libicui18n.72.dylib' (no such file), '/usr/local/lib/libicui18n.72.dylib' (no such file), '/usr/lib/libicui18n.72.dylib' (no such file)

check info. PATHを発見!ref:stackoverflow

└─(17:54:38 on main ✹ ✭)──> brew info icu4c                                ──(Thu,Jul13)─┘
==> icu4c: stable 73.2 (bottled) [keg-only]
C/C++ and Java libraries for Unicode and globalization
https://icu.unicode.org/home
/usr/local/Cellar/icu4c/73.2 (268 files, 79.6MB)
  Poured from bottle using the formulae.brew.sh API on 2023-07-11 at 12:31:41
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/icu4c.rb
License: ICU
==> Caveats
icu4c is keg-only, which means it was not symlinked into /usr/local,
because macOS provides libicucore.dylib (but nothing else).

If you need to have icu4c first in your PATH, run:
  echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.zshrc

For compilers to find icu4c you may need to set:
  export LDFLAGS="-L/usr/local/opt/icu4c/lib"
  export CPPFLAGS="-I/usr/local/opt/icu4c/include"

For pkg-config to find icu4c you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"

PATHを通したら無事にpostgres -Vが起動した

└─(17:59:36 on main ✹ ✭)──> postgres -V                                    ──(Thu,Jul13)─┘
postgres (PostgreSQL) 14.8 (Homebrew)
└─(18:05:32 on main ✹ ✭)──> createuser -P -d monchifc                      ──(Thu,Jul13)─┘
Enter password for new role: 
Enter it again:

PATHに作成したdatabaseとpassword追加

export monchifc_DATABASE_PASSWORD="0721"

update config/database.yml

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: monchifc
  password: <%= ENV['MONCHIFC_DATABASE_PASSWORD'] %>
  timeout: 5000

development:
  <<: *default
  database: monchifc_development

test:
  <<: *default
  database: monchifc_test

production:
  <<: *default
  database: monchifc_production
  username: monchifc
  password: <%= ENV['MONCHIFC_DATABASE_PASSWORD'] %>
└─(18:13:29 on main ✹ ✭)──> rails db:create                                ──(Thu,Jul13)─┘
Created database 'monchifc_development'
Created database 'monchifc_test'

As the output suggests, this command created a development and test database in your PostgreSQL server.

You now have a PostgreSQL database connected to your Rails app. To ensure that your application is working, the next step is to test your configuration.

Test Configuration

└─(18:17:54 on main ✹ ✭)──> rails server --binding=127.0.0.1               ──(Thu,Jul13)─┘
=> Booting Puma
=> Rails 7.0.6 application starting in development 
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.6.6 (ruby 3.2.2-p53) ("Birdie's Version")
*  Min threads: 5
*  Max threads: 5
*  Environment: development
*          PID: 62461
* Listening on http://127.0.0.1:3000
Use Ctrl-C to stop
curl http://127.0.0.1:3000
<ul>
    <li><strong>Rails version:</strong> 7.0.6</li>
    <li><strong>Ruby version:</strong> ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin21]</li>
  </ul>
</body>

</html>

6.1 Generating a Model

bin/rails generate model Article title:string body:text

6.2 Database Migrations

└─(19:30:26 on main ✹)──> bin/rails db:migrate                             ──(Thu,Jul13)─┘

== 20230713150630 CreateArticles: migrating ===================================
-- create_table(:articles)
   -> 0.0344s
== 20230713150630 CreateArticles: migrated (0.0345s) ==========================

6.3 Using a Model to Interact with the Database

write Article by console

└─(19:30:33 on main ✹ ✭)──> bin/rails console                              ──(Thu,Jul13)─┘

Loading development environment (Rails 7.0.6)
irb(main):001:0> article = Article.new(title: "Hello Rails", body: "I am on Rails!")
=> 
#<Article:0x0000000114c5fd18
...
irb(main):002:0> 
irb(main):003:0> article.save
  TRANSACTION (0.2ms)  BEGIN
  Article Create (2.5ms)  INSERT INTO "articles" ("title", "body", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"  [["title", "Hello Rails"], ["body", "I am on Rails!"], ["created_at", "2023-07-13 16:22:22.391691"], ["updated_at", "2023-07-13 16:22:22.391691"]]
  TRANSACTION (43.2ms)  COMMIT
=> true
irb(main):004:0> article
=> 
#<Article:0x0000000114c5fd18
 id: 1,
 title: "Hello Rails",
 body: "I am on Rails!",
 created_at: Thu, 13 Jul 2023 16:22:22.391691000 UTC +00:00,
 updated_at: Thu, 13 Jul 2023 16:22:22.391691000 UTC +00:00>
irb(main):005:0> Article.all
  Article Load (0.4ms)  SELECT "articles".* FROM "articles"
=> 
[#<Article:0x0000000115d3a7a0
  id: 1,
  title: "Hello Rails",
  body: "I am on Rails!",
  created_at: Thu, 13 Jul 2023 16:22:22.391691000 UTC +00:00,
  updated_at: Thu, 13 Jul 2023 16:22:22.391691000 UTC +00:00>]
irb(main):006:0> 
^C
irb(main):006:0> exit

6.4 Showing a List of Articles

└─(20:27:48 on main ✹ ✭)──> rails server --binding=127.0.0.1               ──(Thu,Jul13)─┘
=> Booting Puma
=> Rails 7.0.6 application starting in development 
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.6.6 (ruby 3.2.2-p53) ("Birdie's Version")
*  Min threads: 5
*  Max threads: 5
*  Environment: development
*          PID: 73525
* Listening on http://127.0.0.1:3000
Use Ctrl-C to stop
Started GET "/" for 127.0.0.1 at 2023-07-13 20:28:15 +0400
  ActiveRecord::SchemaMigration Pluck (0.5ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by ArticlesController#index as HTML
  Rendering layout layouts/application.html.erb
  Rendering articles/index.html.erb within layouts/application
  Article Load (0.4ms)  SELECT "articles".* FROM "articles"
  ↳ app/views/articles/index.html.erb:4
  Rendered articles/index.html.erb within layouts/application (Duration: 10.9ms | Allocations: 5326)
  Rendered layout layouts/application.html.erb (Duration: 108.4ms | Allocations: 49957)
Completed 200 OK in 132ms (Views: 109.0ms | ActiveRecord: 3.4ms | Allocations: 54505)
└─(17:49:16 on main)──> bin/rails generate model Comment commenter:string body:text article:references

      invoke  active_record
      create    db/migrate/20230715135119_create_comments.rb
      create    app/models/comment.rb
      invoke    test_unit
      create      test/models/comment_test.rb
      create      test/fixtures/comments.yml

9.3 Using Concerns

└─(19:13:45 on main)──> bin/rails generate migration AddStatusToArticles status:string
bin/rails generate migration AddStatusToComments status:string

      invoke  active_record
      create    db/migrate/20230716151919_add_status_to_articles.rb
      invoke  active_record
      create    db/migrate/20230716151920_add_status_to_comments.rb
┌─(~/dev/monchifc)─────────────($HOME@djperrier-no-macbook:s003)─┐
└─(19:19:20 on main ✭)──> bin/rails db:migrate                  ──(Sun,Jul16)─┘

== 20230716151919 AddStatusToArticles: migrating ==============================
-- add_column(:articles, :status, :string)
   -> 0.0467s
== 20230716151919 AddStatusToArticles: migrated (0.0468s) =====================

== 20230716151920 AddStatusToComments: migrating ==============================
-- add_column(:comments, :status, :string)
   -> 0.0019s
== 20230716151920 AddStatusToComments: migrated (0.0019s) =====================

Mac修復後なぜかerror 発生

current directory:
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c
/Users/$HOME/.rbenv/versions/3.2.2/bin/ruby extconf.rb
checking for ffi_prep_closure_loc() in -lffi... no
checking for ffi_prep_closure_loc() in -llibffi... no
checking for ffi_prep_closure_loc() in -llibffi-8... no
checking for whether -Wl,--exclude-libs,ALL is accepted as LDFLAGS... no
checking for whether -pthread is accepted as LDFLAGS... yes
creating extconf.h
creating Makefile

current directory:
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c
make DESTDIR\= sitearchdir\=./.gem.20230725-35166-rfpqsg
sitelibdir\=./.gem.20230725-35166-rfpqsg clean

current directory:
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c
make DESTDIR\= sitearchdir\=./.gem.20230725-35166-rfpqsg
sitelibdir\=./.gem.20230725-35166-rfpqsg
Configuring libffi
configure: error: in
`/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi-x86_64-darwin21':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details
make: ***
["/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/ffi-1.15.5/ext/ffi_c/libffi-x86_64-darwin21"/.libs/libffi_convenience.a]
Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/ffi-1.15.5 for
inspection.
Results logged to
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/extensions/x86_64-darwin-21/3.2.0/ffi-1.15.5/gem_make.out

/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:118:in
`run'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:52:in
`block in make'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:44:in
`each'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:44:in
`make'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:41:in
`build'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:186:in
`build_extension'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:220:in
`block in build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:217:in
`each'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:217:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/installer.rb:845:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/rubygems_gem_installer.rb:72:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/rubygems_gem_installer.rb:28:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/source/rubygems.rb:202:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/gem_installer.rb:54:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/parallel_installer.rb:156:in
`do_install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/parallel_installer.rb:147:in
`block in worker_pool'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:62:in
`apply_func'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:57:in
`block in process_queue'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:54:in
`loop'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:54:in
`process_queue'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:90:in
`block (2 levels) in create_threads'

An error occurred while installing ffi (1.15.5), and Bundler cannot
continue.

In Gemfile:
  sassc-rails was resolved to 2.1.2, which depends on
    sassc was resolved to 2.4.0, which depends on
      ffi

https://stackoverflow.com/questions/60807971/issues-building-the-libffi-gem-native-extension-when-trying-to-install-jekyll-on

Errorの原因になっていそうだった libffi を改善したい

reinstall libffi on brew using brew reinstall libffi
add the new brew-installed libffi flags to your shell instance, e.g.
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
└─(19:39:48 on main ✹)──> brew reinstall libffi                 ──(Tue,Jul25)─┘
==> Fetching libffi
==> Downloading https://ghcr.io/v2/homebrew/core/libffi/manifests/3.4.4
######################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libffi/blobs/sha256:9dd80c4c3d4
######################################################################### 100.0%
==> Reinstalling libffi 
==> Pouring libffi--3.4.4.monterey.bottle.tar.gz
==> Caveats
libffi is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

For compilers to find libffi you may need to set:
  export LDFLAGS="-L/usr/local/opt/libffi/lib"
  export CPPFLAGS="-I/usr/local/opt/libffi/include"

For pkg-config to find libffi you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
==> Summary
🍺  /usr/local/Cellar/libffi/3.4.4: 17 files, 651.3KB
==> Running `brew cleanup libffi`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

Installing ffi 1.15.5 with native extensionsが成功して気づいた。

これはMac修復前のbrewの状態が良くないのが原因でbrew updateで解決できるのではないか?

└─(19:42:55 on main ✹)──> bundle install                        ──(Tue,Jul25)─┘
Fetching gem metadata from https://rubygems.org/..........
Installing ffi 1.15.5 with native extensions
Fetching sassc 2.4.0
Installing sassc 2.4.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/sassc-2.4.0/ext
/Users/$HOME/.rbenv/versions/3.2.2/bin/ruby extconf.rb
creating Makefile

current directory:
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20230725-63594-h88ib8
sitelibdir\=./.gem.20230725-63594-h88ib8 clean

current directory:
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20230725-63594-h88ib8
sitelibdir\=./.gem.20230725-63594-h88ib8
compiling ./libsass/src/ast.cpp
In file included from
/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/gcc/x86_64-apple-darwin21/13/include/stdint.h:9,
                 from ./libsass/src/memory/../MurmurHash2.hpp:26,
                 from ./libsass/src/memory/allocator.hpp:6,
                 from ./libsass/src/memory.hpp:8,
                 from ./libsass/src/sass.hpp:55,
                 from ./libsass/src/ast.cpp:3:
/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/gcc/x86_64-apple-darwin21/13/include-fixed/stdint.h:27:10:
fatal error: sys/_types/_int8_t.h: No such file or directory
   27 | #include <sys/_types/_int8_t.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [ast.o] Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/sassc-2.4.0 for
inspection.
Results logged to
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/extensions/x86_64-darwin-21/3.2.0/sassc-2.4.0/gem_make.out

/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:118:in
`run'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:52:in
`block in make'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:44:in
`each'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:44:in
`make'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:41:in
`build'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:186:in
`build_extension'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:220:in
`block in build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:217:in
`each'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:217:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/installer.rb:845:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/rubygems_gem_installer.rb:72:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/rubygems_gem_installer.rb:28:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/source/rubygems.rb:202:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/gem_installer.rb:54:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/parallel_installer.rb:156:in
`do_install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/parallel_installer.rb:147:in
`block in worker_pool'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:62:in
`apply_func'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:57:in
`block in process_queue'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:54:in
`loop'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:54:in
`process_queue'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:90:in
`block (2 levels) in create_threads'

An error occurred while installing sassc (2.4.0), and Bundler cannot
continue.

In Gemfile:
  sassc-rails was resolved to 2.1.2, which depends on
    sassc

試しにbrew upgradeしたあとにbundle installしてみたがError

おすすめされているのが gem install sassc -- --disable-march-tune-native

https://github.com/sass/sassc-ruby/issues/146#issuecomment-541364174 sasscが原因になっている様子。しかしそもそものgem installできず

└─(19:57:17 on main ✹)──> gem install sassc -- --disable-march-tune-native
Building native extensions with: '--disable-march-tune-native'
This could take a while...
Successfully installed ffi-1.15.5
Building native extensions with: '--disable-march-tune-native'
This could take a while...
ERROR:  Error installing sassc:
	ERROR: Failed to build gem native extension.

    current directory: /Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sassc-2.4.0/ext
/Users/$HOME/.rbenv/versions/3.2.2/bin/ruby extconf.rb --disable-march-tune-native
creating Makefile

current directory: /Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20230725-67775-fz5o8e sitelibdir\=./.gem.20230725-67775-fz5o8e clean

current directory: /Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sassc-2.4.0/ext
make DESTDIR\= sitearchdir\=./.gem.20230725-67775-fz5o8e sitelibdir\=./.gem.20230725-67775-fz5o8e
compiling ./libsass/src/ast.cpp
In file included from /usr/local/Cellar/gcc/13.1.0/lib/gcc/current/gcc/x86_64-apple-darwin21/13/include/stdint.h:9,
                 from ./libsass/src/memory/../MurmurHash2.hpp:26,
                 from ./libsass/src/memory/allocator.hpp:6,
                 from ./libsass/src/memory.hpp:8,
                 from ./libsass/src/sass.hpp:55,
                 from ./libsass/src/ast.cpp:3:
/usr/local/Cellar/gcc/13.1.0/lib/gcc/current/gcc/x86_64-apple-darwin21/13/include-fixed/stdint.h:27:10: fatal error: sys/_types/_int8_t.h: No such file or directory
   27 | #include <sys/_types/_int8_t.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [ast.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sassc-2.4.0 for inspection.
Results logged to /Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/extensions/x86_64-darwin-21/3.2.0/sassc-2.4.0/gem_make.out

stackoverflow In file included from /usr/local/Cellar/gcc/13.1.0/lib/gcc/current/gcc/x86_64-apple-darwin21/13/include/stdint.h:9,

これを見る限りHomebrewの不具合で認識があっていた。

You need to reinstall Homebrew and GCC after the Mojave update. The GCC toolchain is not included in MacOS for many years now. It appears from your cellar directory that you are using a Homebrew installed version of GCC.

Please review the Homebrew documentation and do a clean install of Homebrew and GCC. Do note that you will still need Xcode Command Line Tools to install and use Homebrew.

HomebrewとGCCをreinstallが必要だと。

確かに調べてみたらMac修復前のclangからのGCC設定だけresetされていた

└─(20:44:05 on main ✖ ✹ ✭)──> gcc --version                     ──(Tue,Jul25)─┘
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
┌─(~)───────────────────────────┐
└─(20:44:14 on main ✖ ✹ ✭)──> g++ --version                     ──(Tue,Jul25)─┘
g++ (Homebrew GCC 13.1.0) 13.1.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

前回設定してあったシンボリックリンクをunlinkして、gccを再設定する!

ref:[nodebrewを消したらgcc(GNU Compiler Collection)とviが使えなくなったのでgcc再設定したい] https://www.notion.so/trkizaki/nodebrew-gcc-GNU-Compiler-Collection-vi-gcc-1630e138c15b498ca139c89c80f86750?pvs=4

┌─(~/dev/monchifc)──────────────┐
└─(20:48:03 on main ✹)──> unlink /usr/local/bin/gcc         1 ↵ ──(Tue,Jul25)─┘
┌─(~/dev/monchifc)──────────────┐
└─(20:49:01 on main ✹)──> ln -s /usr/local/bin/gcc-13 /usr/local/bin/gcc

└─(20:51:27 on main ✹)──> exec $SHELL -l                        ──(Tue,Jul25)─┘
┌─(~/dev/monchifc)──────────────┐
└─(20:53:00 on main ✹)──> gcc --version                         ──(Tue,Jul25)─┘
gcc (Homebrew GCC 13.1.0) 13.1.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc再設定してもbundle errorが出たので、結局homebrew reinstallすることにした。

formulateとcaskはmemoっておいて後で読み込む。

brew leaves -r > homebrew-formulae.txt
brew list --cask > homebrew-cask.txt
└─(21:49:20 on main ✖ ✹ ✭)──> /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password)...
Password:
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following new directories will be created:
/usr/local/Cellar
/usr/local/Caskroom

Press RETURN/ENTER to continue or any other key to abort:
==> /usr/bin/sudo /bin/mkdir -p /usr/local/Cellar /usr/local/Caskroom
==> /usr/bin/sudo /bin/chmod ug=rwx /usr/local/Cellar /usr/local/Caskroom
==> /usr/bin/sudo /usr/sbin/chown $HOME /usr/local/Cellar /usr/local/Caskroom
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Cellar /usr/local/Caskroom
==> /usr/bin/sudo /usr/sbin/chown -R $HOME:admin /usr/local/Homebrew
==> /usr/bin/sudo /bin/mkdir -p /Users/$HOME/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/$HOME/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown -R $HOME /Users/$HOME/Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 5 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), 47.37 KiB | 544.00 KiB/s, done.
From https://github.com/Homebrew/brew
 * [new branch]          imgbot     -> origin/imgbot
HEAD is now at 471e73364 Merge pull request #15754 from MikeMcQuaid/cask_url_class
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations

==> Next steps:
- Run these two commands in your terminal to add Homebrew to your PATH:
    (echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/$HOME/.zprofile
    eval "$(/usr/local/bin/brew shellenv)"
- Run brew help to get started
- Further documentation:
    https://docs.brew.sh
brew install `cat homebrew-formulae.txt`
brew install --cask `cat homebrew-casks.txt`

Errorを読み解くと、GCCに問題があるように見える

└─(19:52:12 on main ✖)──> bundle install                        ──(Wed,Jul26)─┘
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Installing websocket-driver 0.7.6 with native extensions
Installing msgpack 1.7.2 with native extensions
Installing sassc 2.4.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/websocket-driver-0.7.6/ext/websocket-driver
/Users/$HOME/.rbenv/versions/3.2.2/bin/ruby extconf.rb
creating Makefile

current directory:
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/websocket-driver-0.7.6/ext/websocket-driver
make DESTDIR\= sitearchdir\=./.gem.20230726-23887-3uky58
sitelibdir\=./.gem.20230726-23887-3uky58 clean

current directory:
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/websocket-driver-0.7.6/ext/websocket-driver
make DESTDIR\= sitearchdir\=./.gem.20230726-23887-3uky58
sitelibdir\=./.gem.20230726-23887-3uky58
compiling websocket_mask.c
gcc: error: unrecognized command-line option '-fdeclspec'
gcc: error: unrecognized command-line option '-Wextra-tokens'; did you mean
'-Wextra-semi'?
gcc: error: unrecognized command-line option '-Wdivision-by-zero'; did you mean
'-Wdiv-by-zero'?
gcc: error: unrecognized command-line option '-Wshorten-64-to-32'
make: *** [websocket_mask.o] Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/websocket-driver-0.7.6
for inspection.
Results logged to
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/extensions/x86_64-darwin-21/3.2.0/websocket-driver-0.7.6/gem_make.out

/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:118:in
`run'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:52:in
`block in make'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:44:in
`each'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:44:in
`make'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:41:in
`build'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:186:in
`build_extension'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:220:in
`block in build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:217:in
`each'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:217:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/installer.rb:845:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/rubygems_gem_installer.rb:72:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/rubygems_gem_installer.rb:28:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/source/rubygems.rb:202:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/gem_installer.rb:54:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/parallel_installer.rb:156:in
`do_install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/parallel_installer.rb:147:in
`block in worker_pool'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:62:in
`apply_func'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:57:in
`block in process_queue'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:54:in
`loop'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:54:in
`process_queue'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:90:in
`block (2 levels) in create_threads'

An error occurred while installing websocket-driver (0.7.6), and
Bundler cannot continue.

In Gemfile:
  rails was resolved to 7.0.6, which depends on
    actioncable was resolved to 7.0.6, which depends on
      websocket-driver

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/msgpack-1.7.2/ext/msgpack
/Users/$HOME/.rbenv/versions/3.2.2/bin/ruby extconf.rb
checking for rb_enc_interned_str() in ruby.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/$HOME/.rbenv/versions/3.2.2/bin/$(RUBY_BASE_NAME)
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:490:in
`try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.

from
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:583:in
`try_link0'
from
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:601:in
`try_link'
from
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:812:in
`try_func'
from
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:1116:in
`block in have_func'
from
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:989:in
`block in checking_for'
from
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:354:in
`block (2 levels) in postpone'
from
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:324:in
`open'
from
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:354:in
`block in postpone'
from
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:324:in
`open'
from
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:350:in
`postpone'
from
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:988:in
`checking_for'
from
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/3.2.0/mkmf.rb:1115:in
`have_func'
	from extconf.rb:3:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/extensions/x86_64-darwin-21/3.2.0/msgpack-1.7.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/gems/msgpack-1.7.2 for
inspection.
Results logged to
/Users/$HOME/dev/monchifc/.bundle/ruby/3.2.0/extensions/x86_64-darwin-21/3.2.0/msgpack-1.7.2/gem_make.out

/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:118:in
`run'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/ext_conf_builder.rb:27:in
`build'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:186:in
`build_extension'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:220:in
`block in build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:217:in
`each'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/ext/builder.rb:217:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/rubygems/installer.rb:845:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/rubygems_gem_installer.rb:72:in
`build_extensions'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/rubygems_gem_installer.rb:28:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/source/rubygems.rb:202:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/gem_installer.rb:54:in
`install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/parallel_installer.rb:156:in
`do_install'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/installer/parallel_installer.rb:147:in
`block in worker_pool'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:62:in
`apply_func'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:57:in
`block in process_queue'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:54:in
`loop'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:54:in
`process_queue'
/Users/$HOME/.rbenv/versions/3.2.2/lib/ruby/site_ruby/3.2.0/bundler/worker.rb:90:in
`block (2 levels) in create_threads'

An error occurred while installing msgpack (1.7.2), and Bundler cannot
continue.

In Gemfile:
  bootsnap was resolved to 1.16.0, which depends on
    msgpack

最初にpqをgem installした時のように-- --with-cflags="-Wno-error=implicit-function-declaration"でgem installしていくも根本的な解決にはなっていない

└─(19:56:53 on main ✖)──>  gem install msgpack -v '1.7.2' -- --with-cflags="-Wno-error=implicit-function-declaration"
Fetching msgpack-1.7.2.gem
Building native extensions with: '--with-cflags=-Wno-error=implicit-function-declaration'
This could take a while...
Successfully installed msgpack-1.7.2
Parsing documentation for msgpack-1.7.2
Installing ri documentation for msgpack-1.7.2
Done installing documentation for msgpack after 0 seconds
1 gem installed
┌─(~/dev/monchifc)──────────────┐
└─(19:59:56 on main ✖)──>  gem install sassc -v '2.4.0' -- --with-cflags="-Wno-error=implicit-function-declaration"
Building native extensions with: '--with-cflags=-Wno-error=implicit-function-declaration'
This could take a while...
Successfully installed sassc-2.4.0
Parsing documentation for sassc-2.4.0
Installing ri documentation for sassc-2.4.0
Done installing documentation for sassc after 0 seconds
1 gem installed

clangに戻したら急にbundle install できるようになった!solved

└─(20:12:46 on main ✖)──> unlink /usr/local/bin/gcc             ──(Wed,Jul26)─┘
┌─(~/dev/monchifc)──────────────┐
└─(20:14:04 on main ✖)──> gcc --version                         ──(Wed,Jul26)─┘
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
┌─(~/dev/monchifc)──────────────┐
└─(20:14:15 on main ✖)──> bundle                                ──(Wed,Jul26)─┘
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Installing websocket-driver 0.7.6 with native extensions
Installing msgpack 1.7.2 with native extensions
Installing sassc 2.4.0 with native extensions
Fetching sassc-rails 2.1.2
Installing sassc-rails 2.1.2
Bundle complete! 19 Gemfile dependencies, 88 gems now installed.
Bundled gems are installed into `./.bundle`

前回はコメント欄にあるように rm /usr/local/var/postgres/postmaster.pid で解決できたpostgresqlの不具合。 今回はpostgresql@14のERRORをre-installで解決していく。

サイトが反映されないので、db:create db:migrate はやり直しが必要

└─(21:44:55 on main ✖ ✹ ✭)──> brew uninstall --force postgresql
Warning: Formula postgresql was renamed to postgresql@14.
Uninstalling postgresql@14... (3,315 files, 44.5MB)
┌─(~)───────────────────────────┐
└─(21:46:09 on main ✖ ✹ ✭)──> ll /usr/local/var/postgresql@14   ──(Wed,Jul26)─┘
total 112
-rw-------   1 $HOME  admin     3B 13 Jul 17:54 PG_VERSION
drwx------   7 $HOME  admin   224B 13 Jul 18:17 base
drwx------  59 $HOME  admin   1.8K 25 Jul 00:34 global
-rw-------   1 $HOME  admin   4.7K 13 Jul 17:54 pg_hba.conf
-rw-------   1 $HOME  admin   1.6K 13 Jul 17:54 pg_ident.conf
drwx------   3 $HOME  admin    96B 25 Jul 21:49 pg_logical
drwx------   4 $HOME  admin   128B 13 Jul 17:54 pg_multixact
drwx------   3 $HOME  admin    96B 26 Jul 12:30 pg_stat_tmp
drwx------   3 $HOME  admin    96B 13 Jul 17:54 pg_subtrans
drwx------   3 $HOME  admin    96B 25 Jul 21:49 pg_wal
drwx------   3 $HOME  admin    96B 13 Jul 17:54 pg_xact
-rw-------   1 $HOME  admin    88B 13 Jul 17:54 postgresql.auto.conf
-rw-------   1 $HOME  admin    28K 13 Jul 17:54 postgresql.conf
-rw-------   1 $HOME  admin    88B 25 Jul 12:25 postmaster.opts
┌─(~)───────────────────────────┐
└─(21:46:40 on main ✖ ✹ ✭)──> rm -rf /usr/local/var/postgresql@14
┌─(~)───────────────────────────┐
└─(21:47:16 on main ✖ ✹ ✭)──> brew install postgresql@14        ──(Wed,Jul26)─┘
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
==> Updated Homebrew from 471e73364 to fc86485e9.
Updated 2 taps (homebrew/services and homebrew/cask).
==> New Casks
replay                                   sfm

You have 3 outdated formulae installed.

==> Fetching postgresql@14
==> Downloading https://ghcr.io/v2/homebrew/core/postgresql/14/manifests/14.8_2
Already downloaded: /Users/$HOME/Library/Caches/Homebrew/downloads/48d5fd21a79ce56dc177b1529e83e66b3aa6cc746aeb2fbe5f055d65cf377fd5--postgresql@14-14.8_2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/postgresql/14/blobs/sha256:96ea
Already downloaded: /Users/$HOME/Library/Caches/Homebrew/downloads/ae15cdd4529b5860ca690131c49f46560f055cbb61545fa39802cd0b46a012fb--postgresql@14--14.8_2.monterey.bottle.tar.gz
==> Pouring postgresql@14--14.8_2.monterey.bottle.tar.gz
==> /usr/local/Cellar/postgresql@14/14.8_2/bin/initdb --locale=C -E UTF-8 /usr/l
==> Caveats
This formula has created a default database cluster with:
  initdb --locale=C -E UTF-8 /usr/local/var/postgresql@14
For more details, read:
  https://www.postgresql.org/docs/14/app-initdb.html

To start postgresql@14 now and restart at login:
  brew services start postgresql@14
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/postgresql@14/bin/postgres -D /usr/local/var/postgresql@14
==> Summary
🍺  /usr/local/Cellar/postgresql@14/14.8_2: 3,315 files, 44.5MB
==> Running `brew cleanup postgresql@14`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).└─(21:50:52 on main ✖ ✹ ✭)──> postgres -V                   2 ↵ ──(Wed,Jul26)─┘
postgres (PostgreSQL) 14.8 (Homebrew)
┌─(~)───────────────────────────┐
└─(21:58:41 on main ✖ ✹ ✭)──> createuser -P -d monchifc         ──(Wed,Jul26)─┘
Enter password for new role: 
Enter it again:

└─(22:04:52 on main ✹)──> rails db:create                       ──(Wed,Jul26)─┘
Created database 'monchifc_development'
Created database 'monchifc_test'
┌─(~/dev/monchifc)──────────────┐
└─(22:05:00 on main ✹)──> bin/rails db:migrate RAILS_ENV=development
== 20230713150630 CreateArticles: migrating ===================================
-- create_table(:articles)
   -> 0.0480s
== 20230713150630 CreateArticles: migrated (0.0481s) ==========================

== 20230715135119 CreateComments: migrating ===================================
-- create_table(:comments)
   -> 0.0480s
== 20230715135119 CreateComments: migrated (0.0480s) ==========================

== 20230716151919 AddStatusToArticles: migrating ==============================
-- add_column(:articles, :status, :string)
   -> 0.0412s
== 20230716151919 AddStatusToArticles: migrated (0.0413s) =====================

== 20230716151920 AddStatusToComments: migrating ==============================
-- add_column(:comments, :status, :string)
   -> 0.0014s
== 20230716151920 AddStatusToComments: migrated (0.0015s) =====================

== 20230719103644 DeviseCreateUsers: migrating ================================
-- create_table(:users)
   -> 0.0466s
-- add_index(:users, :email, {:unique=>true})
   -> 0.0016s
-- add_index(:users, :reset_password_token, {:unique=>true})
   -> 0.0012s
== 20230719103644 DeviseCreateUsers: migrated (0.0495s) =======================