felangel / mason

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

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

Open jtdLab opened 1 year ago

jtdLab commented 1 year ago

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

felangel commented 1 year ago

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!

jtdLab commented 1 year ago

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 commented 1 year ago

@felangel

stcojo commented 1 year ago

@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)

felangel commented 1 year ago

@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 commented 1 year ago

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

jtdLab commented 1 year ago

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

jtdLab commented 1 year ago

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

felangel commented 1 year ago

@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!

jtdLab commented 1 year ago

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

stcojo commented 1 year ago

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

jtdLab commented 1 year ago

@felangel any updates on this?

felangel commented 1 year ago

@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).

jtdLab commented 1 year ago

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

@felangel This might help.

predatorx7 commented 1 year ago

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` ```sh 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. ```
felangel commented 1 year ago

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

yahu1031 commented 1 year ago

@felangel Doesn't path package resolve this issue?

stcojo commented 1 year ago

Any updates on this @felangel ? thanks

mrverdant13 commented 1 year ago

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.

tomarra commented 7 months ago

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.

felangel commented 7 months ago

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!

nouman-hanif commented 4 months ago

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