Rodsevich / arb_utils

A set of tools for working with .arb files (the preferred Dart way of dealing with i18n/l10n/translations)
https://pub.dev/packages/arb_utils
BSD 3-Clause "New" or "Revised" License
19 stars 12 forks source link

Attempting to activate globally causes large amounts of build errors #6

Closed DanielArndt closed 2 years ago

DanielArndt commented 2 years ago

I've been using arb_utils as a script for several months successfully, however it seems to not be working any more since I cleared my cache. I tried debugging as much as I could on my own, but it's getting out of my level of knowledge.

To make sure I've started with a clean slate, I tried the following:

dart pub cache clean
dart pub global activate arb_utils

The start of the output looks like this:

Resolving dependencies...
+ _fe_analyzer_shared 47.0.0 (50.0.0 available)
+ analyzer 4.7.0 (5.2.0 available)
+ arb_utils 0.3.0
+ archive 3.3.2
+ args 2.3.1
+ async 2.10.0
+ characters 1.2.1
+ clock 1.1.1
+ collection 1.16.0 (1.17.0 available)
+ convert 3.1.1
+ crypto 3.0.2
+ dart_style 2.2.4
+ ffi 2.0.1
+ file 6.1.4
+ flutter 0.0.0 from sdk flutter
+ flutter_web_plugins 0.0.0 from sdk flutter
+ glob 2.1.0
+ http 0.13.5
+ http_parser 4.0.2
+ intl 0.17.0
+ intl_utils 2.7.0
+ js 0.6.4 (0.6.5 available)
+ material_color_utilities 0.1.5 (0.2.0 available)
+ meta 1.8.0
+ package_config 2.1.0
+ path 1.8.2
+ path_provider_linux 2.1.7
+ path_provider_platform_interface 2.0.5
+ path_provider_windows 2.1.3
+ petitparser 5.1.0
+ platform 3.1.0
+ plugin_platform_interface 2.1.3
+ process 4.2.4
+ pub_semver 2.1.2
+ shared_preferences 2.0.15
+ shared_preferences_android 2.0.14
+ shared_preferences_ios 2.1.1
+ shared_preferences_linux 2.1.1
+ shared_preferences_macos 2.0.4
+ shared_preferences_platform_interface 2.1.0
+ shared_preferences_web 2.0.4
+ shared_preferences_windows 2.1.1
+ sky_engine 0.0.99 from sdk flutter
+ source_span 1.9.1
+ string_scanner 1.1.1
+ term_glyph 1.2.1
+ typed_data 1.3.1
+ vector_math 2.1.2 (2.1.4 available)
+ watcher 1.0.2
+ win32 3.0.1
+ xdg_directories 0.2.0+2
+ yaml 3.1.1
Building package executables...
Failed to build arb_utils:sort:
projects/flutter/packages/flutter/lib/src/material/animated_icons.dart:9:8: Error: Not found: 'dart:ui'
import 'dart:ui' as ui show Paint, Path, Canvas;
       ^
projects/flutter/packages/flutter/lib/src/material/animated_icons.dart:10:8: Error: Not found: 'dart:ui'
import 'dart:ui' show lerpDouble;
       ^

and it just goes on and on. Eventually it ends with this:

projects/flutter/packages/flutter/lib/src/semantics/semantics.dart:4591:12: Error: 'TextDirection' isn't a type.
  required TextDirection? thisTextDirection,
           ^^^^^^^^^^^^^
projects/flutter/packages/flutter/lib/src/semantics/semantics.dart:4592:12: Error: 'TextDirection' isn't a type.
  required TextDirection? otherTextDirection,
           ^^^^^^^^^^^^^
projects/flutter/packages/flutter/lib/src/semantics/semantics.dart:4599:12: Error: Undefined name 'TextDirection'.
      case TextDirection.rtl:
           ^^^^^^^^^^^^^
projects/flutter/packages/flutter/lib/src/semantics/semantics.dart:4602:12: Error: Undefined name 'TextDirection'.
      case TextDirection.ltr:
           ^^^^^^^^^^^^^
projects/flutter/packages/flutter/lib/src/semantics/semantics_event.dart:87:9: Error: 'TextDirection' isn't a type.
  final TextDirection textDirection;
        ^^^^^^^^^^^^^
projects/flutter/packages/flutter/lib/src/semantics/semantics_service.dart:32:48: Error: 'TextDirection' isn't a type.
  static Future<void> announce(String message, TextDirection textDirection) async {
                                               ^^^^^^^^^^^^^
projects/flutter/packages/flutter/lib/src/painting/_network_image_io.dart:134:18: Error: 'ImmutableBuffer' isn't a type.
        final ui.ImmutableBuffer buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
                 ^^^^^^^^^^^^^^^
projects/flutter/packages/flutter/lib/src/painting/_network_image_io.dart:134:52: Error: Undefined name 'ImmutableBuffer'.
        final ui.ImmutableBuffer buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
                                                   ^^^^^^^^^^^^^^^

I've upgraded flutter to the latest version

$ dart --version                                                                                                                                                                                                                                                               
Dart SDK version: 2.18.2 (stable) (Tue Sep 27 13:24:11 2022 +0200) on "linux_x64"
[12:45:53] darndt@ringwood ~    
$ flutter --version                                                                                                                                                                                                                                                            
Flutter 3.3.6 • channel stable • git@github.com:flutter/flutter.git
Framework • revision 6928314d50 (6 days ago) • 2022-10-25 16:34:41 -0400
Engine • revision 3ad69d7be3
Tools • Dart 2.18.2 • DevTools 2.15.0
$ flutter doctor                                                                                                                                                                                                                    
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.6, on Ubuntu 22.04.1 LTS 5.15.0-52-generic, locale en_CA.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.72.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

• No issues found!

Happy to do more digging, but I have no idea where to keep looking. Flutter and dart appear to work fine otherwise, but I still acknowledge this could be related to my setup. I just don't know how to debug further.

Rodsevich commented 2 years ago

I think the problem is that you are running it from Dart instead of Flutter. And as the package depends on Flutter libs it need to be ran from flutter instead. Try just changing the command from dart pub global activate arb_utils to flutter pub global activate arb_utils and let's see if that does the trick

DanielArndt commented 2 years ago

Same error with flutter pub .... I tried clearing the cache again as well, no luck.

DanielArndt commented 2 years ago

Hmm. I just cloned the repo and activated it with

dart pub global activate --source path projects/arb_utils

and it works fine.

DanielArndt commented 2 years ago

Scratch that. It "activates", but I guess it doesn't build until I execute

dart pub global run arb_utils:sort lib/l10n/arb/app_en.arb

When I do that, I get the same error as above.

But, I'm able to successfully activate and run if I checkout version 0.2.0 of arb_utils instead.

DanielArndt commented 2 years ago

The culprit seems to be

https://github.com/Rodsevich/arb_utils/blob/25b6625d9d456153ff9b2e77f97855fc2c595d0d/lib/arb_utils.dart#L9

Which in turn depends on flutter

https://github.com/Rodsevich/arb_utils/blob/25b6625d9d456153ff9b2e77f97855fc2c595d0d/lib/src/utils/locale.dart#L1

I made #7 to attempt to fix this, although I don't know if it is the correct approach.

Rodsevich commented 2 years ago

I made a 0.4.0 version with a good approach and so, but it seems to just read the incompatibility with flutter and refuses to work:

$ dart pub global activate arb_utils
$ arb_utils
Can't load Kernel binary: Invalid kernel binary format version.
arb_utils as globally activated requires the Flutter SDK, which is unsupported for global executables.

It seems the Flutter part must be decoupled from this package. So sad