felangel / mason

Tools which allow developers to create and consume reusable templates called bricks.
https://docs.brickhub.dev
974 stars 97 forks source link

fix: The getter 'STD_HANDLE' isn't defined for the class 'WindowsTerminal'. #1296

Closed lkervran closed 5 months ago

lkervran commented 5 months ago

Description

Using the fvm package that has a dependency to your package make it's installation failed because of this error:

Failed to build fvm:main:
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:9:33: Error: The getter 'STD_HANDLE' isn't defined for the class 'WindowsTerminal'.
 - 'WindowsTerminal' is from 'package:mason_logger/src/ffi/windows_terminal.dart' ('../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'STD_HANDLE'.
    outputHandle = GetStdHandle(STD_HANDLE.STD_OUTPUT_HANDLE);
                                ^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:10:32: Error: The getter 'STD_HANDLE' isn't defined for the class 'WindowsTerminal'.
 - 'WindowsTerminal' is from 'package:mason_logger/src/ffi/windows_terminal.dart' ('../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'STD_HANDLE'.
    inputHandle = GetStdHandle(STD_HANDLE.STD_INPUT_HANDLE);
                               ^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:18:22: Error: Undefined name 'CONSOLE_MODE'.
    const dwMode = (~CONSOLE_MODE.ENABLE_ECHO_INPUT) &
                     ^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:19:11: Error: Undefined name 'CONSOLE_MODE'.
        (~CONSOLE_MODE.ENABLE_PROCESSED_INPUT) &
          ^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:20:11: Error: Undefined name 'CONSOLE_MODE'.
        (~CONSOLE_MODE.ENABLE_LINE_INPUT) &
          ^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:21:11: Error: Undefined name 'CONSOLE_MODE'.
        (~CONSOLE_MODE.ENABLE_WINDOW_INPUT);
          ^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:27:20: Error: Undefined name 'CONSOLE_MODE'.
    const dwMode = CONSOLE_MODE.ENABLE_ECHO_INPUT |
                   ^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:28:9: Error: Undefined name 'CONSOLE_MODE'.
        CONSOLE_MODE.ENABLE_EXTENDED_FLAGS |
        ^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:29:9: Error: Undefined name 'CONSOLE_MODE'.
        CONSOLE_MODE.ENABLE_INSERT_MODE |
        ^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:30:9: Error: Undefined name 'CONSOLE_MODE'.
        CONSOLE_MODE.ENABLE_LINE_INPUT |
        ^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:31:9: Error: Undefined name 'CONSOLE_MODE'.
        CONSOLE_MODE.ENABLE_MOUSE_INPUT |
        ^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:32:9: Error: Undefined name 'CONSOLE_MODE'.
        CONSOLE_MODE.ENABLE_PROCESSED_INPUT |
        ^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:33:9: Error: Undefined name 'CONSOLE_MODE'.
        CONSOLE_MODE.ENABLE_QUICK_EDIT_MODE |
        ^^^^^^^^^^^^
../.pub-cache/hosted/pub.dev/mason_logger-0.2.13/lib/src/ffi/windows_terminal.dart:34:9: Error: Undefined name 'CONSOLE_MODE'.
        CONSOLE_MODE.ENABLE_VIRTUAL_TERMINAL_INPUT;
        ^^^^^^^^^^^^

Seems related to this PR changes https://github.com/felangel/mason/pull/1286

Steps To Reproduce

Use flutter 3.16.7 Run dart pub global activate fvm

Expected Behavior

fvm installed

Additional Context

Opened issue in fvm for more details: https://github.com/leoafarias/fvm/issues/717

renefloor commented 5 months ago

Same thing happens btw if you run dart pub global activate very_good_cli

justatipfromthedeadsequoiatree commented 5 months ago

Same thing happens btw if you run dart pub global activate very_good_cli

same error when running dart pub global activate mason_cli

wolfenrain commented 5 months ago

I suspect it is because the win32 version did not get bumped with this change and it does not correctly resolve to a version that has those enums available.

wolfenrain commented 5 months ago

Opened a PR for that version bump, trying to see if I can reproduce it now using the following command: dart pub global activate --source git https://github.com/felangel/mason --git-path packages/mason_logger --g it-ref a66ff5e3597e64e541c7a6fc0d7593e1cb23286b but weirdly enough the master one also installs just fine so not sure if this is doable without a pubdev release 😅

renefloor commented 5 months ago

FYI, it's using API's from the latest win32 package, which requires Dart 3.3.0. I think if you upgrade your Flutter installation to at least 3.19.0 it resolves the issue. But I can imagine that's not an option for everybody.

felangel commented 5 months ago

Sorry about that! Just published 0.2.14 to revert the change. Will publish 0.2.15 with the updated constraints now 👍 Let me know if you're still having issues, thanks!

lkervran commented 5 months ago

Working fine now ! Thanks for the fix @felangel

felangel commented 5 months ago

Just published 0.2.15 of mason logger which includes the win32 upgrade but should only be pulled down if you have a compatible Flutter/Dart version now. If anyone is still facing any issues please let me know and thanks everyone for your help and patience! 💙