Wordmoveを実行できるようにする

# 参考記事
[wordmoveのMovefileのエラーを解決してみた in さくらレンタルサーバ](https://qiita.com/hiro93n/items/7a23cac716db0a863203)
[Wordmoveの基本操作](https://qiita.com/mrymmh/items/c644934cac386d95b7df)
[wordmoveを使ってWordPressサーバのデータを開発機に再現](https://qiita.com/akiko-pusu/items/43d87896a518233d9503)
[gemのupdateがopensslのせいで通らない](https://www.takasay.com/entry/2014/11/22/080000)
[brew link openssl --force ができなくて phpenv & php-build で PHP がビルドできない](https://qiita.com/chatii0079/items/b30cf35c4ec9bdf8dd70)
[macOS High Sierra（OSX）のOpenSSLをデフォルトのLibreSSLからOpenSSLに変更する](https://qiita.com/moroi/items/53d60d1d6885795a0f6f)
[rbenvの使い方と仕組みについて](https://qiita.com/Kodak_tmo/items/73147ed4f0eec54d6e94)

# wordmoveの実行

`wordmove`コマンドを実行すると、以下のようになる。

```
> % wordmove pull -e staging -u
Traceback (most recent call last):
	31: from /Users/user_name/.rbenv/versions/2.6.1/bin/wordmove:23:in `<main>'
	30: from /Users/user_name/.rbenv/versions/2.6.1/bin/wordmove:23:in `load'
	29: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/wordmove-4.0.0/exe/wordmove:5:in `<top (required)>'
	28: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	27: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	26: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/wordmove-4.0.0/lib/wordmove.rb:16:in `<top (required)>'
	25: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	24: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	23: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/photocopier-1.3.2/lib/photocopier.rb:5:in `<top (required)>'
	22: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	21: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	20: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/net-sftp-2.1.2/lib/net/sftp.rb:1:in `<top (required)>'
	19: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	18: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	17: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/net-ssh-4.2.0/lib/net/ssh.rb:11:in `<top (required)>'
	16: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	15: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	14: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/net-ssh-4.2.0/lib/net/ssh/transport/session.rb:6:in `<top (required)>'
	13: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	12: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	11: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/net-ssh-4.2.0/lib/net/ssh/transport/algorithms.rb:1:in `<top (required)>'
	10: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 9: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 8: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/net-ssh-4.2.0/lib/net/ssh/buffer.rb:2:in `<top (required)>'
	 7: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 6: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 5: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/net-ssh-4.2.0/lib/net/ssh/transport/openssl.rb:2:in `<top (required)>'
	 4: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 3: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	 2: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/openssl.rb:13:in `<top (required)>'
	 1: from /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': dlopen(/Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/x86_64-darwin18/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
  Referenced from: /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/x86_64-darwin18/openssl.bundle
  Reason: image not found - /Users/user_name/.rbenv/versions/2.6.1/lib/ruby/2.6.0/x86_64-darwin18/openssl.bundle
```

LoadErrorによってコマンド正常に実行されていない様子。。。
どうやらOpenSSLが機能していないらしい。

# brewでopenSSLをリンクさせる

[gemのupdateがopensslのせいで通らない](https://www.takasay.com/entry/2014/11/22/080000)
[brew link openssl --force ができなくて phpenv & php-build で PHP がビルドできない](https://qiita.com/chatii0079/items/b30cf35c4ec9bdf8dd70)

```
$ brew link openssl --force
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
  -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
```

「opnsslにリンクすることを拒否しています。」という警告文が出た。
opensslが存在していないか、存在していても認識されていないかのどちらかであることが推測できる。

# 使用されているOpenSSLを確認する

[macOS High Sierra（OSX）のOpenSSLをデフォルトのLibreSSLからOpenSSLに変更する](https://qiita.com/moroi/items/53d60d1d6885795a0f6f)

```
$ openssl version
LibreSSL 2.2.7
```

デフォルトのopenSSLが`LibreSSL`になっている。


# OpenSSLを「LibreSSL」から「OpenSSL」に変更する
## HomebrewでOpenSSLをインストール

```
$ brew install openssl
```

## opensslの情報を確認する 

```
$ brew info openssl
openssl: stable 1.0.2o (bottled) [keg-only]
SSL/TLS cryptography library
https://openssl.org/
/usr/local/Cellar/openssl/1.0.2o_1 (1,791 files, 12.3MB)
  Poured from bottle on 2018-05-08 at 15:22:23
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/openssl.rb
==> Dependencies
Build: makedepend ✘
==> Options
--without-test
    Skip build-time tests (not recommended)
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
```

>If you need to have this software first in your PATH run:
>（意訳：もしあなたがこのソフトウェアを優先したい場合は実行）

```
$ echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
```

上記のコマンドでOpenSSLでパスを通す。
ターミナルを再起動する。

```
$ openssl version
OpenSSL 1.0.2o  27 Mar 2018
```

OpenSSLに変更された。

# Rubyのバージョンを確認する

```
> % rbenv versions
  system
* 2.6.1 (set by /Users/user_name/.rbenv/version)
```

# Rubyを再インストールする

```
> % env CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline` --with-openssl-dir=`brew --prefix openssl`" rbenv install -f 2.6.1
ruby-build: use openssl from homebrew
Downloading ruby-2.6.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.1.tar.bz2
Installing ruby-2.6.1...
ruby-build: use readline from homebrew
Installed ruby-2.6.1 to /Users/kengokakeshita/.rbenv/versions/2.6.1
```

# rbenvのインストール→指定したRubyのバージョンをインストールする手順

```
// 1.初期化設定
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
// 2.初期化設定の反映
$ source ~/.bash_profile
// 3.rbenvのインストール：
$ brew install rbenv ruby-build
// 4.インストール可能なRubyのバージョン一覧の表示
$ rbenv install -l
// 5.指定したRubyのバージョンをインストール
$ rbenv install 2.3.5
// 6.インストールしたRubyを使用可能な状態にする⇒shimsへの反映
$ rbenv rehash
```
# shims(rbenv rehash)について
```
// "rbenv which コマンド名"を使って、コマンドの参照先のバージョンが変わっている事を確認してみる。
// rubyコマンドの参照先を確認(rubyコマンドの参照先がバージョン2.3.5を向いている事を確認)
$ rbenv which ruby
~/.rbenv/versions/2.3.5/bin/ruby
// rubyのバージョンを切り替え
$ rbenv global 2.5.0-dev
// rubyコマンドの参照先が変わった事を確認
$ rbenv which ruby
~/.rbenv/versions/2.5.0-dev/bin/ruby
```

# wordmoveコマンドの実行

```
-> % wordmove
Commands:
  wordmove --version, -v   # Print the version
  wordmove doctor          # Do some local configuration and environment checks
  wordmove help [COMMAND]  # Describe available commands or one specific command
  wordmove init            # Generates a brand new movefile.yml
  wordmove pull            # Pulls WP data from remote host to the local machine
  wordmove push            # Pushes WP data from local machine to remote host
```

エラーは出ていないので、wordmoveコマンド自体は正常に実行されているようです。