rails db migrateとポスグレSQL起動時のエラー

<h1>目次一覧</h1>
<ul>
<li>困ってたエラー内容</li>
<li>考えたこと</li>
<li>解決策</li>
<li>解決策実行後の結果</li>
</ul>



<h2>困ってたエラー内容</h2>
<h3>1️⃣ポスぐれちゃん実行時</h3>

```
user@usernoMacBook k % pg_ctl -D /usr/local/var/postgres@14 start

waiting for server to start....2024-02-19 19:10:33.891 JST [33480] LOG:  starting PostgreSQL 14.11 (Homebrew) on x86_64-apple-darwin22.6.0, compiled by Apple clang version 15.0.0 (clang-1500.1.0.2.5), 64-bit
2024-02-19 19:10:33.901 JST [33480] LOG:  could not bind IPv6 address "::1": Address already in use
2024-02-19 19:10:33.901 JST [33480] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2024-02-19 19:10:33.901 JST [33480] LOG:  could not bind IPv4 address "127.0.0.1": Address already in use
2024-02-19 19:10:33.901 JST [33480] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2024-02-19 19:10:33.901 JST [33480] WARNING:  could not create listen socket for "localhost"
2024-02-19 19:10:33.907 JST [33480] FATAL:  could not create any TCP/IP sockets
2024-02-19 19:10:33.909 JST [33480] LOG:  database system is shut down
 stopped waiting
pg_ctl: could not start server
Examine the log output.

 ```



<h3>2️⃣migrate失敗 エラー内容</h3>

```
user@usernoMacBook k % rails db:migrate
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
/Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:430:in `visit_Psych_Nodes_Alias': Unknown alias: default (Psych::BadAlias)
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/visitor.rb:30:in `visit'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/visitor.rb:6:in `accept'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:35:in `accept'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:345:in `block in revive_hash'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `each'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `each_slice'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `revive_hash'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:167:in `visit_Psych_Nodes_Mapping'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/visitor.rb:30:in `visit'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/visitor.rb:6:in `accept'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:35:in `accept'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:345:in `block in revive_hash'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `each'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `each_slice'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:343:in `revive_hash'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:167:in `visit_Psych_Nodes_Mapping'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/visitor.rb:30:in `visit'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/visitor.rb:6:in `accept'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:35:in `accept'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:318:in `visit_Psych_Nodes_Document'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/visitor.rb:30:in `visit'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/visitor.rb:6:in `accept'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych/visitors/to_ruby.rb:35:in `accept'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych.rb:335:in `safe_load'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/psych.rb:370:in `load'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/env.rb:30:in `available_environments'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/env.rb:21:in `current'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/env.rb:15:in `inquire'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/env.rb:7:in `inquire'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/instance.rb:11:in `env'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/instance.rb:18:in `config'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker.rb:34:in `config'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/webpacker-4.3.0/lib/webpacker/railtie.rb:32:in `block in <class:Engine>'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-6.0.3/lib/rails/initializable.rb:32:in `instance_exec'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-6.0.3/lib/rails/initializable.rb:32:in `run'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-6.0.3/lib/rails/initializable.rb:61:in `block in run_initializers'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/tsort.rb:228:in `block in tsort_each'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/tsort.rb:431:in `each_strongly_connected_component_from'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/tsort.rb:349:in `block in each_strongly_connected_component'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/tsort.rb:347:in `each'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/tsort.rb:347:in `call'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/tsort.rb:347:in `each_strongly_connected_component'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/tsort.rb:226:in `tsort_each'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/3.1.0/tsort.rb:205:in `tsort_each'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-6.0.3/lib/rails/initializable.rb:60:in `run_initializers'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-6.0.3/lib/rails/application.rb:363:in `initialize!'
	from /Users/user/taki/k/config/environment.rb:5:in `<main>'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-6.0.3/lib/active_support/dependencies.rb:324:in `block in require'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-6.0.3/lib/active_support/dependencies.rb:291:in `load_dependency'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-6.0.3/lib/active_support/dependencies.rb:324:in `require'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-6.0.3/lib/rails/application.rb:339:in `require_environment!'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-6.0.3/lib/rails/command/actions.rb:28:in `require_environment!'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-6.0.3/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-6.0.3/lib/rails/commands/dbconsole/dbconsole_command.rb:177:in `perform'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-6.0.3/lib/rails/command/base.rb:69:in `perform'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-6.0.3/lib/rails/command.rb:46:in `invoke'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/railties-6.0.3/lib/rails/commands.rb:18:in `<main>'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
	from /Users/user/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
	from bin/rails:4:in `<main>'
```

<h2>考えたこと</h2>
<h3>前に"Psych UnknownAlias"で調べて、Gemfile修正したことあるけど、
それで解決できたりして...前でたエラー画面の文字、Psychが被ってるし</h3>

<h2>解決策</h2>

```
『Gemfileにこれ記入』
gem 'psych', '~> 3.1’

      ↓
bundle install
```

<h2>参考にした記事<h2>
https://qiita.com/Bjp8kHYYPFq8MrI/items/90a9db03160f8d6f7e5c

<h3>解決策実行後の結果</h3>

```
user@usernoMacBook k % rails db:create                           
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Created database 'rails_functions_task_development'
Created database 'rails_functions_task_test'
user@usernoMacBook k % rails db:migrate
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
== 20201020025325 CreateUsers: migrating ======================================
-- create_table(:users)
   -> 0.0361s
== 20201020025325 CreateUsers: migrated (0.0362s) =============================

```
<h2>わかったこと</h2>
<h3>migrateできない 
<br>→ つまりPostgresqlも起動できない 
<br>→ migrateできるためには、入れておかなきゃいけないGemがある
<br>ということだった
<br>- 完</h3>