dart-lang / webdev

A CLI for Dart web development.
https://pub.dev/packages/webdev
212 stars 75 forks source link

`dart pub global activate webdev` fails with Dart 2.16 beta #1482

Closed domesticmouse closed 2 years ago

domesticmouse commented 2 years ago

Attempting to activate webdev:

$ dart pub global activate webdev
Resolving dependencies... (2.9s)
+ args 2.3.0
+ async 2.8.2
+ browser_launcher 1.0.0
+ build_daemon 3.0.1
+ built_collection 5.1.1
+ built_value 8.1.3
+ charcode 1.3.1
+ checked_yaml 2.0.1
+ clock 1.1.0
+ collection 1.15.0
+ convert 3.0.1
+ crypto 3.0.1
+ dds 2.1.6+2 (2.1.7 available)
+ devtools 2.8.0
+ devtools_server 2.8.0 (2.9.2 available)
+ devtools_shared 2.8.0 (2.9.2 available)
+ dwds 11.5.1
+ fixnum 1.0.0
+ http 0.13.4
+ http_multi_server 3.0.1
+ http_parser 4.0.0
+ intl 0.17.0
+ io 1.0.3
+ json_annotation 4.4.0
+ json_rpc_2 3.0.1
+ logging 1.0.2
+ meta 1.7.0
+ mime 1.0.1
+ package_config 2.0.2
+ path 1.8.1
+ pedantic 1.11.1
+ pool 1.5.0
+ pub_semver 2.1.0
+ pubspec_parse 1.2.0
+ shelf 1.2.0
+ shelf_packages_handler 3.0.0
+ shelf_proxy 1.0.1
+ shelf_static 1.1.0
+ shelf_web_socket 1.0.1
+ source_maps 0.10.10
+ source_span 1.8.1
+ sse 4.1.0
+ stack_trace 1.10.0
+ stream_channel 2.1.0
+ stream_transform 2.0.0
+ string_scanner 1.1.0
+ term_glyph 1.2.0
+ typed_data 1.3.0
+ usage 4.0.2
+ uuid 3.0.5
+ vm_service 7.5.0 (8.1.0 available)
+ watcher 1.0.1
+ web_socket_channel 2.1.0
+ webdev 2.7.7
+ webkit_inspection_protocol 1.0.0
+ yaml 3.1.0
Building package executables... (3.3s)
Failed to build webdev:webdev:
.pub-cache/hosted/pub.dartlang.org/dds-2.1.6+2/lib/src/cpu_samples_manager.dart:73:21: Error: Type 'CpuSamplesEvent' not found.
  void cacheSamples(CpuSamplesEvent samples) {
                    ^^^^^^^^^^^^^^^
.pub-cache/hosted/pub.dartlang.org/dds-2.1.6+2/lib/src/cpu_samples_manager.dart:73:21: Error: 'CpuSamplesEvent' isn't a type.
  void cacheSamples(CpuSamplesEvent samples) {
                    ^^^^^^^^^^^^^^^

Flutter / dart version info:

$ flutter doctor -v

[✓] Flutter (Channel beta, 2.9.0-0.1.pre, on macOS 12.1 21C52 darwin-x64, locale en)
    • Flutter version 2.9.0-0.1.pre at /Users/brettmorgan/flutter
    • Upstream repository https://github.com/flutter/flutter
    • Framework revision 8f1f9c10f0 (10 days ago), 2021-12-14 13:41:48 -0800
    • Engine revision 234aca678a
    • Dart version 2.16.0 (build 2.16.0-80.1.beta)
    • DevTools version 2.9.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/brettmorgan/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.63.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.29.0

[✓] Connected device (3 available)
    • iPhone 13 (mobile) • 95D92E87-6ADE-4EE3-BB9F-A04C27A2C56A • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
    • macOS (desktop)    • macos                                • darwin-x64
      • macOS 12.1 21C52 darwin-x64
    • Chrome (web)       • chrome                               • web-javascript
      • Google Chrome 96.0.4664.110

• No issues found!
domesticmouse commented 2 years ago

/cc @kevmoo for visibility

alvarogfn commented 2 years ago

I changed "CpuSamplesEvent" to "var" and it worked fine. But it's only a temporary solution.

GZGavinZhao commented 2 years ago

I'm on Dart stable (2.15.1 on "linux_x64") and I'm experiencing the same issue.

alextekartik commented 2 years ago

It seems to be related to https://github.com/dart-lang/sdk/issues/47978

Unfortunately webdev is picking up dds 2.1.6+2 which is not working and not dds 2.1.7 due to some depencency conflict.

Resolving dependencies...
Because webdev depends on dds ^2.1.7 which depends on vm_service ^8.1.0, vm_service ^8.1.0 is required.
So, because webdev depends on vm_service >=3.0.0 <8.0.0, version solving failed.

One temporary workaround if you encounter the issue using webdev as @alvarogfn suggested: edit ~/.pub-cache/hosted/pub.dartlang.org/dds-2.1.6+2/lib/src/cpu_samples_manager.dart line 73 and change:

void cacheSamples(CpuSamplesEvent samples) {

to

void cacheSamples(dynamic samples) {

and run

dart pub global deactivate webdev
dart pub global activate webdev

to force recompilation.

GZGavinZhao commented 2 years ago

It's also possible to activate a specific version of webdev. The highest version that work for me was 2.7.4

dart pub global activate webdev 2.7.4
natebosch commented 2 years ago

@bkonyi - was dds published with an invalid constraint?

bkonyi commented 2 years ago

@bkonyi - was dds published with an invalid constraint?

Yes, but 2.1.6+2 and 2.1.7 was supposed to resolve the issues.

natebosch commented 2 years ago

A republish with narrow constraints doesn't always solve the problem when a package was published with too wide constraints. The wide constraints version will get chosen for any solves where the narrow one would be ruled out, so the new package does fix existing bad solves. We could consider a republish with a newer version number and the old code, but I don't know if that will cause other problems.

In this case I think we can either revoke the versions of dds with invalid constraints, or we could get a version of webdev published with constraints that allow the newest vm_service. I'm not sure if anyone with permissions/knowledge to revoke packages is around, most folks are out.

Getting a compatible version published is not trivial, it is not sufficient to widen the local constraints on vm_service. devtools version 2.8.0 depends on the older vm_service, and there is no published version that allows the vm_service compatible with the published versions of dds.

It's not clear the easiest way to make the constraints allow the latest vm_service. Publishing a new devtools would probably work, but that team is out as well.

There is a comment in the pubspec saying that we depend on devtools because we expect devtools_shared would have a dependency through to it anyway, but that doesn't make much sense to me. I don't know why we need that dep, but the folks who might have context on that are also out.

https://github.com/dart-lang/webdev/blob/40f826520a3b5ba3ba72f0864572a49410174c88/webdev/pubspec.yaml#L39

If we assume it's safe and remove that dependency, we'd need to publish both webdev and dwds with widened constraints on vm_service. There are unpublished breaking changes in the repo for dwds, I'm not sure if publishing now would interrupt any specific plans.

I suspect that this will have to wait until more people are back next year.

mnordine commented 2 years ago

This is breaking our CI, unfortunately, on stable Dart 2.15.1. The workaround above isn't going to help much for CI.

To make matters worse, it seems webdev 2.7.4 does not work with Dart 2.15.1:

Installed executable webdev.
Warning: Executable "webdev" runs "bin/webdev.dart", which was not found in webdev.
Activated webdev 2.7.4.
$ webdev build
[SEVERE] Could not find a command named "/usr/lib/dart/bin/snapshots/pub.dart.snapshot".
GZGavinZhao commented 2 years ago

@mnordine If you're really desperate and you only need to build the website, I think you can manually invoke build_runner as I think this is what webdev does under the hood, e.g. dart run build_runner build -o web:build. I forgot the exact command but it should be something similar to that.

bkonyi commented 2 years ago

There is a comment in the pubspec saying that we depend on devtools because we expect devtools_shared would have a dependency through to it anyway, but that doesn't make much sense to me. I don't know why we need that dep, but the folks who might have context on that are also out.

https://github.com/dart-lang/webdev/blob/40f826520a3b5ba3ba72f0864572a49410174c88/webdev/pubspec.yaml#L39

If we assume it's safe and remove that dependency, we'd need to publish both webdev and dwds with widened constraints on vm_service. There are unpublished breaking changes in the repo for dwds, I'm not sure if publishing now would interrupt any specific plans.

I suspect that this will have to wait until more people are back next year.

Unfortunately, I think this assumption does hold. The devtools binaries are shipped in the devtools package under the build directory in the root of the package, and devtools_server needs that directory to serve the application. dwds still relies on this to launch DevTools, but we should move to using the DevTools bundled with the SDK now that we're not publishing new versions through pub.

kenzieschmoll commented 2 years ago

+1 that dwds should switch to launching DevTools from the Dart SDK. Then perhaps the devtools and devtools_server deps can be removed all together. Nonetheless, I did publish devtools 2.9.3 on pub, which has the bumped constraints for vm_service and dds (https://github.com/flutter/devtools/pull/3545). This was to fix a retracted publish of 2.9.2 that users on old SDKs were still pulling down, but also should help unblock this problem.

bkonyi commented 2 years ago

I've also published dds version 2.1.6+3. Using a 2.1.4 SDK to test, this seems to be resolved:

$ xcodebuild/DebugX64/dart-sdk/bin/dart --version
Dart SDK version: 2.14.0 (stable) (Mon Sep 6 13:47:59 2021 +0200) on "macos_x64"
$ xcodebuild/DebugX64/dart-sdk/bin/dart pub global activate webdev
Resolving dependencies... (1.7s)
+ args 2.3.0
+ async 2.8.2
+ browser_launcher 1.0.0
+ build_daemon 3.0.1
+ built_collection 5.1.1
+ built_value 8.1.3
+ charcode 1.3.1
+ checked_yaml 2.0.1
+ clock 1.1.0
+ collection 1.15.0
+ convert 3.0.1
+ crypto 3.0.1
+ dds 2.1.6+3 (2.1.7 available)
+ devtools 2.8.0 (2.9.3 available)
+ devtools_server 2.8.0 (2.9.3 available)
+ devtools_shared 2.8.0 (2.9.3 available)
+ dwds 11.5.0 (11.5.1 available)
+ fixnum 1.0.0
+ http 0.13.4
+ http_multi_server 3.0.1
+ http_parser 4.0.0
+ intl 0.17.0
+ io 1.0.3
+ json_annotation 4.4.0
+ json_rpc_2 3.0.1
+ logging 1.0.2
+ meta 1.7.0
+ mime 1.0.1
+ package_config 2.0.2
+ path 1.8.1
+ pedantic 1.11.1 (discontinued replaced by lints)
+ pool 1.5.0
+ pub_semver 2.1.0
+ pubspec_parse 1.2.0
+ shelf 1.2.0
+ shelf_packages_handler 3.0.0
+ shelf_proxy 1.0.1
+ shelf_static 1.1.0
+ shelf_web_socket 1.0.1
+ source_maps 0.10.10
+ source_span 1.8.1
+ sse 4.1.0
+ stack_trace 1.10.0
+ stream_channel 2.1.0
+ stream_transform 2.0.0
+ string_scanner 1.1.0
+ term_glyph 1.2.0
+ typed_data 1.3.0
+ usage 4.0.2
+ uuid 3.0.5
+ vm_service 7.5.0 (8.1.0 available)
+ watcher 1.0.1
+ web_socket_channel 2.1.0
+ webdev 2.7.6 (2.7.7 available)
+ webkit_inspection_protocol 1.0.0
+ yaml 3.1.0
Building package executables... (3.7s)
Built webdev:webdev.
Installed executable webdev.
Activated webdev 2.7.6.

Thanks for being patient everyone!