システム情報
- OS: macOS Catalina 10.15.4(19E287)
- mruby version: master(84aad399) (2020年5月5日現在)
- Bison version: 3.5.4
概要
macOS で mruby をビルドして Hello World する。ハマりどころとして、macOS の Bison が古すぎてエラーになることがある。
clone & rake test
$ git clone git@github.com:mruby/mruby.git
$ cd mruby
$ rake test
...
>>> Test test <<<
mrbtest - Embeddable Ruby Test
...
Skip: File.expand_path (with ENV) (mrbgems: mruby-io)
Skip: IO#pread => IO#pread is not implemented on this configuration (mrbgems: mruby-io)
Skip: IO#pwrite => IO#pwrite is not implemented on this configuration (mrbgems: mruby-io)
Total: 1239
OK: 1236
KO: 0
Crash: 0
Warning: 0
Skip: 3
Time: 0.79 seconds
>>> Bintest test <<<
bintest - Command Binary Test
........................................................
Total: 56
OK: 56
KO: 0
Crash: 0
Warning: 0
Skip: 0
Time: 1.3 seconds
Hello World
$ rake -v $ ./bin/mirb mirb - Embeddable Interactive Ruby Shell > print "hello world!" hello world! => nil
Bison バージョンについて
Bison バージョンが古いと以下のエラーとなった
bison -o "/Users/kentaro/projects/mruby/build/host/mrbgems/mruby-compiler/core/y.tab.c" "/Users/kentaro/projects/mruby/mrbgems/mruby-compiler/core/parse.y" /Users/kentaro/projects/mruby/mrbgems/mruby-compiler/core/parse.y:1333.9-16: syntax error, unexpected identifier, expecting string bison -o "/Users/kentaro/projects/mruby/build/host/mrbgems/mruby-compiler/core/y.tab.c" "/Users/kentaro/projects/mruby/mrbgems/mruby-compiler/core/parse.y" /Users/kentaro/projects/mruby/mrbgems/mruby-compiler/core/parse.y:1333.9-16: syntax error, unexpected identifier, expecting string
ログ全体は ここ。
エラーが発生した Bison は
$ /usr/bin/bison --version bison (GNU Bison) 2.3
通った Bison は
/usr/local/opt/bison/bin/bison --version bison (GNU Bison) 3.5.4
新しい Bison は brew install bison で入れて PATH を通しておく必要がある。