dart_repl icon indicating copy to clipboard operation
dart_repl copied to clipboard

kernel-service: Error: Unhandled exception: Bad state: No element

Open liudonghua123 opened this issue 3 years ago • 4 comments

After I installed this package, I just run var a=123; and print(a), then it crashed.

D:\temp\repl>drepl
The Dart VM service is listening on http://127.0.0.1:8181/WfEY8xjHEc8=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/WfEY8xjHEc8=/devtools/#/?uri=ws%3A%2F%2F127.0.0.1%3A8181%2FWfEY8xjHEc8%3D%2Fws
2.17.1 (stable) (Tue May 17 17:58:21 2022 +0000) on "windows_x64"
Type `exit()` or Ctrl-d to quit.
> var a=123;
reloaded
> kernel-service: Error: Unhandled exception:
Bad state: No element
#0      Iterable.first (dart:core/iterable.dart:624:7)
#1      MappedIterable.first (dart:_internal/iterable.dart:370:31)
#2      lookupOrBuildNewIncrementalCompiler (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:443:45)
#3      _processLoadRequest (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:864:22)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

Unhandled exception:
Bad state: No element
#0      Iterable.first (dart:core/iterable.dart:624:7)
#1      MappedIterable.first (dart:_internal/iterable.dart:370:31)
#2      lookupOrBuildNewIncrementalCompiler (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:443:45)
#3      _processLoadRequest (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:864:22)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
^CTerminate batch job (Y/N)? ^C
Y

D:\temp\repl>

liudonghua123 avatar May 23 '22 08:05 liudonghua123

Thanks for filing this. Not sure what is causing it as I can't replicate it myself locally on Linux. I assume you got this by globally activating the repl package using something like: dart pub global activate --source path D:\temp\repl>drepl ?

In which case I would expect you to have run into #12 which I also need to fix.

I'll try to look into this more soon.

maks avatar May 24 '22 00:05 maks

I installed it via dart pub global activate repl. And it failed with some errors https://github.com/maks/dart_repl/issues/8, then I modified the local code in C:\Users\Liu.D.H\AppData\Local\Pub\Cache\hosted\pub.flutter-io.cn\repl-0.1.0\lib\parser.dart then run dart pub global activate repl again.

liudonghua123 avatar May 24 '22 02:05 liudonghua123

I also found an interesting project on https://github.com/hetu-script/hetu-script#command-line-tool. The hetu works well. But it is not using pure dart syntax.

liudonghua123 avatar May 24 '22 02:05 liudonghua123

Ah ok, thanks for letting me know, that makes sense now, you edited the local pub cache files. I'd suggest editing local cache files is not the best approach though, I'd rather suggest use your local clone of this repo, edit it and use eg. the --source for testing doing a global activate from it.

In regards to Hetu, yes I've come across it before, its very impressive, but if you are interested in a scripting implementation use Dart syntax then you probably want to look at dart_eval though its not feature complete by any means yet.

maks avatar May 24 '22 04:05 maks