macOS で実行するための最適な開発環境インストール方法は?

Discourse を macOS 上で開発用としてインストールする際の現在の考え方とアプローチはどうなっていますか?公式 GitHub のドキュメントに記載されている手順に従ってインストールを試みました(Beginners Guide to Install Discourse on macOS for Development)が、うまくいきませんでした。

cppjieba_rb-0.3.3 gem のインストール時に 3 つのエラーが報告されました。

最近、同じような経験をした方はいますか?

gem install cppjieba_rb の出力は何ですか?

~/Developer/localhost/discourse on  master sudo gem install cppjieba_rb -v '0.3.3' --source 'https://rubygems.org/'             at 17:13:33
パスワード:
ネイティブ拡張をビルド中。これには時間がかかる場合があります...
エラー: cppjieba_rb のインストール中にエラーが発生しました:
	エラー: gem ネイティブ拡張のビルドに失敗しました。

    現在のディレクトリ: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20191021-73798-k500fk.rb extconf.rb
Makefile を作成中

    現在のディレクトリ: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb
make "DESTDIR=" clean

    現在のディレクトリ: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb
make "DESTDIR="
cppjieba_rb.c をコンパイル中
internal.cc をコンパイル中
含まれているファイル: internal.cc:1
含まれているファイル: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33
含まれているファイル: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19/ruby/config.h:413:31: エラー: リテラルに無効な接尾辞; C++11 ではリテラルと識別子の間にスペースが必要です [-Wreserved-user-defined-literal]
#define RUBY_ARCH "universal-"RUBY_PLATFORM_OS
                              ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19/ruby/config.h:414:35: エラー: リテラルに無効な接尾辞; C++11 ではリテラルと識別子の間にスペースが必要です [-Wreserved-user-defined-literal]
#define RUBY_PLATFORM "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
                                  ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19/ruby/config.h:414:55: エラー: リテラルに無効な接尾辞; C++11 ではリテラルと識別子の間にスペースが必要です [-Wreserved-user-defined-literal]
#define RUBY_PLATFORM "universal."RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
                                                      ^

含まれているファイル: internal.cc:1
含まれているファイル: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33
含まれているファイル: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:2111
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/intern.h:56:19: 警告: 'register' ストレージクラス指定子は非推奨であり、C++17 と互換性がありません [-Wdeprecated-register]
void rb_mem_clear(register VALUE*, register long);
                  ^~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/intern.h:56:36: 警告: 'register' ストレージクラス指定子は非推奨であり、C++17 と互換性がありません [-Wdeprecated-register]
void rb_mem_clear(register VALUE*, register long);
                                   ^~~~~~~~~
含まれているファイル: internal.cc:8
含まれているファイル: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/include/cppjieba/Jieba.hpp:4
含まれているファイル: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/include/cppjieba/QuerySegment.hpp:8
含まれているファイル: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/include/cppjieba/DictTrie.hpp:13
/Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/deps/limonp/StringUtil.hpp:87:70: 警告: 'ptr_fun<unsigned int, bool>' は非推奨です [-Wdeprecated-declarations]
  s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<unsigned, bool>(IsSpace))));
                                                                     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1097:1: 注: 'ptr_fun<unsigned int, bool>' はここで明示的に非推奨としてマークされています
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:1101:39: 注: マクロ '_LIBCPP_DEPRECATED_IN_CXX11' から展開されました
#  define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
                                      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:1090:48: 注: マクロ '_LIBCPP_DEPRECATED' から展開されました
#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
                                               ^
含まれているファイル: internal.cc:8
含まれているファイル: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/include/cppjieba/Jieba.hpp:4
含まれているファイル: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/include/cppjieba/QuerySegment.hpp:8
含まれているファイル: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/include/cppjieba/DictTrie.hpp:13
/Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/deps/limonp/StringUtil.hpp:92:61: 警告: 'ptr_fun<unsigned int, bool>' は非推奨です [-Wdeprecated-declarations]
  s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<unsigned, bool>(IsSpace))).base(), s.end());
                                                            ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1097:1: 注: 'ptr_fun<unsigned int, bool>' はここで明示的に非推奨としてマークされています
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:1101:39: 注: マクロ '_LIBCPP_DEPRECATED_IN_CXX11' から展開されました
#  define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
                                      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:1090:48: 注: マクロ '_LIBCPP_DEPRECATED' から展開されました
#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
                                               ^
含まれているファイル: internal.cc:8
含まれているファイル: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/include/cppjieba/Jieba.hpp:4
含まれているファイル: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/include/cppjieba/QuerySegment.hpp:8
含まれているファイル: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/include/cppjieba/DictTrie.hpp:13
/Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/deps/limonp/StringUtil.hpp:101:70: 警告: 'bind2nd<std::__1::equal_to<char>, char>' は非推奨です [-Wdeprecated-declarations]
  s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::bind2nd(std::equal_to<char>(), x))));
                                                                     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1079:1: 注: 'bind2nd<std::__1::equal_to<char>, char>' はここで明示的に非推奨としてマークされています
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:1101:39: 注: マクロ '_LIBCPP_DEPRECATED_IN_CXX11' から展開されました
#  define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
                                      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:1090:48: 注: マクロ '_LIBCPP_DEPRECATED' から展開されました
#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
                                               ^
含まれているファイル: internal.cc:8
含まれているファイル: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/include/cppjieba/Jieba.hpp:4
含まれているファイル: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/include/cppjieba/QuerySegment.hpp:8
含まれているファイル: /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/include/cppjieba/DictTrie.hpp:13
/Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3/ext/cppjieba_rb/../cppjieba/deps/limonp/StringUtil.hpp:106:61: 警告: 'bind2nd<std::__1::equal_to<char>, char>' は非推奨です [-Wdeprecated-declarations]
  s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::bind2nd(std::equal_to<char>(), x))).base(), s.end());
                                                            ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/functional:1079:1: 注: 'bind2nd<std::__1::equal_to<char>, char>' はここで明示的に非推奨としてマークされています
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:1101:39: 注: マクロ '_LIBCPP_DEPRECATED_IN_CXX11' から展開されました
#  define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
                                      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:1090:48: 注: マクロ '_LIBCPP_DEPRECATED' から展開されました
#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
                                               ^
6 件の警告と 3 件のエラーが発生しました。
make: *** [internal.o] エラー 1

make に失敗しました。終了コード 2

Gem ファイルは検査のために /Library/Ruby/Gems/2.6.0/gems/cppjieba_rb-0.3.3 にインストールされたままになります。
結果は /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/cppjieba_rb-0.3.3/gem_make.out に記録されました。

これ、解決しましたか?bash から zsh に切り替えた際、rbenv の設定を忘れて同じ問題にぶつかりました。rbenv を再び使うようにしたら、すべて元に戻りました。

macOS のシステム Ruby は、時々問題を起こすようです。

私にはわかりませんでした。Discourse 依存関係インストールスクリプトの一部として、rbenv のインストール以外に何か追加しましたか?他に指示がないため、私はそれだけを行いました。

私の開発環境はだいぶ前に設定したので、確信がありません。当時、特別なことをした覚えはないのですが、その間に macOS に何か変更があったかもしれません。

rbenv が設定されているか確認できます。nano ~/.bash_profile を実行すると、以下のような内容が表示されるはずです。

# load rbenv
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init - --no-rehash)"

また、rbenv versions を実行して、現在選択されているバージョン(アスタリスクが付いている方)を確認することもできます。もし system になっている場合は変更が必要です。私の環境では 2.6.1 が正常に動作しています(rbenv install 2.6.1 の後、rbenv global 2.6.1 を実行してください)。