【解決】FATAL:  database "postgres" does not exist DETAIL:  The database subdirectory "base/13688" is missing. Couldn't create 'mannyou_development' database. Please check your configuratio

## Macのストレージ(その他)を綺麗にしたらRailsの開発環境がイカれた③

### rails db:createができない

```
FATAL:  database "postgres" does not exist
DETAIL:  The database subdirectory "base/13688" is missing.
Couldn't create 'mannyou_development' database. Please check your configuration.
rails aborted!
ActiveRecord::NoDatabaseError: FATAL:  database "postgres" does not exist
DETAIL:  The database subdirectory "base/13688" is missing.
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:696:in `rescue in connect'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:691:in `connect'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:223:in `initialize'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `new'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `postgresql_connection'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/connection_handling.rb:90:in `connection'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/tasks/postgresql_database_tasks.rb:12:in `connection'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/tasks/postgresql_database_tasks.rb:21:in `create'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/tasks/database_tasks.rb:119:in `create'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/tasks/database_tasks.rb:139:in `block in create_current'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/tasks/database_tasks.rb:316:in `block in each_current_configuration'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/tasks/database_tasks.rb:313:in `each'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/tasks/database_tasks.rb:313:in `each_current_configuration'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/tasks/database_tasks.rb:138:in `create_current'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activerecord-5.2.4.1/lib/active_record/railties/databases.rake:29:in `block (2 levels) in <main>'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/railties-5.2.4.1/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/railties-5.2.4.1/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/railties-5.2.4.1/lib/rails/command.rb:48:in `invoke'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/railties-5.2.4.1/lib/rails/commands.rb:18:in `<main>'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `block in require'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:257:in `load_dependency'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/activesupport-5.2.4.1/lib/active_support/dependencies.rb:291:in `require'
/Users/jun/dic/mannyou_assignment/bin/rails:9:in `<top (required)>'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `load'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/spring-2.1.0/lib/spring/client/rails.rb:28:in `call'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/spring-2.1.0/bin/spring:49:in `<top (required)>'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `load'
/Users/jun/dic/mannyou_assignment/vendor/bundle/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<top (required)>'
/Users/jun/dic/mannyou_assignment/bin/spring:15:in `require'
/Users/jun/dic/mannyou_assignment/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
```

## やったこと

**とりあえずpostgresqlの再起動**

```
$ brew services restart postgresql
```

したがダメ

## 解決策

**postgresqlアンインストール**

```
$ brew uninstall --ignore-dependencies postgresql

Uninstalling /usr/local/Cellar/postgresql/12.2... (3,218 files, 37.8MB)
MacBook-Pro-4:mannyou_assignment jun$ rm -rf /usr/local/var/postgres
MacBook-Pro-4:mannyou_assignment jun$ brew install postgresql
==> Downloading https://homebrew.bintray.com/bottles/postgresql-12.2.catalina.bottle.tar.gz
Already downloaded: /Users/jun/Library/Caches/Homebrew/downloads/ce703f1d4a362ba7bd6c54f75a5a8708672cd8898932b8e1364c09d742aca201--postgresql-12.2.catalina.bottle.tar.gz
==> Pouring postgresql-12.2.catalina.bottle.tar.gz
==> /usr/local/Cellar/postgresql/12.2/bin/initdb --locale=C -E UTF-8 /usr/local/var/postgres
==> Caveats
To migrate existing data from a previous major version of PostgreSQL run:
  brew postgresql-upgrade-database

To have launchd start postgresql now and restart at login:
  brew services start postgresql
Or, if you don't want/need a background service you can just run:
  pg_ctl -D /usr/local/var/postgres start
==> Summary
🍺  /usr/local/Cellar/postgresql/12.2: 3,218 files, 37.8MB
```

**postgresql再インストール**

```
$ brew install postgresql

==> Downloading https://homebrew.bintray.com/bottles/postgresql-12.2.catalina.bottle.tar.gz
Already downloaded: /Users/jun/Library/Caches/Homebrew/downloads/ce703f1d4a362ba7bd6c54f75a5a8708672cd8898932b8e1364c09d742aca201--postgresql-12.2.catalina.bottle.tar.gz
==> Pouring postgresql-12.2.catalina.bottle.tar.gz
==> /usr/local/Cellar/postgresql/12.2/bin/initdb --locale=C -E UTF-8 /usr/local/var/postgres
==> Caveats
To migrate existing data from a previous major version of PostgreSQL run:
  brew postgresql-upgrade-database

To have launchd start postgresql now and restart at login:
  brew services start postgresql
Or, if you don't want/need a background service you can just run:
  pg_ctl -D /usr/local/var/postgres start
==> Summary
🍺  /usr/local/Cellar/postgresql/12.2: 3,218 files, 37.8MB
```

以上です！

****

### Macのストレージ(その他)を綺麗にしたらRailsの開発環境がイカれた

Macのストレージ(その他)を綺麗にしたらRailsの開発環境がイカれた①
[ruby -vができない](https://qiita.com/___inon_/items/aaed570712bfbae3116d)

Macのストレージ(その他)を綺麗にしたらRailsの開発環境がイカれた②
[bundle installでつまづく](https://qiita.com/___inon_/items/c898c67f536f9d2d766c)

Macのストレージ(その他)を綺麗にしたらRailsの開発環境がイカれた②
[rails db:createができない](https://qiita.com/___inon_/items/1ad3e2594dc0d35b9568)　　　　 ← ここ