invertase / melos

πŸŒ‹ A tool for managing Dart projects with multiple packages. With IntelliJ and Vscode IDE support. Supports automated versioning, changelogs & publishing via Conventional Commits.
https://melos.invertase.dev/~melos-latest
Apache License 2.0
1.11k stars 198 forks source link

Running melos for flutter pub get with --diff creates race condition for temp files #614

Closed VladimirGradev closed 9 months ago

VladimirGradev commented 9 months ago

Is there an existing issue for this?

Version

3.4.0

Description

When I use melos with --diff and there are many affected packages, flutter pub get for every package is invoked in parallel. Every flutter pub get creates temp folder/file and at some point I got these errors:

[pckg1]: Rename failed, path = '/home/runner/.pub-cache/_temp/dirBCAZFR' (OS Error: File exists, errno = 17)

[pckg2]: Rename failed, path = '/home/runner/.pub-cache/_temp/dirMKUSCN' (OS Error: File exists, errno = 17)

[pckg3]: Rename failed, path = '/home/runner/.pub-cache/_temp/dirDXDYRM' (OS Error: File exists, errno = 17)

[pckg4]: Rename failed, path = '/home/runner/.pub-cache/_temp/dirUITHEZ' (OS Error: File exists, errno = 17)

[pckg5]: Rename failed, path = '/home/runner/.pub-cache/_temp/dirQLMMIO' (OS Error: File exists, errno = 17)

hence it fails.

Steps to reproduce

Create a github action with one step: melos exec --fail-fast --diff=origin/main...HEAD --include-dependents -- flutter pub get --suppress-analytics

Create a change that affects multiple packages

Expected behavior

command executes successfully for all packages

Screenshots

No response

Additional context and comments

[!] Flutter (Channel [user-branch], 3.16.0, on Ubuntu 22.04.3 LTS 5.10.186-179.751.amzn2.x86_64, locale en_US) ! Flutter version 3.16.0 on channel [user-branch] at /home/runner/flutter Currently on an unknown channel. Run flutter channel to switch to an official channel. If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install. ! Upstream repository unknown source is not a standard remote. Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error. β€’ Framework revision db7ef5bf9f (3 weeks ago), 2023-11-15 11:25:44 -0800 β€’ Engine revision 74d16627b9 β€’ Dart version 3.2.0 β€’ DevTools version 2.28.2 β€’ If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[βœ—] Android toolchain - develop for Android devices βœ— Unable to locate Android SDK. Install Android Studio from: https://developer.android.com/studio/index.html On first launch it will assist you in installing the Android SDK components. (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions). If the Android SDK has been installed to a custom location, please use flutter config --android-sdk to update to that location.

[βœ—] Chrome - develop for the web (Cannot find Chrome executable at google-chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[βœ—] Linux toolchain - develop for Linux desktop βœ— clang++ is required for Linux development. It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/ βœ— CMake is required for Linux development. It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from https://cmake.org/download/ βœ— ninja is required for Linux development. It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases βœ— pkg-config is required for Linux development. It is likely available from your distribution (e.g.: apt install pkg-config), or can be downloaded from https://www.freedesktop.org/wiki/Software/pkg-config/

[!] Android Studio (not installed) β€’ Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).

[βœ“] Connected device (1 available) β€’ Linux (desktop) β€’ linux β€’ linux-x64 β€’ Ubuntu 22.04.3 LTS 5.10.186-179.751.amzn2.x86_64

[βœ“] Network resources β€’ All expected network resources are available.

! Doctor found issues in 5 categories.

spydon commented 9 months ago

Can you run it with -c1 instead?

VladimirGradev commented 9 months ago

It works with -c1, but of course , extremely slow.

spydon commented 9 months ago

I'm not sure this would be possible to solve from the Melos side, or do you have any ideas?

VladimirGradev commented 9 months ago

I was wondering if there is some kind of internal race condition. When I set the the step to retry, it usually passes on the second or third try. I will go with -c 1 for now, thanks @spydon .

lukas-tide commented 3 months ago

@spydon do you have any clues where could be the root cause of this? Is it pub which is the root cause of the issue?