fzyzcjy / dart_interactive

REPL (interactive shell) for Dart, supporting 3rd party packages, hot reload, and full grammar
https://github.com/fzyzcjy/dart_interactive
MIT License
222 stars 13 forks source link

Allow dynamic downloading new library (by simply calling `dart pub add` and done) #8

Closed fzyzcjy closed 2 years ago

fzyzcjy commented 2 years ago

what syntax?

jupyter (python):

!pip install xxx

fzyzcjy commented 2 years ago

>>> !dart pub add path  
[STDERR] "path" is already in "dependencies". Use "pub upgrade path" to upgrade to a later version!
[STDERR] 

[WARNING 2022-10-22 19:43:39.523583] Process execution failed (exitCode=65)
>>> !dart pub add path
Resolving dependencies...

Got dependencies!

>>> !cat pubspec.yaml
name: execution_workspace
description: 
version: 1.0.0

environment:
  sdk: ">=2.18.0 <3.0.0"

dependencies:
  interactive:
    path: ../interactive
  path: ^1.8.2

dev_dependencies:

>>> import 'package:path/path.dart';
>>> path
[WARNING 2022-10-22 19:44:42.774964] Error: [ErrorRef id: objects/0, kind: UnhandledException, message: Unhandled exception:
NoSuchMethodError: Class 'InteractiveRuntimeContext' has no instance getter 'path'.
Receiver: Instance of 'InteractiveRuntimeContext'
Tried calling: path
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
#1      InteractiveRuntimeContext.noSuchMethod (package:interactive/src/runtime_support.dart:32:18)
#2      ExtDynamic.generatedMethod (file:///Users/tom/RefCode/dart_interactive/packages/execution_workspace/lib/auto_generated.dart:16:13)
#3      Eval ()
]
>>> join
>>> print('$join')
Closure: (String, [String?, String?, String?, String?, String?, String?, String?]) => String from Function 'join': static.