Experimental feature in 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.java.net.cn/dev/reference-manual/llvm/
  ruby        Ruby                    https://graalvm.java.net.cn/ruby/

Tools:
  [id]        [name]                  [website]
  agentscript Agent Script            
  coverage    Code Coverage           https://graalvm.java.net.cn/tools/code-coverage/
  cpusampler  CPU Sampler             https://graalvm.java.net.cn/tools/profiling/
  cputracer   CPU Tracer              https://graalvm.java.net.cn/tools/profiling/
  dap         Debug Protocol Server   https://graalvm.java.net.cn/tools/dap/
  heap        Heap Dump               
  heapmonitor Heap Allocation Monitor 
  insight     Insight                 https://graalvm.java.net.cn/tools/graalvm-insight/
  inspect     Chrome Inspector        https://graalvm.java.net.cn/tools/chrome-debugger/
  lsp         Language Server         https://graalvm.java.net.cn/tools/lsp/
  memtracer   Memory Tracer           https://graalvm.java.net.cn/tools/profiling/

  Use --help:[id] for component options.

See https://graalvm.java.net.cn for more information.

如果从 Ruby 启动器运行,TruffleRuby 也会读取 `RUBYOPT` 环境变量,就像标准 Ruby 一样。

未列出的 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 配置,最后是系统属性。

TruffleRuby 选项以及传统的 Ruby 选项和 VM 选项也可以在 `TRUFFLERUBYOPT` 和 `RUBYOPT` 环境变量中设置,如果从 Ruby 启动器运行。

-- 或第一个非选项参数会停止处理 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 主目录似乎不正确,或未设置,将抛出异常。

联系我们