macOSのアップデートを見越して標準のスクリプトランタイムに依存せずHomeBrewが手軽に入るか検証してみた

macOS 10.15以降で標準では同梱されなくなる予定のスクリプトランタイムについて、HomeBrewの設定にどのくらいの影響を及ぼすのか、手元の環境を崩しながら確認してみました。
2019.06.10

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

はじめに

AppleがmacOS 10.15 Beta Release NotesにてScripting Language Runtimesに関するアップデートを発表しました。

Scripting language runtimes such as Python, Ruby, and Perl are included in macOS for compatibility with legacy software. Future versions of macOS won’t include scripting language runtimes by default, and might require you to install additional packages.

もともとシステムで入っていたバージョンは動作に影響することを考えて使っていなかったのですが、HomeBrewの導入には欠かせないものでした。将来的に導入の前提としてランタイムを入れる必要が発生します。

個人的にHomeBrewに依存していることもあり、念の為標準ランタイムに依存せずにHomeBrewの導入が現状でも手軽にこなせるか、手元の環境を崩しつつ確認してみました。

導入方法

各種ダウンロードは、macOSで初期から入っているcurlで行います。また、あくまでも手軽く行えるかという1点のため、インストール時の指定オプションが不明だった場合に踏み入った検証までは行いません。

導入手順

HomeBrewのインストール手順は以下の通りです。

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

つまり現時点ではRubyが必須です。そしてRubyは現在のmacOSの素のライブラリのみだと入りません。よって、以下の流れになります。

  1. Rubyの関連ライブラリインストール
  2. Rubyのソースコードによるインストール
  3. HomeBrewのインストール

関連ライブラリのインストール

まずは無難にXcode Command Line Toolsを入れます。

xcode-select --install

そして、試しにRubyのソースコードをダウンロードし、makeコマンドを実行すると、ライブラリが不足している為にインストール出来ないことが分かります。

今回最初に引っかかったgdbmについて検索してみたところ、HomeBrewに依存する形でのインストール例が主となりました。

brew install gdbm

止む無くソースコードをダウンロードした上でのビルドも試みましたが、手軽くとは行かないようです。

% ./configure
% make
..
..
In file included from input-rl.c:17:
In file included from ./gdbmtool.h:19:
In file included from ./gdbmdefs.h:21:
./gdbmconst.h:58:9: warning: 'SIZE_T_MAX' macro redefined [-Wmacro-redefined]
#define SIZE_T_MAX ((size_t)-1)
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/i386/limits.h:98:9: note: 
      previous definition is here
#define SIZE_T_MAX      ULONG_MAX       /* max value for a size_t */
        ^
input-rl.c:117:11: warning: implicit declaration of function 'history_list' is
      invalid in C99 [-Wimplicit-function-declaration]
  hlist = history_list ();
          ^
input-rl.c:117:9: warning: incompatible integer to pointer conversion assigning
      to 'HIST_ENTRY **' (aka 'struct _hist_entry **') from 'int'
      [-Wint-conversion]
  hlist = history_list ();
        ^ ~~~~~~~~~~~~~~~
input-rl.c:167:21: warning: incompatible pointer types assigning to 'Function *'
      (aka 'int (*)(const char *, int)') from 'int (void)'
      [-Wincompatible-pointer-types]
  rl_pre_input_hook = pre_input;
                    ^ ~~~~~~~~~
4 warnings generated.
  CCLD     gdbmtool
Undefined symbols for architecture x86_64:
  "_history_list", referenced from:
      _input_history_handler in input-rl.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [gdbmtool] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

まとめ

HomeBrew公式Twitterにて以下の通りフォローがなされており、HomeBrewに依存した環境を利用している方で導入の手間をなるだけ抑えたい場合は今後も注視すべきだと思います。

また、今回のような検証を手元の環境で試される場合は、shellのrcファイル及びbrewfileでのバックアップ作成、shellをbashへの事前変更をおすすめします。

brewfile

brew install rcmdnk/file/brew-file
brew file init