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
217 stars 13 forks source link

`OS Error: The filename, directory name, or volume label syntax is incorrect` on windows, unrelated to package core, but compatibility issues about folder paths #30

Closed liudonghua123 closed 1 year ago

liudonghua123 commented 1 year ago

I tried the guidance on readme (Inside packages/interactive, execute dart run --enable-vm-service bin/interactive.dart.), however, it not works for me.

D:\code\dart>git clone git@github.com:fzyzcjy/dart_interactive.git
Cloning into 'dart_interactive'...
remote: Enumerating objects: 820, done.
remote: Counting objects: 100% (368/368), done.
remote: Compressing objects: 100% (205/205), done.
remote: Total 820 (delta 141), reused 344 (delta 120), pack-reused 452
Receiving objects: 100% (820/820), 141.04 KiB | 300.00 KiB/s, done.
Resolving deltas: 100% (318/318), done.

D:\code\dart>cd dart_interactive\

D:\code\dart\dart_interactive>cd packages\interactive\

D:\code\dart\dart_interactive\packages\interactive>
D:\code\dart\dart_interactive\packages\interactive>dart run --enable-vm-service bin\interactive.dart
The Dart VM service is listening on http://127.0.0.1:8181/QttPLrcLj-Y=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/QttPLrcLj-Y=/devtools/#/?uri=ws%3A%2F%2F127.0.0.1%3A8181%2FQttPLrcLj-Y%3D%2Fws
Error: Couldn't resolve the package 'interactive' in 'package:interactive/src/main.dart'.
bin/interactive.dart:1:8: Error: Not found: 'package:interactive/src/main.dart'
import 'package:interactive/src/main.dart' as lib_main;
       ^
bin/interactive.dart:3:42: Error: Method not found: 'main'.
void main(List<String> args) => lib_main.main(args);
                                         ^^^^

D:\code\dart\dart_interactive\packages\interactive>dart pub get
Resolving dependencies...
+ _fe_analyzer_shared 49.0.0
+ analyzer 5.1.0
+ args 2.3.1
+ async 2.9.0
+ boolean_selector 2.1.0
+ cli_repl 0.2.3
+ collection 1.17.0
+ convert 3.0.2
+ coverage 1.6.1
+ crypto 3.0.2
+ file 6.1.4
+ frontend_server_client 3.1.0
+ glob 2.1.0
+ http_multi_server 3.2.1
+ http_parser 4.0.2
+ io 1.0.3
+ js 0.6.5
+ lint 1.10.0
+ logging 1.1.0
+ matcher 0.12.12
+ meta 1.8.0
+ mime 1.0.2
+ node_preamble 2.0.1
+ package_config 2.1.0
+ path 1.8.2
+ pool 1.5.1
+ pub_semver 2.1.1
+ shelf 1.4.0
+ shelf_packages_handler 3.0.1
+ shelf_static 1.1.1
+ shelf_web_socket 1.0.2
+ source_map_stack_trace 2.1.0
+ source_maps 0.10.11
+ source_span 1.9.1
+ stack_trace 1.11.0
+ stream_channel 2.1.1
+ string_scanner 1.1.1
+ term_glyph 1.2.1
+ test 1.21.6
+ test_api 0.4.14
+ test_core 0.4.18
+ typed_data 1.3.1
+ vm_service 9.4.0
+ watcher 1.0.2
+ web_socket_channel 2.2.0
+ webkit_inspection_protocol 1.2.0
+ yaml 3.1.1
Downloading test 1.21.6...
Downloading lint 1.10.0...
Downloading logging 1.1.0...
Downloading collection 1.17.0...
Downloading cli_repl 0.2.3...
Downloading test_core 0.4.18...
Downloading test_api 0.4.14...
Downloading analyzer 5.1.0...
Downloading _fe_analyzer_shared 49.0.0...
Downloading stream_channel 2.1.1...
Downloading stack_trace 1.11.0...
Downloading js 0.6.5...
Downloading source_maps 0.10.11...
Downloading watcher 1.0.2...
Downloading http_parser 4.0.2...
Downloading frontend_server_client 3.1.0...
Downloading shelf 1.4.0...
Downloading coverage 1.6.1...
Changed 47 dependencies!

D:\code\dart\dart_interactive\packages\interactive>dart run --enable-vm-service bin/interactive.dart
The Dart VM service is listening on http://127.0.0.1:8181/56H0eTNIIls=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/56H0eTNIIls=/devtools/#/?uri=ws%3A%2F%2F127.0.0.1%3A8181%2F56H0eTNIIls%3D%2Fws
Unhandled exception:
FileSystemException: Exists failed, path = 'C:\Users\LIUD~1.H\AppData\Local\Temp/dart_interactive_workspace_2022-10-22T22:38:56.335037' (OS Error: The filename, directory name, or volume label syntax is incorrect.
, errno = 123)
#0      _Directory.existsSync (dart:io/directory_impl.dart:94:7)
#1      _Directory.createSync (dart:io/directory_impl.dart:126:11)
#2      WorkspaceFileTree._prepare (package:interactive/src/workspace_file_tree.dart:31:20)
#3      WorkspaceFileTree.create (package:interactive/src/workspace_file_tree.dart:14:11)
<asynchronous suspension>
#4      run (package:interactive/src/main.dart:30:29)
<asynchronous suspension>

D:\code\dart\dart_interactive\packages\interactive>
D:\code\dart\dart_interactive\packages\interactive>dart --version
Dart SDK version: 2.18.2 (stable) (Tue Sep 27 13:24:11 2022 +0200) on "windows_x64"

D:\code\dart\dart_interactive\packages\interactive>ver

Microsoft Windows [Version 10.0.22621.675]

D:\code\dart\dart_interactive\packages\interactive>
fzyzcjy commented 1 year ago

This is the problem: FileSystemException: Exists failed, path = 'C:\Users\LIUD~1.H\AppData\Local\Temp/dart_interactive_workspace_2022-10-22T22:38:56.335037' (OS Error: The filename, directory name, or volume label syntax is incorrect.

I should use "\" not "/", i.e. use path join instead of hardcoding "/". Will fix today.

fzyzcjy commented 1 year ago

Will fix this after CI is configured in order to verify CI correctness as well

fzyzcjy commented 1 year ago

https://github.com/fzyzcjy/dart_interactive/actions/runs/3305144365/jobs/5455011709

reproduced and fixed

fzyzcjy commented 1 year ago

FileSystemException: Exists failed, path = 'C:\Users\RUNNER~1\AppData\Local\Temp\dart_interactive_workspace_2022-10-23T00:17:14.630661' (OS Error: The filename, directory name, or volume label syntax is incorrect.

fzyzcjy commented 1 year ago

Hmm I do not have a windows at hand. Could you please debug it a little bit? It seems unrelated to the core of this package, but instead, only related to creating folders etc.

fzyzcjy commented 1 year ago

I will try to remove ":" etc now

fzyzcjy commented 1 year ago

it works

liudonghua123 commented 1 year ago

I updated the code and tried again. It's Could not start the VM service: localhost:8181 is already in use. error. But I could not find any process serve 8181 port. Maybe a windows bug.

D:\code\dart\dart_interactive\packages\interactive>git pull
remote: Enumerating objects: 259, done.
remote: Counting objects: 100% (250/250), done.
remote: Compressing objects: 100% (100/100), done.
remote: Total 259 (delta 124), reused 238 (delta 112), pack-reused 9
Receiving objects: 100% (259/259), 99.25 KiB | 29.00 KiB/s, done.
Resolving deltas: 100% (124/124), completed with 2 local objects.
From github.com:fzyzcjy/dart_interactive
   e3da481..cfe8098  master     -> origin/master
 * [new tag]         v1.0.0     -> v1.0.0
 * [new tag]         v1.0.1     -> v1.0.1
Updating e3da481..cfe8098
Fast-forward
 .all-contributorsrc                                   |   54 +++
 .github/ISSUE_TEMPLATE/bug_report.md                  |   38 ++
 .github/ISSUE_TEMPLATE/feature_request.md             |   20 +
 .github/config.yml                                    |   14 +
 .github/dependabot.yml                                |    9 +
 .github/settings.yml                                  |  108 ++++++
 .github/stale.yml                                     |   17 +
 .github/workflows/ci.yaml                             |   44 +++
 .github/workflows/post_release.yml                    |   21 ++
 .gitignore                                            |    1 +
 CHANGELOG.md                                          |    8 +
 LICENSE                                               |   21 ++
 README.md                                             |  185 +++++++++-
 doc/logo.svg                                          | 1134 +--------------------------------------------------------
 example/example.md                                    |    1 +
 justfile                                              |   22 ++
 packages/interactive/CHANGELOG.md                     |    1 +
 packages/interactive/LICENSE                          |    1 +
 packages/interactive/README.md                        |    1 +
 packages/interactive/bin/interactive.dart             |   30 +-
 packages/interactive/lib/src/main.dart                |   36 +-
 packages/interactive/lib/src/runtime_support.dart     |   20 +-
 packages/interactive/lib/src/workspace_code.dart      |    1 -
 packages/interactive/lib/src/workspace_file_tree.dart |   28 +-
 packages/interactive/lib/src/workspace_isolate.dart   |   18 +-
 packages/interactive/pubspec.yaml                     |    8 +-
 packages/interactive/test/e2e_test.dart               |    1 +
 27 files changed, 680 insertions(+), 1162 deletions(-)
 create mode 100644 .all-contributorsrc
 create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md
 create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md
 create mode 100644 .github/config.yml
 create mode 100644 .github/dependabot.yml
 create mode 100644 .github/settings.yml
 create mode 100644 .github/stale.yml
 create mode 100644 .github/workflows/ci.yaml
 create mode 100644 .github/workflows/post_release.yml
 create mode 100644 CHANGELOG.md
 create mode 100644 LICENSE
 create mode 100644 example/example.md
 create mode 100644 justfile
 create mode 120000 packages/interactive/CHANGELOG.md
 create mode 120000 packages/interactive/LICENSE
 create mode 120000 packages/interactive/README.md

D:\code\dart\dart_interactive\packages\interactive>dart run --enable-vm-service bin/interactive.dart
The Dart VM service is listening on http://127.0.0.1:8181/7yCYZWVshzE=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/7yCYZWVshzE=/devtools/#/?uri=ws%3A%2F%2F127.0.0.1%3A8181%2F7yCYZWVshzE%3D%2Fws
Run: D:\apps\flutter\bin\cache\dart-sdk\bin\dart.exe [--enable-vm-service, file:///D:/code/dart/dart_interactive/packages/interactive/bin/interactive.dart, --vm-service-was-enabled]
Could not start the VM service: localhost:8181 is already in use.

D:\code\dart\dart_interactive\packages\interactive>netstat -nao|findstr 8181

D:\code\dart\dart_interactive\packages\interactive>dart run --enable-vm-service bin/interactive.dart
The Dart VM service is listening on http://127.0.0.1:8181/bfsiTaXMX_w=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/bfsiTaXMX_w=/devtools/#/?uri=ws%3A%2F%2F127.0.0.1%3A8181%2FbfsiTaXMX_w%3D%2Fws
Run: D:\apps\flutter\bin\cache\dart-sdk\bin\dart.exe [--enable-vm-service, file:///D:/code/dart/dart_interactive/packages/interactive/bin/interactive.dart, --vm-service-was-enabled]
Could not start the VM service: localhost:8181 is already in use.

D:\code\dart\dart_interactive\packages\interactive>
fzyzcjy commented 1 year ago

8181 is probably because you already start one, and do not stop/kill it

btw CI on windows runs well. could you please check that to see differences?

liudonghua123 commented 1 year ago

Yes, I changed to another port like 12345. It seems work now.

From the console log, I found both 12345 and 8181 used internal?

D:\code\dart\dart_interactive\packages\interactive>dart run --enable-vm-service=12345 bin/interactive.dart
The Dart VM service is listening on http://127.0.0.1:12345/AaP2buyvNjQ=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:12345/AaP2buyvNjQ=/devtools/#/?uri=ws%3A%2F%2F127.0.0.1%3A12345%2FAaP2buyvNjQ%3D%2Fws
Run: D:\apps\flutter\bin\cache\dart-sdk\bin\dart.exe [--enable-vm-service, file:///D:/code/dart/dart_interactive/packages/interactive/bin/interactive.dart, --vm-service-was-enabled]
The Dart VM service is listening on http://127.0.0.1:8181/0G1Fddx3S8c=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/0G1Fddx3S8c=/devtools/#/?uri=ws%3A%2F%2F127.0.0.1%3A8181%2F0G1Fddx3S8c%3D%2Fws
Workspace: C:\Users\LIUD~1.H\AppData\Local\Temp\dart_interactive_workspace_2022-10-23T213208841490
>>> String hello="hello"
[WARNING 2022-10-23 21:32:20.425019] Error: Hot reload failed, maybe because code has syntax error?
>>> var hello="hello";
[WARNING 2022-10-23 21:32:32.773892] Please use `a=1` instead of `var a=1`
>>> a=1
1
>>> hello="hello"
hello
>>>
fzyzcjy commented 1 year ago

Weird. I suspect it is run twice. i.e. interactive calls interactive calls interactive (originally should be: interactive calls interactive, where the latter has vm serviice enabled)

fzyzcjy commented 1 year ago

Oh I see, please do not use dart run!

fzyzcjy commented 1 year ago

use new syntax here: https://github.com/fzyzcjy/dart_interactive#-getting-started

liudonghua123 commented 1 year ago

use new syntax here: https://github.com/fzyzcjy/dart_interactive#-getting-started

Thanks, now I tried the new usage, it works.

C:\Users\Liu.D.H>dart pub global activate interactive
Resolving dependencies...
Because pub global activate depends on interactive any which doesn't exist (could not find package interactive at
  https://mirrors.tuna.tsinghua.edu.cn/dart-pub/), version solving failed.

C:\Users\Liu.D.H>set PUB_HOSTED_URL=

C:\Users\Liu.D.H>dart pub global activate interactive
Resolving dependencies...
+ _fe_analyzer_shared 49.0.0
+ analyzer 5.1.0
+ args 2.3.1
+ async 2.9.0
+ cli_repl 0.2.3
+ collection 1.17.0
+ convert 3.1.1
+ crypto 3.0.2
+ file 6.1.4
+ glob 2.1.0
+ interactive 1.0.1
+ js 0.6.5
+ logging 1.1.0
+ meta 1.8.0
+ package_config 2.1.0
+ path 1.8.2
+ pub_semver 2.1.2
+ source_span 1.9.1
+ string_scanner 1.1.1
+ term_glyph 1.2.1
+ typed_data 1.3.1
+ vm_service 9.4.0
+ watcher 1.0.2
+ yaml 3.1.1
Downloading interactive 1.0.1...
Downloading path 1.8.2...
Downloading logging 1.1.0...
Downloading collection 1.17.0...
Downloading cli_repl 0.2.3...
Downloading args 2.3.1...
Downloading analyzer 5.1.0...
Downloading _fe_analyzer_shared 49.0.0...
Downloading meta 1.8.0...
Downloading js 0.6.5...
Downloading yaml 3.1.1...
Downloading string_scanner 1.1.1...
Downloading watcher 1.0.2...
Downloading package_config 2.1.0...
Downloading crypto 3.0.2...
Downloading typed_data 1.3.1...
Downloading vm_service 9.4.0...
Downloading pub_semver 2.1.2...
Downloading glob 2.1.0...
Downloading source_span 1.9.1...
Downloading term_glyph 1.2.1...
Downloading convert 3.1.1...
Downloading file 6.1.4...
Downloading async 2.9.0...
Building package executables...
Built interactive:interactive.
Installed executable interactive.
Activated interactive 1.0.1.

C:\Users\Liu.D.H>interactive
Run: D:\apps\flutter\bin\cache\dart-sdk\bin\dart.exe [--enable-vm-service, file:///C:/Users/Liu.D.H/AppData/Local/Pub/Cache/global_packages/interactive/bin/interactive.dart-2.18.2.snapshot, --vm-service-was-enabled]
The Dart VM service is listening on http://127.0.0.1:8181/C42iBdZFGzs=/
The Dart DevTools debugger and profiler is available at: http://127.0.0.1:8181/C42iBdZFGzs=/devtools/#/?uri=ws%3A%2F%2F127.0.0.1%3A8181%2FC42iBdZFGzs%3D%2Fws
Workspace: C:\Users\LIUD~1.H\AppData\Local\Temp\dart_interactive_workspace_2022-10-23T213851628321
>>> hello="hello"
hello
>>>
fzyzcjy commented 1 year ago

great!