- 適用於 JDK 23 的 GraalVM (最新版)
- 適用於 JDK 24 的 GraalVM (搶先體驗版)
- 適用於 JDK 21 的 GraalVM
- 適用於 JDK 17 的 GraalVM
- 封存
- 開發建置
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={jit|rubyopt|...}[,...], --disable={jit|rubyopt|...}[,...]
enable or disable features. see below for available features
--external-encoding=encoding, --internal-encoding=encoding
specify the default external or internal character encoding
--backtrace-limit=num
limit the maximum length of backtrace
--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
Features:
gems rubygems (only for debugging, default: enabled)
error_highlight error_highlight (default: enabled)
did_you_mean did_you_mean (default: enabled)
syntax_suggest syntax_suggest (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
Runtime options:
--polyglot Run with all other guest languages accessible.
--native Run using the native launcher with limited access to Java libraries
(default).
--jvm Run on the Java Virtual Machine with access to Java libraries.
--vm.[option] Pass options to the host VM. To see available options, use '--help:vm'.
--log.file=<String> Redirect guest languages logging into a given file.
--log.[logger].level=<String> Set language log level to OFF, SEVERE, WARNING, INFO, CONFIG, FINE,
FINER, FINEST or ALL.
--help Print this help message.
--help:vm Print options for the host VM.
--help:engine Print engine options.
--help:compiler Print engine compiler options.
--help:all Print all options.
--version:graalvm Print GraalVM version information and exit.
--show-version:graalvm Print GraalVM version information and continue execution.
Languages:
[id] [name] [website]
llvm LLVM https://graalvm.dev.org.tw/dev/reference-manual/llvm/
ruby Ruby https://graalvm.dev.org.tw/ruby/
Tools:
[id] [name] [website]
agentscript Agent Script
coverage Code Coverage https://graalvm.dev.org.tw/tools/code-coverage/
cpusampler CPU Sampler https://graalvm.dev.org.tw/tools/profiling/
cputracer CPU Tracer https://graalvm.dev.org.tw/tools/profiling/
dap Debug Protocol Server https://graalvm.dev.org.tw/tools/dap/
heap Heap Dump
heapmonitor Heap Allocation Monitor
insight Insight https://graalvm.dev.org.tw/tools/graalvm-insight/
inspect Chrome Inspector https://graalvm.dev.org.tw/tools/chrome-debugger/
lsp Language Server https://graalvm.dev.org.tw/tools/lsp/
memtracer Memory Tracer https://graalvm.dev.org.tw/tools/profiling/
Use --help:[id] for component options.
See https://graalvm.dev.org.tw for more information.
如果從 Ruby 啟動器執行,TruffleRuby 也會如標準 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 啟動器執行,TruffleRuby 選項以及傳統的 Ruby 選項和 VM 選項也可以在 TRUFFLERUBYOPT
和 RUBYOPT
環境變數中設定。
--
或第一個非選項引數會停止處理 TrufflRuby 和 VM 選項,其方式與停止處理 Ruby 引數的方式相同。
VM 選項 #
若要在底層 VM 中設定選項,請使用 --vm.
,這對於原生組態和 JVM 組態都有效。例如,--vm.Dsystem_property=value
或 --vm.ea
。
若要設定類別路徑,請使用 =
表示法,而不是兩個不同的引數。例如,--vm.cp=lib.jar
或 --vm.classpath=lib.jar
。
其他二進位開關 #
其他二進位檔,例如 irb
、gem
等,與標準 Ruby 支援完全相同的開關。
判斷 TruffleRuby 首頁 #
TruffleRuby 需要知道標準程式庫等檔案的所在位置。這些檔案儲存在 TruffleRuby 首頁目錄中。Ruby 首頁一律是 Truffle 框架回報的,或是解壓縮的內部資源。
如果 Ruby 首頁看起來不正確或未設定,則會擲回例外。