TruffleRubyのオプションとコマンドライン
TruffleRubyのコマンドライン・インタフェースは、互換性があるMRIバージョンのものと同じになります。
Usage: truffleruby [switches] [--] [programfile] [arguments]
-0[octal] specify record separator (\0, if no argument)
-a autosplit mode with -n or -p (splits $_ into $F)
-c check syntax only
-Cdirectory cd to directory before executing your script
-d, --debug set debugging flags (set $DEBUG to true)
-e 'command' one line of script. Several -e's allowed. Omit [programfile]
-Eex[:in], --encoding=ex[:in]
specify the default external and internal character encodings
-Fpattern split() pattern for autosplit (-a)
-i[extension] edit ARGV files in place (make backup if extension supplied)
-Idirectory specify $LOAD_PATH directory (may be used more than once)
-l enable line ending processing
-n assume 'while gets(); ... end' loop around your script
-p assume loop like -n but print line also like sed
-rlibrary require the library before executing your script
-s enable some switch parsing for switches after script name
-S look for the script using PATH environment variable
-v print the version number, then turn on verbose mode
-w turn warnings on for your script
-W[level=2|:category]
set warning level; 0=silence, 1=medium, 2=verbose
-x[directory] strip off text before #!ruby line and perhaps cd to directory
--copyright print the copyright
--enable={gems|rubyopt|...}[,...], --disable={gems|rubyopt|...}[,...]
enable or disable features. see below for available features
--external-encoding=encoding, --internal-encoding=encoding
specify the default external or internal character encoding
--verbose turn on verbose mode and disable script from stdin
--version print the version number, then exit
--help show this message, -h for short message
--backtrace-limit=num
limit the maximum length of backtrace
Features:
gems rubygems (default: enabled)
did_you_mean did_you_mean (default: enabled)
rubyopt RUBYOPT environment variable (default: enabled)
frozen-string-literal
freeze all string literals (default: disabled)
Warning categories:
deprecated deprecated features
experimental experimental features
また、TruffleRubyをRubyランチャから実行する場合、標準のRubyと同様にRUBYOPT
環境変数が読み取られます。
リストされないRubyスイッチ
MRIには、ヘルプ出力には通常リストされないが、Rubyのマニュアル・ページに記載されている追加のRubyスイッチがいくつかあります。
-Xdirectory cd to directory before executing your script (same as -C)
-U set the internal encoding to UTF-8
-K[EeSsUuNnAa] sets the source and external encoding
--encoding=external[:internal]
the same as --external-encoding=external and optionally --internal-encoding=internal
TruffleRubyのオプション
TruffleRubyのオプションは、--option=value
を使用して設定します。また、任意のランチャから--ruby.option=value
を使用することもできます。=value
を省略すると、true
に設定できます。
使用可能なオプションとドキュメントは、--help:languages
で確認できます。また、--help:expert
および--help:internal
を設定すると、それらのカテゴリのオプションが表示されます。オプションはすべて試験段階にあり、随時変更される可能性があります。
オプションをJVMシステム・プロパティとして設定することもでき、その場合は接頭辞polyglot.ruby.
が付きます。たとえば、--vm.Dpolyglot.ruby.cexts.remap=true
や、JVMシステム・プロパティを設定する他の方法を使用できます。最後に、オプションをGraalVMポリグロットAPIの構成オプションとして設定できます。
オプションの優先順位は、最初にコマンドライン、次にGraal-SDKポリグロットAPI構成、最後にシステム・プロパティという順です。
また、従来のRubyのオプションとVMのオプションに加えて、TruffleRubyのオプションも、Rubyランチャから実行する場合はTRUFFLERUBYOPT
およびRUBYOPT
環境変数で設定できます。
--
またはオプションでない最初の引数は、Rubyの引数の処理を停止するのと同様に、TrufflRubyおよびVMのオプションの処理を停止します。
VMのオプション
基礎となるVMのオプションを設定するには、ネイティブ構成とJVM構成の両方に有効な--vm.
を使用します。たとえば、--vm.Dsystem_property=value
や--vm.ea
です。
クラスパスを設定するには、2つの別個の引数ではなく、=
表記を使用します。たとえば、--vm.cp=lib.jar
や--vm.classpath=lib.jar
です。
他のバイナリのスイッチ
irb
、gem
などの他のバイナリでは、標準のRubyとまったく同じスイッチがサポートされています。
TruffleRubyホームの特定
TruffleRubyは、標準ライブラリなどのファイルをどこで探すかを認識している必要があります。これらは、TruffleRubyホーム・ディレクトリに格納されます。Rubyホームは、常に、Truffleフレームワークの報告先となります。
Rubyホームが正しいとみなされないか設定されていない場合、警告が表示されますが、プログラムは続行し、標準ライブラリを要求できなくなります。no-home-provided
オプションを使用すると、ホームを一切探さないようにTruffleRubyに指示できます。