Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interactive command does not work as shown #93

Open
oezg opened this issue Jun 11, 2024 · 23 comments
Open

interactive command does not work as shown #93

oezg opened this issue Jun 11, 2024 · 23 comments

Comments

@oezg
Copy link

oezg commented Jun 11, 2024

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

Copy link

welcome bot commented Jun 11, 2024

Hi! Thanks for opening your first issue here! 😄

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 11, 2024

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 #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.

@oezg
Copy link
Author

oezg commented Jun 12, 2024

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

@oezg
Copy link
Author

oezg commented Jun 12, 2024

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

@oezg
Copy link
Author

oezg commented Jun 12, 2024

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?

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jun 12, 2024

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
    final workspaceFileTree = await WorkspaceFileTree.create(
    . (And similarly, add a ton of various prints to a lot of lines).
  • At folder /path/to/dart_interactive/packages/interactive, run dart run interactive
  • Look at outputs. Suppose aaaa is printed, then we know it is executed; otherwise it is not. We can bisect to see what exact line fails.

@AlexeyBukin
Copy link

@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.

@rkyrychuk
Copy link

Not working on mac os to. Probably not supported with Dart 3.4.3 or Dart 3 at all

@Maksimka101
Copy link

Maksimka101 commented Jul 16, 2024

@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"

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jul 17, 2024

@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.

@Maksimka101
Copy link

Maksimka101 commented Jul 17, 2024

I'm talking about dart's vm service

@Maksimka101
Copy link

Maksimka101 commented Jul 17, 2024

@fzyzcjy Can you please tell what is your machine, os, dart version and how do you launch the app (with or without compiling it)?

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jul 17, 2024

@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

@natrys
Copy link

natrys commented Sep 5, 2024

For me, there is a race condition. Execution gets stuck here normally:

final isolateIdsAfter = await vm.getIsolateIds();

But putting a sleep at the beginning of main function gets it to work.

_setUpLogging(verbose ? Level.ALL : Level.WARNING);

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"

@fzyzcjy
Copy link
Owner

fzyzcjy commented Sep 6, 2024

@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.

@natrys
Copy link

natrys commented Sep 6, 2024

@fzyzcjy Had time to do a little more testing. I feel like the issue might be in the relationship between these two lines:

final vm = await VmServiceWrapper.create();
final workspaceIsolate =
await WorkspaceIsolate.create(vm, workspaceFileTree);

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.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Sep 6, 2024

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.

Copy link

stale bot commented Nov 7, 2024

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.

@stale stale bot added the wontfix This will not be worked on label Nov 7, 2024
@CBBosman
Copy link

CBBosman commented Nov 12, 2024

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"

@stale stale bot removed the wontfix This will not be worked on label Nov 12, 2024
@BeezBeez
Copy link

Just tested with Dart 3.7.0 beta on Windows 11, and I don't have the >>> output.

@jdk-21
Copy link

jdk-21 commented Jan 13, 2025

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

@timolehto
Copy link

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"

@soluty
Copy link

soluty commented Mar 13, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests