Skip to content

Isolate.resolvePackageUri has inconsistent behavior when called from a script launched via relative path #32901

Closed
@jcollins-g

Description

@jcollins-g

When running in the VM with preview-dart-2, resolvePackageUri sometimes doesn't resolve to a file URI correctly unless the script was launched with an absolute path.

demo:

/tmp/resolve
$ cat pubspec.yaml
name: resolvedemo
version: 0.1.0
/tmp/resolve
$ pub get
Resolving dependencies... 
Got dependencies!
/tmp/resolve
$ cat bin/resolve.dart 
import "dart:isolate" show Isolate;

main() {
  Uri theUri = Uri.parse('package:resolvedemo/test.dart');
  print('theUri: $theUri');
  Isolate.resolvePackageUri(theUri).then((u) => print ('resolved Uri: $u'));
}

/tmp/resolve
$ dart `pwd`/bin/resolve.dart
theUri: package:resolvedemo/test.dart
resolved Uri: file:///tmp/resolve/lib/test.dart
/tmp/resolve
$ dart bin/resolve.dart
theUri: package:resolvedemo/test.dart
resolved Uri: file:///tmp/resolve/lib/test.dart
/tmp/resolve
$ dart --preview-dart-2 `pwd`/bin/resolve.dart
theUri: package:resolvedemo/test.dart
resolved Uri: file:///tmp/resolve/lib/test.dart
/tmp/resolve
$ dart --preview-dart-2 bin/resolve.dart
theUri: package:resolvedemo/test.dart
resolved Uri: lib/test.dart
/tmp/resolve
$

I believe all four runs of the program should have the same output.
(edit: refined example for clarity)

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failuresarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions