Command Line Reference
This page shows the srb tc --help output for the latest version of Sorbet.
See Command Line Quickstart for an overview of some of the more common options and workflows.
See
srb tc --helpto see the help options for your version of Sorbet. (New options are added and changed all the time.)
Usage
Sorbet: A fast, powerful typechecker designed for Ruby
Usage:
sorbet [options] [[--] <path>...]
INPUT options
-e <string> Treat <string> as if it were the contents of a Ruby file
passed on the command line (default: "")
--e-rbi <string> Like `-e`, but treat <string> as an RBI file (default:
"")
--file <path>[,<path>...]
Run over the contents of <path> (repeatable)
(Equivalent to passing <path> as a positional argument)
--dir <path>[,<path>...] Run over all Ruby and RBI files in <path>, recursively
(repeatable)
(Equivalent to passing <path> as a positional argument)
--allowed-extension <ext>[,<ext>...]
Inside directories, only discover files ending in <ext>.
Passing this option replaces the default list.
(repeatable) (default: .rb,.rbi)
--ignore <pattern>[,<pattern>...]
Ignores input files that contain <pattern> in their paths
(relative to the input path passed to Sorbet).
When <pattern> starts with `/` it matches against the
prefix of these relative paths; others match anywhere.
Matches must be against whole path segments, so `foo`
matches `foo/bar.rb` and `bar/foo/baz.rb` but not
`foo.rb` or `foo2/bar.rb`. (repeatable)
--no-config Do not load the content of the `sorbet/config` file.
Otherwise, Sorbet reads the `sorbet/config` file and
treats each line as if it were passed on the command
line, unless the line starts with `#`.
To load a <file> as if it were a config file, pass
`@<file>` as a positional arg
--typed {false,true,strict,strong,[auto]}
Force all code to specified strictness level,
disregarding all `# typed:` sigils. For `auto`, uses the
`# typed:` sigil in the file or `false` for files without
a sigil. (default: auto)
--typed-override <filepath.yaml>
Read <filepath.yaml> to override the strictness of
individual files.
Contents must be a map of `<strictness>: ['path1.rb',
...]` pairs.
Can be used to enable type checking for certain files
temporarily without having to add a comment to every
file. (default: "")
OUTPUT options
-q, --quiet Silence all non-critical errors
-P, --progress Draw progressbar
--color {always,never,[auto]}
Use color output. For `auto`: use color if stderr is a
tty (default: auto)
--no-error-count Do not print the `Errors: <N>` summary line
--no-error-sections Only print the first line of every error message
(suppress any additional information below an error). Can
provide substantial speedups when dealing with many
errors
--error-url-base <url-base>
Every error message includes a link created by prefixing
that error's code with <url-base>. Can be used to
maintain docs on Sorbet error codes which are more
relevant to a specific project or company. (default:
https://srb.help/)
--remove-path-prefix <prefix>
Remove the provided <prefix> from all printed paths.
Defaults to the input directory passed to Sorbet, if any.
(default: "")
--gen-packages [={normal,strict}(=normal)]
Generate package information (normal or strict)
AUTOCORRECT options
-a, --autocorrect Auto-correct source files with suggested fixes.
Use the `--{isolate,suppress}-error-code` options to
control which corrections to apply
--suggest-unsafe [=<method>(=T.unsafe)]
Include 'unsafe' autocorrects, e.g. those which can be
fixed by wrapping code in `T.unsafe` or using
`T.untyped`. Provide a custom <method> to wrap with
`<method>(...)` instead of `T.unsafe(...)`. This
supersedes certain autocorrects, especially T.must.
--did-you-mean Whether to include 'Did you mean' suggestions in
autocorrects. For large codemods, it's usually better to
avoid spurious changes by setting this to false (default:
true)
--suggest-typed Emit autocorrects to set the `# typed:` sigil in every
file to the highest possible level where no errors would
be reported in that file. Will downgrade the `# typed:`
sigil for any files with errors.
ERROR options
--typed-super Enable typechecking of `super` calls when possible
(default: true)
--check-out-of-order-constant-references
Detect when a constant is referenced early in a file, but
defined later in that file. Does not detect out-of-order
references across file boundaries.
--isolate-error-code <error-code>[,<error-code>...]
Only report errors with code <error-code>. All other
errors will be silenced. (repeatable)
--suppress-error-code <error-code>[,<error-code>...]
Do not report errors with code <error-code>. (repeatable)
--suppress-payload-superclass-redefinition-for <class>[,<class>...]
Explicitly suppress the superclass redefinition error for
<class>, a fully qualified class name defined in Sorbet's
payload, like `IRB::RelineInputMethod`. (repeatable)
--experimental-ruby3-keyword-args
Enforce use of new (Ruby 3.0-style) keyword arguments.
(incomplete and experimental)
--uniquely-defined-behavior
Ensure that every class and module only defines
'behavior' in one file. Ensures that every class or
module can be autoloaded by loading exactly one file.
--stop-after <phase> Stop after completing <phase>. Can be useful for
debugging. Also useful when overwhelmed with errors,
because errors from earlier phases (like resolver) can
cause errors downstream (in inferencer).
Phases: [init, parser, rbs, desugarer, rewriter,
local-vars, namer, resolver, cfg, inferencer] (default:
inferencer)
METRIC options
--counters Print all internal counters
--counter <counter>[,<counter>...]
Print internal counter for <counter> (repeatable)
--track-untyped [={[nowhere],everywhere,everywhere-but-tests}(=everywhere)]
Include a per-file counter of untyped usages in the
`--print=file-table-json` output. This is in addition to
the codebase-wide `types.input.untyped.usages` counter.
--metrics-file <file> Report counters and some timers to <file>, in JSON
format. (default: "")
--metrics-prefix <prefix>
Prefix every metric name in the `--metrics-file` output
with <prefix>, e.g. `my_org.my_repo`. (default:
ruby_typer.unknown)
--metrics-branch <branch>
Set the `branch` field to <branch> in the
`--metrics-file` output. (default: none)
--metrics-sha <sha> Set the `sha` field to <sha> in the `--metrics-file`
output. (default: none)
--metrics-repo <repo> Set the `repo` field to <repo> in the `--metrics-file`
output. (default: none)
--statsd-host <host> Send counters to the StatsD server at <host> (default:
"")
--statsd-prefix <prefix> Prefix every StatsD metric name with <prefix> (default:
ruby_typer.unknown)
--statsd-port <port> Connect to `--statsd-host` on <port> (default: 8200)
--statsd-tag-revision Tags some metrics with the revision Sorbet was built from
(default: true)
--metrics-extra-tags <key>=<value>[,<key>=<value>...]
Extra tags to include in every statsd metric.
(repeatable) (default: "")
--metrics-latest-version-file <file>
Tag every statsd metric with
`is_latest_version:{true,false,unknown}`, by comparing
the revision Sorbet was built from to the contents of
<file>. Re-reads <file> every time metrics are sent, so
that long-running LSP processes notice when <file>
changes. (default: "")
LSP options
--lsp Start in language server protocol mode (LSP mode)
--lsp-error-cap <cap> Reports no more than <cap> diagnostics (e.g. errors and
informations) to the language client, like VS Code. Can
prevent slowdown triggered by large diagnostic lists. A
<cap> of 0 means no limit. (default: 1000)
--lsp-max-files-on-fast-path <n>
Retypechecks the whole codebase after an edit that
changes over <n> files at once, or that changes a
definition used in over <n> files. Smaller edits only
retypecheck those files, which blocks other requests
until it finishes. (default: 50)
--disable-watchman When in LSP mode, disable file watching via Watchman
--watchman-path <path> Path to watchman executable. Will search on `PATH` if
<path> contains no slashes. (default: watchman)
--watchman-pause-state-name <state>[,<state>...]
Defer file change notifications while a client holds the
watchman state <state> (see `watchman state-enter`) on
the watched root; they arrive as one batch when the state
is left. (repeatable)
--watchman-namespace <namespace>
Only watch files under <namespace>, a directory relative
to the watched root (default: "")
--lsp-directories-missing-from-client <path>[,<path>...]
Directory prefixes that only exist where the LSP server
is running, not on the client. Useful when running Sorbet
via an `ssh` connection to a remote server, where the
remote server has generated files that do not exist on
the client. References to files in these directories will
be sent as `sorbet:` URIs to clients that understand
them. (repeatable)
--forcibly-silence-lsp-multiple-dir-error
Allow the LSP to start with multiple `--dir` options by
silencing the error. (WARNING: This flag does not address
the known issues with multiple directory support in LSP
mode. You are likely to encounter unexpected behavior.)
LSP FEATURE options
--enable-experimental-lsp-document-highlight
Enable experimental LSP feature: Document Highlight
--enable-experimental-lsp-signature-help
Enable experimental LSP feature: Signature Help
--enable-experimental-lsp-extract-to-variable
Enable experimental LSP feature: Extract To Variable
--enable-experimental-lsp-create-missing-method
Enable experimental LSP feature: Create Missing Method
--enable-all-experimental-lsp-features
Enable every experimental LSP feature. (WARNING: can be
crashy; for developer use only. End users should prefer
to use `--enable-all-beta-lsp-features`, instead.)
--enable-all-beta-lsp-features
Enable (expected-to-be-non-crashy) early-access LSP
features.
PERFORMANCE options
--web-trace-file <file> Generate a trace into <file> in the Trace Event Format
(used by chrome://tracing) (default: "")
--web-trace-file-strict Whether to close the toplevel array in `--web-trace-file`
--cache-dir <dir> Use <dir> to cache certain data. Will create <dir> if it
does not exist (default: "")
--max-cache-size-bytes <bytes>
Must be a multiple of OS page size (usually 4096).
Subject to restrictions on mdb_env_set_mapsize function
in LMDB API docs. (default: 4294967296)
--max-threads <n> Set number of threads to use for fork/join worker pools.
LSP will use <n> threads plus some extra threads to
manage the connection with the client, watchman, etc.
(default: number of cores on the system)
--reserve-class-table-capacity <n>
Preallocate <n> slots in the class and modules table
(default: 0)
--reserve-method-table-capacity <n>
Preallocate <n> slots in the method table (default: 0)
--reserve-field-table-capacity <n>
Preallocate <n> slots in the field table (default: 0)
--reserve-type-argument-table-capacity <n>
Preallocate <n> slots in the type argument table
(default: 0)
--reserve-type-member-table-capacity <n>
Preallocate <n> slots in the type member table (default:
0)
--reserve-utf8-name-table-capacity <n>
Preallocate <n> slots in the UTF8 name table (default: 0)
--reserve-constant-name-table-capacity <n>
Preallocate <n> slots in the constant name table
(default: 0)
--reserve-unique-name-table-capacity <n>
Preallocate <n> slots in the unique name table (default:
0)
SORBET PACKAGES MODE options
--sorbet-packages Enable support for Sorbet's experimental Ruby package
system
--sorbet-packages-hint-message <message>
Add <message> as an additional error note in every
packaging-related error (default: "")
--extra-package-files-directory-prefix-slash <dir>[,<dir>...]
Extra parent directories which contain package files.
Files are associated to a package using a package's
namespace join by slashes. That is, files in
<dir>/Project/FooBar/ belong to Project::FooBar
(repeatable)
--allow-relaxed-packager-checks-for <pkg>[,<pkg>...]
Allow <pkg> to ignore the restrictions set by
`visible_to` directives and `package_private!` markers
(repeatable)
--gen-packages-update-visibility-for <pkg>[,<pkg>...]
Generate `visible_to` autocorrects for <pkg> in
--gen-packages mode (repeatable)
--gen-packages-allow-relaxing-test-visibility
Allow adding `visible_to 'tests'` for packages with
visibility updates
--packager-layers [=<layer-name>[,<layer-name>...](=library,application)]
Valid layer names for packages, ordered lowest to
highest. Passing this flag also enables layering checks.
(repeatable)
--package-attributed-errors
Attribute errors to their enclosing package in the error
output
--experimental-package-directed
Enable support for checking by package, instead of
processing all files at once
--min-stratum-size <n> In package-directed mode, merge strata with fewer than
<n> files (including `__package.rb` files) with a
neighbor
--stratum-split-threshold <n>
In package-directed mode, split strata with more than <n>
files (including `__package.rb` files) into their
component SCCs
--focus-package <pkg>[,<pkg>...]
Focus typechecking to <pkg> (repeatable)
--focus-file <file>[,<file>...]
Focus typechecking to <file> (repeatable)
--focus-assume-package-dependencies-typecheck
Skip inference for dependencies of the focused set
--focus-extent {[full],none}
The extent of packages that depend on the focused set
that will be typechecked (default: full)
STRIPE AUTOGEN options
--autogen-version <version>
Write `-p autogen-msgpack` output in format <version>
--autogen-subclasses-parent <class>[,<class>...]
Generate a list of the subclasses of <class>. Requires
`-p autogen-subclasses` (repeatable)
--autogen-subclasses-ignore <pattern>[,<pattern>...]
Like --ignore, but only ignore <pattern> in `-p
autogen-subclasses`. (repeatable)
--autogen-msgpack-skip-reference-metadata
Skip serializing extra metadata on references when
printing msgpack in autogen
DEBUGGING options
-v, --verbose Verbosity level [0-3]
--debug-log-file <file> Write debug logs to <file> (default: "")
--wait-for-dbg Wait for debugger to attach after starting. Especially
useful to attach to a Sorbet process launched by a
language client
--sleep-in-slow-path [=<seconds>(=3)]
Sleep for <seconds> in the slow path to artificially slow
it down
--stress-incremental-resolver
Simulate updates which tend to expose namer and resolver
bugs
--simulate-crash Raise an uncaught C++ exception on startup to simulate a
crash
--force-hashing Force Sorbet to calculate file hashes, even from the CLI.
Useful for profiling.
--trace-lexer Emit the lexer's token stream in a debug format
--trace-parser Enable bison's parser trace functionality
-p, --print <format>[,<format>...]
Print various internal data structures. (repeatable)
By default, the output is to stdout. To send the data to
a file, use
--print=<format>:<file>
Most of these formats are unstable, for internal-use only.
Stable: [file-table-json, file-table-full-json,
missing-constants, payload-sources, untyped-blame]
Unstable: [parse-tree, parse-tree-json,
parse-tree-json-with-locs, parse-tree-whitequark,
rbs-rewrite-tree, desugar-tree, desugar-tree-raw,
desugar-tree-raw-with-locs, rewrite-tree,
rewrite-tree-raw, index-tree, index-tree-raw, name-tree,
name-tree-raw, resolve-tree, resolve-tree-raw,
flatten-tree, flatten-tree-raw, ast, ast-raw, cfg,
cfg-raw, cfg-text, symbol-table, symbol-table-raw,
symbol-table-json, symbol-table-full,
symbol-table-full-raw, symbol-table-full-json, autogen,
autogen-msgpack, autogen-subclasses, package-tree,
minimized-rbi
INTERNAL options
--suppress-non-critical Exit 0 unless there was a critical error (i.e., an
uncaught exception)
--no-stdlib Do not load Sorbet's payload which defines RBI files for
the Ruby standard library
--store-state <symbol-table>,<name-table>,<file-table>
Store state into three files, separated by commas:
<symbol-table>,<name-table>,<file-table> (default: "")
--silence-dev-message Silence "You are running a development build" message
--censor-for-snapshot-tests
When printing raw location information, don't show line
numbers
EXPERIMENTAL options
--enable-experimental-requires-ancestor
Enable experimental `requires_ancestor` annotation
--enable-experimental-rbs-signatures
Enable experimental support for RBS signatures as inline
comments
--enable-experimental-rbs-assertions
Enable experimental support for RBS assertions as inline
comments
--enable-experimental-rbs-comments
Enable experimental support for RBS signatures and
assertions as inline comments
--enable-experimental-rspec
Enables experimental support for RSpec. There are many
RSpec constructs that are impossible for Sorbet to
handle. As a result, there is no path to this flag ever
being stable: RSpec support is best effort.
--enable-experimental-method-modifiers
Enable experimental support for method def modifiers like
`abstract def foo; end`.
Implicitly enabled if you enable RBS support.
OTHER options
--version Show Sorbet's version
--license Show Sorbet's license, and licenses of its dependencies
--stdout-hup-hack Monitor STDERR for HUP and exit on hangup to work around
OpenSSH bug
--minimize-to-rbi <file.rbi>
[experimental] Output a minimal RBI containing the diff
between Sorbet's view of a codebase and the definitions
present in <file.rbi> (default: "")
-h, --help [=<section>[,<section>...](=all)]
Show help. Pass an optional <section> to show only that
section, instead of all sections (repeatable)
--parser {[original],prism}
Which parser to use. Prism support is experimental and
still under active development. Correct code should still
parse correctly, but error diagnostics and
auto-corrections are a work-in-progress. (default:
original)