interactive command does not work as shown
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):
- OS: Linux Fedora
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
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:
- Clone this repo, say it is at
/path/to/dart_interactive - Add
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). - At folder
/path/to/dart_interactive/packages/interactive, rundart run interactive - Look at outputs. Suppose
aaaais 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:
https://github.com/fzyzcjy/dart_interactive/blob/1e9e1ae28e3c7a1542a45f441150611f856c6739/packages/interactive/lib/src/workspace_isolate.dart#L43
But putting a sleep at the beginning of main function gets it to work.
https://github.com/fzyzcjy/dart_interactive/blob/1e9e1ae28e3c7a1542a45f441150611f856c6739/packages/interactive/lib/src/main.dart#L53
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:
https://github.com/fzyzcjy/dart_interactive/blob/1e9e1ae28e3c7a1542a45f441150611f856c6739/packages/interactive/lib/src/executor.dart#L33-L35
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"
Just tested with Dart 3.7.0 beta on Windows 11, and I don't have the >>> output.
Can confirm the issue on macOS 14.7.2 dart --version Dart SDK version: 3.5.3 (stable) (Wed Sep 11 16:22:47 2024 +0000) on "macos_arm64"
I have Dart installed through Flutter.
But it seems to work when I clone the repo and use dart run
Edit: Deactivating and activating seemed to work
I guess this bugs existence is quite well established alredy, but in any case can report that this issue happens on freshly installed interactive on Fedora 41 and:
dart --version
Dart SDK version: 3.7.0 (stable) (Wed Feb 5 04:53:58 2025 -0800) on "linux_x64"
this problem is in my computer , dart version is 3.4.3, in windows wsl. output is
Run: /home/u/.x-cmd.root/local/data/asdf/installs/dart/3.4.3/bin/dart [--enable-vm-service=42045, file:///home/soluty/.pub-cache/global_packages/i nteractive/bin/interactive.dart-3.4.3.snapshot, --vm-service-was-enabled] Workspace: /tmp/dart_interactive_workspace_2025-03-13T133053492751 The Dart VM service is listening on http://127.0.0.1:42045/i2X3vLIH2B4=/ The Dart DevTools debugger and profiler is available at: http://127.0.0.1:42045/i2X3vLIH2B4=/devtools?uri=ws://127.0.0.1:42045/i2X3vLIH2B4=/ws
I was running into this on macOS 15.3.1 (M2) with dart 3.6.0 using the VS Code terminal
$ dart pub global activate interactive
Downloading packages... .
+ _fe_analyzer_shared 82.0.0
+ analyzer 7.4.1
+ args 2.7.0
+ async 2.13.0
+ cli_repl 0.2.3
+ collection 1.19.1
+ convert 3.1.2
+ crypto 3.0.6
+ file 7.0.1
+ glob 2.1.3
+ interactive 1.4.1
+ js 0.6.7 (0.7.2 available)
+ logging 1.3.0
+ meta 1.16.0
+ package_config 2.2.0
+ path 1.9.1
+ pub_semver 2.2.0
+ source_span 1.10.1
+ string_scanner 1.4.1
+ term_glyph 1.2.2
+ typed_data 1.4.0
+ vm_service 11.10.0 (15.0.0 available)
+ watcher 1.1.1
+ yaml 3.1.3
Building package executables... (1.7s)
Built interactive:interactive.
Installed executable interactive.
Activated interactive 1.4.1.
$ interactive
Run: /Users/beninato/fvm/versions/3.27.1/bin/cache/dart-sdk/bin/dart [--enable-vm-service=50212, file:///Users/beninato/.pub-cache/global_packages/interactive/bin/interactive.dart-3.6.0.snapshot, --vm-service-was-enabled]
Workspace: /var/folders/nd/yt3bmrtd4s3882h6n_sfn9tw0000gn/T/dart_interactive_workspace_2025-04-18T210650962449
The Dart VM service is listening on http://127.0.0.1:50212/h2EPiuuf_t8=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:50212/h2EPiuuf_t8=/devtools/?uri=ws://127.0.0.1:50212/h2EPiuuf_t8=/ws
$ dart --version
Dart SDK version: 3.6.0 (stable) (Thu Dec 5 07:46:24 2024 -0800) on "macos_arm64"
However, after running dart pub global deactivate interactive and dart pub global activate interactive, it seems to be working in iTerm2 (VS Code still was not working, so I'm not sure if the deactivate / activate was even needed to work on a different terminal)
Run: /Users/beninato/fvm/versions/3.27.1/bin/cache/dart-sdk/bin/dart [--enable-vm-service=52094, file:///Users/beninato/.pub-cache/global_packages/interactive/bin/interactive.dart-3.6.0.snapshot, --vm-service-was-enabled]
The Dart VM service is listening on http://127.0.0.1:52094/HOn98ypQ-bs=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:52094/HOn98ypQ-bs=/devtools/?uri=ws://127.0.0.1:52094/HOn98ypQ-bs=/ws
Workspace: /var/folders/nd/yt3bmrtd4s3882h6n_sfn9tw0000gn/T/dart_interactive_workspace_2025-04-18T211811585326
>>> print("hello world")
hello world
>>>
Can confirm the same issue when i install interactive using dart pub global activate interactive
- M2 Max MBP (macos version 15.3.2 and 15.4.1) with Dart SDK version: 3.4.4, 3.5.4, and 3.7.2 (vscode terminal, ghostty, alacritty, and default macos terminal)
HP Ryzen Pro 5650U Windows laptop with dart 3.7.0 seems to work fine though.
When I download the repository on my MBP and run dart pub global activate --source path . to install interactive from a local repository, i get the following error, which might be helpful.
Unhandled exception:
getVM: (-32000) Service connection disposed
#0 VmService._call (package:vm_service/src/vm_service.dart:1912:7)
#1 VmService.getVM (package:vm_service/src/vm_service.dart:1388:25)
#2 _extension#0.getIsolateIds (package:interactive/src/workspace_isolate.dart:58:65)
#3 WorkspaceIsolate.create (package:interactive/src/workspace_isolate.dart:43:38)
<asynchronous suspension>
#4 Executor.create (package:interactive/src/executor.dart:41:30)
<asynchronous suspension>
#5 run (package:interactive/src/main.dart:59:7)
<asynchronous suspension>
#6 main (file://~/Downloads/dart_interactive-master/packages/interactive/bin/interactive.dart:9:5)
<asynchronous suspension>
However, when I run dart run bin/interactive.dart it works just fine. So something seems to be going on during compilation that causes the problem.
When I compile bin/interactive.dart to a kernel and run that, I get the same error message getVM: (-32000) Service connection disposed
When I compile to exe and run that I get the following infinite retry loop:
./interactive.exe
Run: ./interactive.exe [--enable-vm-service=53521,
file://./interactive.exe, --vm-service-was-enabled]
Run: ./interactive.exe [--enable-vm-service=53522,
file://./interactive.exe, --vm-service-was-enabled, --enable-vm-service=53521,
file://./interactive.exe, --vm-service-was-enabled]
Run: ./interactive.exe [--enable-vm-service=53523,
file://./interactive.exe, --vm-service-was-enabled, --enable-vm-service=53522,
file://./interactive.exe, --vm-service-was-enabled, --enable-vm-service=53521,
file://./interactive.exe, --vm-service-was-enabled]
Run: ./interactive.exe [--enable-vm-service=53524,
file://./interactive.exe, --vm-service-was-enabled, --enable-vm-service=53523,
file://./interactive.exe, --vm-service-was-enabled, --enable-vm-service=53522,
file://./interactive.exe, --vm-service-was-enabled, --enable-vm-service=53521,
file://./interactive.exe, --vm-service-was-enabled]
The pattern is that if it fails to run at a given port then it keeps trying one higher port number and then proceed to check every port below it until it reaches the default port number.
For my personal use, I just hacked together a workaround solution:
- install interactive using
dart pub global activate interactive - download the interactive source code from github
- go to
~/.pub-cache/global_packages/interactiveand delete its contents - move
bin,src, andpubspec.lockfrom the interactive repository into~/.pub-cache/global_packages/interactive - edit
~/.pub-cache/bin/interactiveto contain the following commanddart run ../global_packages/interactive/bin/interactive.dart "$@"
Not ideal, but functional. I guess the root cause is related to dart itself and not interactive, but fixing that is above my paygrade.
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.
Same problem here.
~ $ dart pub global activate interactive
Downloading packages... .
+ _fe_analyzer_shared 85.0.0 (86.0.0 available)
+ analyzer 7.7.0 (8.0.0 available)
+ args 2.7.0
+ async 2.13.0
+ cli_repl 0.2.3
+ collection 1.19.1
+ convert 3.1.2
+ crypto 3.0.6
+ file 7.0.1
+ glob 2.1.3
+ interactive 1.4.1
+ js 0.6.7 (0.7.2 available)
+ logging 1.3.0
+ meta 1.17.0
+ package_config 2.2.0
+ path 1.9.1
+ pub_semver 2.2.0
+ source_span 1.10.1
+ string_scanner 1.4.1
+ term_glyph 1.2.2
+ typed_data 1.4.0
+ vm_service 11.10.0 (15.0.2 available)
+ watcher 1.1.2
+ yaml 3.1.3
Building package executables... (5.5s)
Built interactive:interactive.
Installed executable interactive.
Activated interactive 1.4.1.
~ $ interactive
Run: dart [--enable-vm-service=42601, file:///ssd/ckchen/.pub-cache/global_packages/interactive/bin/interactive.dart-3.8.1.snapshot, --vm-service-was-enabled]
Workspace: /tmp/dart_interactive_workspace_2025-07-21T130411923433
The Dart VM service is listening on http://127.0.0.1:42601/O7ZpUJiL75A=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:42601/O7ZpUJiL75A=/devtools/?uri=ws://127.0.0.1:42601/O7ZpUJiL75A=/ws
^C
~ $ dart --version
Dart SDK version: 3.8.1 (stable) (Wed May 28 00:47:25 2025 -0700) on "linux_x64"
~ $ uname -a
Linux cadpcd 5.15.0-139-generic #149~20.04.1-Ubuntu SMP Wed Apr 16 08:29:56 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
~ $
My temporary solution is, after dart pub global activate interactive, run dart pub global run interactive:interactive instead of interactive.