久しぶりに pod install しようとしたら怒られた

# ことのはじまり

```console
$ pod install
rbenv: version `2.4.1' is not installed (set by /path/to/.ruby-version)
```

# tl;dr

解決までにやったことまとめ

1. `brew upgrade rbenv`
2. `brew upgrade ruby-build`
3. `rbenv install 2.4.1`
4. `rbenv global 2.4.1`
5. `gem install cocoapods`
6. `rbenv rehash`
7. `pod setup`
8. `pod install` (∩´∀｀)∩ﾜｰｲ

# 解決までの詳細

```console
$ pod install
rbenv: version `2.4.1' is not installed (set by /path/to/.ruby-version)
```

必要なバージョンがないらしい。
というわけなのでrubyのインストールをする。

```console
$ rbenv --version
rbenv 1.1.1
$ brew upgrade rbenv
Error: rbenv 1.1.1 already installed
$ brew upgrade ruby-build
==> Upgrading 1 outdated package:
ruby-build 20181106 -> 20190130
==> Upgrading ruby-build
==> Downloading https://github.com/rbenv/ruby-build/archive/v20190130.tar.gz
==> Downloading from https://codeload.github.com/rbenv/ruby-build/tar.gz/v20190130
######################################################################## 100.0%
==> ./install.sh
🍺  /usr/local/Cellar/ruby-build/20190130: 433 files, 217.3KB, built in 10 seconds
$ rbenv install 2.4.1
$ rbenv global 2.4.1
```

- `ruby-build` `rbenv`を最新に
- `ruby`の必要なバージョンをインストール
-  使うバージョンの指定の変更

をした。これでいける？

```console
$ pod install
rbenv: pod: command not found

The `pod' command exists in these Ruby versions:
  2.3.1
```

まだだめorz
`pod`が2.3.1にしかないっていっているようなのでインストールする

```console
$ gem install cocoapods
Fetching: concurrent-ruby-1.1.4.gem (100%)
Successfully installed concurrent-ruby-1.1.4
Fetching: i18n-0.9.5.gem (100%)
Successfully installed i18n-0.9.5
Fetching: thread_safe-0.3.6.gem (100%)
Successfully installed thread_safe-0.3.6
Fetching: tzinfo-1.2.5.gem (100%)
Successfully installed tzinfo-1.2.5
Fetching: activesupport-4.2.11.gem (100%)
Successfully installed activesupport-4.2.11
Fetching: nap-1.1.0.gem (100%)
Successfully installed nap-1.1.0
Fetching: fuzzy_match-2.0.4.gem (100%)
Successfully installed fuzzy_match-2.0.4
Fetching: cocoapods-core-1.6.1.gem (100%)
Successfully installed cocoapods-core-1.6.1
Fetching: claide-1.0.2.gem (100%)
Successfully installed claide-1.0.2
Fetching: cocoapods-deintegrate-1.0.3.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.3
Fetching: cocoapods-downloader-1.2.2.gem (100%)
Successfully installed cocoapods-downloader-1.2.2
Fetching: cocoapods-plugins-1.0.0.gem (100%)
Successfully installed cocoapods-plugins-1.0.0
Fetching: cocoapods-search-1.0.0.gem (100%)
Successfully installed cocoapods-search-1.0.0
Fetching: cocoapods-stats-1.1.0.gem (100%)
Successfully installed cocoapods-stats-1.1.0
Fetching: netrc-0.11.0.gem (100%)
Successfully installed netrc-0.11.0
Fetching: cocoapods-trunk-1.3.1.gem (100%)
Successfully installed cocoapods-trunk-1.3.1
Fetching: cocoapods-try-1.1.0.gem (100%)
Successfully installed cocoapods-try-1.1.0
Fetching: molinillo-0.6.6.gem (100%)
Successfully installed molinillo-0.6.6
Fetching: atomos-0.1.3.gem (100%)
Successfully installed atomos-0.1.3
Fetching: CFPropertyList-3.0.0.gem (100%)
Successfully installed CFPropertyList-3.0.0
Fetching: colored2-3.1.2.gem (100%)
Successfully installed colored2-3.1.2
Fetching: nanaimo-0.2.6.gem (100%)
Successfully installed nanaimo-0.2.6
Fetching: xcodeproj-1.8.1.gem (100%)
Successfully installed xcodeproj-1.8.1
Fetching: escape-0.0.4.gem (100%)
Successfully installed escape-0.0.4
Fetching: fourflusher-2.2.0.gem (100%)
Successfully installed fourflusher-2.2.0
Fetching: gh_inspector-1.1.3.gem (100%)
Successfully installed gh_inspector-1.1.3
Fetching: ruby-macho-1.4.0.gem (100%)
Successfully installed ruby-macho-1.4.0
Fetching: cocoapods-1.6.1.gem (100%)
Successfully installed cocoapods-1.6.1
Parsing documentation for concurrent-ruby-1.1.4
Installing ri documentation for concurrent-ruby-1.1.4
Parsing documentation for i18n-0.9.5
Installing ri documentation for i18n-0.9.5
Parsing documentation for thread_safe-0.3.6
Installing ri documentation for thread_safe-0.3.6
Parsing documentation for tzinfo-1.2.5
Installing ri documentation for tzinfo-1.2.5
Parsing documentation for activesupport-4.2.11
Installing ri documentation for activesupport-4.2.11
Parsing documentation for nap-1.1.0
Installing ri documentation for nap-1.1.0
Parsing documentation for fuzzy_match-2.0.4
Installing ri documentation for fuzzy_match-2.0.4
Parsing documentation for cocoapods-core-1.6.1
Installing ri documentation for cocoapods-core-1.6.1
Parsing documentation for claide-1.0.2
Installing ri documentation for claide-1.0.2
Parsing documentation for cocoapods-deintegrate-1.0.3
Installing ri documentation for cocoapods-deintegrate-1.0.3
Parsing documentation for cocoapods-downloader-1.2.2
Installing ri documentation for cocoapods-downloader-1.2.2
Parsing documentation for cocoapods-plugins-1.0.0
Installing ri documentation for cocoapods-plugins-1.0.0
Parsing documentation for cocoapods-search-1.0.0
Installing ri documentation for cocoapods-search-1.0.0
Parsing documentation for cocoapods-stats-1.1.0
Installing ri documentation for cocoapods-stats-1.1.0
Parsing documentation for netrc-0.11.0
Installing ri documentation for netrc-0.11.0
Parsing documentation for cocoapods-trunk-1.3.1
Installing ri documentation for cocoapods-trunk-1.3.1
Parsing documentation for cocoapods-try-1.1.0
Installing ri documentation for cocoapods-try-1.1.0
Parsing documentation for molinillo-0.6.6
Installing ri documentation for molinillo-0.6.6
Parsing documentation for atomos-0.1.3
Installing ri documentation for atomos-0.1.3
Parsing documentation for CFPropertyList-3.0.0
Installing ri documentation for CFPropertyList-3.0.0
Parsing documentation for colored2-3.1.2
Installing ri documentation for colored2-3.1.2
Parsing documentation for nanaimo-0.2.6
Installing ri documentation for nanaimo-0.2.6
Parsing documentation for xcodeproj-1.8.1
Installing ri documentation for xcodeproj-1.8.1
Parsing documentation for escape-0.0.4
Installing ri documentation for escape-0.0.4
Parsing documentation for fourflusher-2.2.0
Installing ri documentation for fourflusher-2.2.0
Parsing documentation for gh_inspector-1.1.3
Installing ri documentation for gh_inspector-1.1.3
Parsing documentation for ruby-macho-1.4.0
Installing ri documentation for ruby-macho-1.4.0
Parsing documentation for cocoapods-1.6.1
Installing ri documentation for cocoapods-1.6.1
Done installing documentation for concurrent-ruby, i18n, thread_safe, tzinfo, activesupport, nap, fuzzy_match, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, netrc, cocoapods-trunk, cocoapods-try, molinillo, atomos, CFPropertyList, colored2, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho, cocoapods after 55 seconds
28 gems installed
```

今度こそ...

```console
$ pod install
Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "RealmSwift":
  In Podfile:
    RealmSwift (~> 3.7.0)

None of your spec sources contain a spec satisfying the dependency: `RealmSwift (~> 3.7.0)`.

You have either:
 * out-of-date source repos which you can update with `pod repo update` or with `pod install --repo-update`.
 * mistyped the name or version.
 * not added the source repo that hosts the Podspec to your Podfile.

Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by default.
```

よくわからないけど

> out-of-date source repos which you can update

とのことだから何かの情報のupdateが必要っぽい。

```console
$ rbenv rehash
$ pod setup
Setting up CocoaPods master repo
  $ /usr/local/bin/git -C /path/to/.cocoapods/repos/master fetch origin --progress
  remote: Enumerating objects: 103056, done.
  remote: Counting objects: 100% (103056/103056), done.
  remote: Compressing objects: 100% (91/91), done.
  remote: Total 1855298 (delta 102979), reused 102993 (delta 102957), pack-reused 1752242
  Receiving objects: 100% (1855298/1855298), 249.35 MiB | 1.83 MiB/s, done.
  Resolving deltas: 100% (1255419/1255419), completed with 10205 local objects.
  From https://github.com/CocoaPods/Specs
     23cb22d5917..f89a55a3dc3 master                -> origin/master
   * [new branch]            backz                 -> origin/backz
   * [new branch]            cdn_scripts           -> origin/cdn_scripts
   * [new branch]            swift_version_support -> origin/swift_version_support
  $ /usr/local/bin/git -C /path/to/.cocoapods/repos/master rev-parse --abbrev-ref
  HEAD
  master
  $ /usr/local/bin/git -C /path/to/.cocoapods/repos/master reset --hard origin/master
  Checking out files: 100% (182648/182648), done.
  HEAD is now at f89a55a3dc3 [Add] Debugo 0.1.0
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renameLimit variable to at least 180262 and retry the command.
Setup completed
```

これでどうだ！

```console
$ pod install
Analyzing dependencies
Downloading dependencies
Installing Alamofire (4.8.1)
Installing CryptoSwift (0.14.0)
Installing ObjectMapper (3.4.2)
Installing Realm (3.7.6)
Installing RealmSwift (3.7.6)
Installing SVProgressHUD (2.2.5)
Installing SwiftyAttributes (5.0.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 6 dependencies from the Podfile and 7 total pods installed.
```

できた！ (∩´∀｀)∩ﾜｰｲ