mason icon indicating copy to clipboard operation
mason copied to clipboard

fix: On windows path gets resolved with error because all / get replaced with \ even in closing tokens

Open jtdLab opened this issue 2 years ago • 22 comments

Description

/ that are part of the closing tokens aka {{/foo}} get converted to a \ on windows when used in path.

Steps To Reproduce

  1. Brick with __brick__/{{#foo}}boom/baam/booz{{/foo}}/README.md
  2. Generate README.md

Expected Behavior README.md should be generated at location boom\baam\booz\ if foo is true

But instead the /from {{/foo}} gets convertet to a \ and leads to an error OS Error: The system cannot find the path specified

jtdLab avatar Dec 23 '22 04:12 jtdLab

Hi @jtdLab 👋 Thanks for opening an issue!

What is the value of the foo variable in this case? Can you please provide a link to a minimal reproduction sample? Thanks!

felangel avatar Dec 23 '22 04:12 felangel

Checkout the repo:

https://github.com/jtdLab/mason_windows_failure

Hint: the repo contains a github action run which illustrates the problem (mason generation fails on windows and completes on linux.)

Hope that helps

jtdLab avatar Dec 23 '22 22:12 jtdLab

@felangel

jtdLab avatar Dec 29 '22 01:12 jtdLab

@felangel facing the same problem on Windows 10.

FileSystemException: Directory listing failed, path = 'C:/Users/Stefan/AppData/Local/Mason/Cache/git/mason_bricks_aHR0cHM6Ly9naXRodWIuY29tL2thY2l1bGEvbWFzb25fYnJpY2tz_b7a40356a469ad04579114864c70650cd4f12a50/app\__brick__\{{ projectName.lowerCase() }}\lib\features\common\data\local\{{#useHive}}locvbWFzb25fYnJpY2tz_b7a40356a469ad04579114864c70650cd4f12a50/app\__brical_store.dart{{\*' (OS Error: The system cannot find the path specified. ied. , errno = 3)

stcojo avatar Jan 04 '23 06:01 stcojo

@jtdLab @stcojo sorry for the delay (I was not able to get to this during the holiday break). I'm planning to take a closer look later today and hopefully get a fix for this very soon. Sorry for the inconvenience!

felangel avatar Jan 04 '23 16:01 felangel

@jtdLab can you re-test using the master branch of mason and regenerate the bundle?

felangel avatar Jan 16 '23 21:01 felangel

@felangel im sry but looks like the error seems to be still around after regenerating the bundle.

jtdLab avatar Feb 15 '23 11:02 jtdLab

@felangel I think the error is caused by the Maximum Path Length Limitation in the Windows API

jtdLab avatar Feb 15 '23 14:02 jtdLab

@jtdLab apologies for the delay. I finally tried to reproduce the issue on a windows machine and was not able to reproduce using the latest version of mason. Can you please re-test using the latest version and let me know if this is still an issue for you? Thanks!

felangel avatar Feb 28 '23 04:02 felangel

@felangel i simplified the example at https://github.com/jtdLab/mason_windows_failure the action run illustrates the problem.

jtdLab avatar Feb 28 '23 12:02 jtdLab

@felangel Problem still persists after updating to Updated to 0.1.0-dev.50

stcojo avatar Mar 18 '23 11:03 stcojo

@felangel any updates on this?

jtdLab avatar Mar 24 '23 18:03 jtdLab

@jtdLab apologies for the delay! I need to get my hands on a windows machine (should hopefully be able to pick one up this weekend).

felangel avatar May 19 '23 05:05 felangel

@felangel I think the error is caused by the Maximum Path Length Limitation in the Windows API

@felangel This might help.

jtdLab avatar May 19 '23 12:05 jtdLab

I'm facing a similar issue on Windows 10. I'm using mason's version 0.1.0-dev.50.

Output of `mason add generate -g`
PS > mason add generate -g
PathNotFoundException: Directory listing failed, path = 'C:\Users\BroadBand\AppData\Local\Mason\Cache\hosted\registry.brickhub.dev\generate_0.1.3\__brick__\{{#has_tests}}test\widgets\{{#is_schematic_widget}}{{name.snakeCase()}}\{{#needs_theme_for_widget}}{{name.snakeCase()}}_theme_test.dart{{\needs_theme_for_widget}}{{\*' (OS Error: The system cannot find the path specified.
, errno = 3)
Output of `flutter doctor -v`
[✓] Flutter (Channel stable, 3.10.1, on Microsoft Windows [Version 10.0.19045.2965], locale en-IN)
    • Flutter version 3.10.1 on channel stable at C:\sdks\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d3d8effc68 (7 days ago), 2023-05-16 17:59:05 -0700
    • Engine revision b4fb11214d
    • Dart version 3.0.1
    • DevTools version 2.23.1

[✓] Windows Version (Installed version of Windows is version 10 or higher)

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at C:\Users\BroadBand\AppData\Local\Android\Sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.6.0)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.6.33712.159
    • Windows 10 SDK version 10.0.22000.0

[✓] Android Studio (version 2022.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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 17.0.6+0-b2043.56-9586694)

[✓] VS Code (version 1.78.2)
    • VS Code at C:\Users\BroadBand\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.64.0

[✓] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.2965]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 113.0.5672.127
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 113.0.1774.50

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

predatorx7 avatar May 24 '23 05:05 predatorx7

I just got a windows machine yesterday so I will finally look at this more closely later today. Sorry for the inconvenience!

felangel avatar May 24 '23 13:05 felangel

@felangel Doesn't path package resolve this issue?

yahu1031 avatar Jun 03 '23 19:06 yahu1031

Any updates on this @felangel ? thanks

stcojo avatar Jun 18 '23 15:06 stcojo

I was facing the same issue

The odd thing was that the paths were not congruent image

After debugging the mason_cli locally, I found that the root cause is related to the cache. In my case, this bug seemed to be triggered when I moved the brick directory to another nested location. Since I was working on a globally added local brick, I just run mason remove -g <my_brick> and I didn't struggle with the issue again. I guess the same applies to mason cache clear.

mrverdant13 avatar Aug 21 '23 00:08 mrverdant13

Alright I think we have a related ticket on very_good_flutter_plugin that can quickly reproduce the issue. For all the details take a look at https://github.com/VeryGoodOpenSource/very_good_flutter_plugin/issues/144

Steps to Reproduce

  1. dart pub global activate very_good_cli
  2. dart pub global activate mason_cli
  3. mason add -g very_good_flutter_plugin

Pretty quickly you get the same error message

PathNotFoundException: Directory listing failed, path = 'C:/Users/Tom Arra/AppData/Local/Mason/Cache/hosted/registry.brickhub.dev/very_good_flutter_plugin_0.6.0\__brick__\{{project_name.snakeCase()}}\{{project_name.snakeCase()}}\example\{{#android}}android{{\android}}\app\src\main\kotlin\com\example\{{project_name.snakeCase()}}\*' (OS Error: The system cannot find the path specified.

tomarra avatar Jan 29 '24 19:01 tomarra

Alright I think we have a related ticket on very_good_flutter_plugin that can quickly reproduce the issue. For all the details take a look at VeryGoodOpenSource/very_good_flutter_plugin#144

Steps to Reproduce

  1. dart pub global activate very_good_cli
  2. dart pub global activate mason_cli
  3. mason add -g very_good_flutter_plugin

Pretty quickly you get the same error message

PathNotFoundException: Directory listing failed, path = 'C:/Users/Tom Arra/AppData/Local/Mason/Cache/hosted/registry.brickhub.dev/very_good_flutter_plugin_0.6.0\__brick__\{{project_name.snakeCase()}}\{{project_name.snakeCase()}}\example\{{#android}}android{{\android}}\app\src\main\kotlin\com\example\{{project_name.snakeCase()}}\*' (OS Error: The system cannot find the path specified.

Awesome I’ll have a look asap, thanks!

felangel avatar Jan 30 '24 00:01 felangel

any progress on this? I am facing this issue on Windows 11. This is keeping us from using mason to install new bricks from github

nouman-hanif avatar Apr 19 '24 19:04 nouman-hanif