Skip to content

DART_VM_OPTIONS for self-executables not working! #55767

Description

@gmpassos

As mentioned on README, Dart 3.4.0 supports DART_VM_OPTIONS for self-executables:

README.md:

...
### Dart Runtime

- Dart VM flags and options can now be provided to any executable generated
  using `dart compile exe` via the `DART_VM_OPTIONS` environment variable.
  `DART_VM_OPTIONS` should be set to a list of comma-separated flags and options
  with no whitespace. Options that allow for multiple values to be provided as
  comma-separated values are not supported (e.g.,
  `--timeline-streams=Dart,GC,Compiler`).

  Example of a valid `DART_VM_OPTIONS` environment variable:

   DART_VM_OPTIONS=--random_seed=42,--verbose_gc

...

Example:

foo.dart:

void main(List<String> args) {
  print("FOO>> args: $args");
}

run-foo.sh:

#!/bin/bash

dart compile exe foo.dart

export DART_VM_OPTIONS=--random_seed=42,--verbose_gc
echo "DART_VM_OPTIONS: $DART_VM_OPTIONS"

echo "Running executable:"
./foo.exe

Output of ./run-foo.sh:

Generated: /private/tmp/dart-test-foo/foo.exe
DART_VM_OPTIONS: --random_seed=42,--verbose_gc
Running executable:
Usage: dart [<vm-flags>] <dart-script-file> [<script-arguments>]

Executes the Dart script <dart-script-file> with the given list of <script-arguments>.

Common VM flags:
--help or -h
  Display this message (add -v or --verbose for information about
  all VM options).
--packages=<path>
  Where to find a package spec file.
--define=<key>=<value> or -D<key>=<value>
  Define an environment declaration. To specify multiple declarations,
  use multiple instances of this option.
--snapshot-kind=<snapshot_kind>
--snapshot=<file_name>
  These snapshot options are used to generate a snapshot of the loaded
  Dart script:
    <snapshot-kind> controls the kind of snapshot, it could be
                    kernel(default) or app-jit
    <file_name> specifies the file into which the snapshot is written
--version
  Print the SDK version.

For some reason it's always showing the dart CLI help message.


dart --version:

Dart SDK version: 3.4.0 (stable) (Mon May 6 07:59:58 2024 -0700) on "macos_x64"

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.triagedIssue has been triaged by sub team

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions