Open oezg opened 5 months ago
Hi! Thanks for opening your first issue here! :smile:
Hmm, I cannot reproduce locally:
interactive
Building package executable... (3.2s)
Built interactive:interactive.
Run: /Users/tom/fvm/versions/3.22.0/bin/cache/dart-sdk/bin/dart [--enable-vm-service=61753, file:///Users/tom/.pub-cache/global_packages/interactive/bin/interactive.dart-3.4.0.snapshot, --vm-service-was-enabled]
The Dart VM service is listening on http://127.0.0.1:61753/nLZukNycYk4=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:61753/nLZukNycYk4=/devtools?uri=ws://127.0.0.1:61753/nLZukNycYk4=/ws
Workspace: /var/folders/j5/j6ymn7yd70564hzt31pq_0g80000gn/T/dart_interactive_workspace_2024-06-12T073635644668
>>> print(42)
42
[InstanceRef id: objects/null, kind: Null, identityHashCode: -1, classRef: [ClassRef id: classes/170, name: Null, library: [LibraryRef id: libraries/@0150898, name: dart.core, uri: dart:core]]]
But your description looks similar to https://github.com/fzyzcjy/dart_interactive/issues/92.
Since I do not have a reproducible environment, could you please check whether it stucks (or provide a reproducible env)? For example, one way is to run a debugger on it, another way is to add a lot of print
and see. The package (https://github.com/fzyzcjy/dart_interactive/tree/master/packages/interactive) is nothing but a standard Dart command line program, so it would be easy to clone and run locally for debugging/modifying.
I removed the dart-sdk from /opt/, downloaded, extracted and copied dart sdk 3.4.4 to /opt/.
I used dart pub global deactivate interactive
and then dart pub global activate interactive
to refresh the installation.
$ which interactive
~/.pub-cache/bin/interactive
However the problem persists and I cannot see the interactive prompt >>>, instead this is the output:
$ interactive
Run: dart [--enable-vm-service=44349, file:///home/oezg/.pub-cache/global_packages/interactive/bin/interactive.dart-3.4.4.snapshot, --vm-service-was-enabled]
Workspace: /tmp/dart_interactive_workspace_2024-06-12T234104656045
The Dart VM service is listening on http://127.0.0.1:44349/fU8SNuHSDK4=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:44349/fU8SNuHSDK4=/devtools?uri=ws://127.0.0.1:44349/fU8SNuHSDK4=/ws
I am just a beginner with dart. I cloned the repo, and hit dart run
inside the interactive package. The result is the same:
interactive]$ dart run
Building package executable...
Built interactive:interactive.
Run: dart [--enable-vm-service=38049, file:///home/oezg/tries/dart/dart_interactive/packages/interactive/.dart_tool/pub/bin/interactive/interactive.dart-3.4.4.snapshot, --vm-service-was-enabled]
Workspace: /tmp/dart_interactive_workspace_2024-06-12T235213133939
The Dart VM service is listening on http://127.0.0.1:38049/xmPtEZa3kZk=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:38049/xmPtEZa3kZk=/devtools?uri=ws://127.0.0.1:38049/xmPtEZa3kZk=/ws
I didn't install Flutter, I only installed dart from the zip archive. Can this be the problem? My default browser is Brave. Can this be a problem? I don't have Chrome installed on my computer. Can this be a problem?
Hi, as is suggested above, could you please try to add a bunch of print
and see where it gets stuck? For example:
/path/to/dart_interactive
print('aaaa');
above this line https://github.com/fzyzcjy/dart_interactive/blob/5e4308fa2835e99262e82d044d76bd566b78a918/packages/interactive/lib/src/main.dart#L55. (And similarly, add a ton of various prints to a lot of lines)./path/to/dart_interactive/packages/interactive
, run dart run interactive
aaaa
is printed, then we know it is executed; otherwise it is not. We can bisect to see what exact line fails.@oezg Looks like OS-related bug for me. Cannot reproduce on Windows and MacOS. Try to debug interactive
command and find the bug. Then we'll submit a patch to the interactive
repo.
Not working on mac os to. Probably not supported with Dart 3.4.3 or Dart 3 at all
@fzyzcjy I tried to dig deeper and discovered that VmService
stops responding after creating an Isolate with the generated code. In WorkspaceIsolate.create
, the vm service is successfully used before creating the Isolate, but after that, the method vmService.getVM
never completes. This method is used to get the isolate id, so I tried replacing it with Service.getIsolateID(isolate)
, which worked, and I entered the REPL, seeing the coveted >>>
. However, when entering code, during the ReloadSources
phase, the method vmService.reloadSources
is called, which again never completes.
I also found out that when running with dart run
, everything works. But if you build the kernel, as the pub global activate
command does, this error occurs.
Dart SDK version: 3.4.3 (stable) (Tue Jun 4 19:51:39 2024 +0000) on "macos_arm64"
@Maksimka101 Hmm... Do you mean it is stuck at calling Dart's vm service? (or it is stuck at dart_interactive code), if the former maybe we can create an issue on Dart repo asking about this.
I'm talking about dart's vm service
@fzyzcjy Can you please tell what is your machine, os, dart version and how do you launch the app (with or without compiling it)?
@Maksimka101 I personally use macos, and you can check https://github.com/fzyzcjy/dart_interactive/blob/master/.github/workflows/ci.yaml for various machines and versions etc
For me, there is a race condition. Execution gets stuck here normally:
But putting a sleep at the beginning of main function gets it to work.
Tested by running dart run
in git HEAD. Dart version:
Dart SDK version: 3.6.0-216.0.dev (dev) (Wed Sep 4 13:34:13 2024 -0700) on "linux_x64"
@natrys curious why would getIsolateIds would introduce a race condition... But if this is stuck, maybe we can do a workaround: We can change await vm.getIsolateIds()
to a timeout-and-retry. In other words, we timeout on e.g. 1s and if it timeouts we retry again and again.
@fzyzcjy Had time to do a little more testing. I feel like the issue might be in the relationship between these two lines:
As is, it gets stuck when executing the second line.
If I put await Future<void>.delayed(const Duration(seconds: 1));
before both lines, then it works fine.
If I put this in-between them, then it just crashes/exits (not even gets stuck).
Tried adding retry logic like:
VmServiceWrapper vm;
WorkspaceIsolate workspaceIsolate;
while (true) {
try {
vm = await VmServiceWrapper.create();
workspaceIsolate = await WorkspaceIsolate.create(vm, workspaceFileTree)
.timeout(const Duration(seconds: 1));
break;
} on TimeoutException {
print('Trying again...');
await Future<void>.delayed(const Duration(seconds: 1));
}
}
It works in the second try as I would expect. However something is still not quite right because when I do C-d on the repl, then it gets stuck instead of exiting cleanly.
Hmm... Again that's quite weird... Maybe the next step can be reducing the same to bare minimum, i.e. only call Dart vm apis. Then, if the problem still exists, that may be a bug related to Dart lang, and we can create a bug report there.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I have the same issue on linux. Just installed and when I run interactive
I get the same output with no interactive prompt.
dart --version
Dart SDK version: 3.5.3 (stable) (Wed Sep 11 16:22:47 2024 +0000) on "linux_x64"
Describe the bug I used the installation guide but the interactive more did not work.
To Reproduce after the installation and adding to the PATH I ran interactive but the repl did not start as shown in the website. Instead I get this message:
Run: dart [--enable-vm-service=43935, file:///home/..../.pub-cache/global_packages/interactive/bin/interactive.dart-3.4.3.snapshot, --vm-service-was-enabled] Workspace: /tmp/dart_interactive_workspace_2024-06-12T010133935832 The Dart VM service is listening on http://127.0.0.1:43935/fdZBpSYCk6k=/ The Dart DevTools debugger and profiler is available at: http://127.0.0.1:43935/fdZBpSYCk6k=/devtools?uri=ws://127.0.0.1:43935/fdZBpSYCk6k=/ws
Expected behavior the terminal will show the repl with >>> and respond to my prompts
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context when I go to the link, connected app type is Dart CLI, VM Service Connection: ws://127.0.0.1:43935/fdZBpSYCk6k=/ws