Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: invalid PUB_CACHE variable on the windows runner when using git overrides in pubspec #278

Closed
richardshiue opened this issue Mar 2, 2024 · 0 comments · Fixed by #280

Comments

@richardshiue
Copy link
Contributor

richardshiue commented Mar 2, 2024

First and foremost congrats and thank you for maintaining this action.

Version

latest release (version 2.13.0)

Description

When specifying a dependency override in pubspec.yaml to a git ref, calls to flutter pub get and similar fail in the windows runner with the message:

Git error. Command: `git clone --mirror https://github.com/<repo>.git /c/Users/runneradmin/.pub-cache\git\cache\<repo>-<ref>`
stdout: 
stderr: fatal: destination path '/c/Users/runneradmin/.pub-cache\git\cache\<repo>-<ref>' already exists and is not an empty directory.
exit code: 128

I can reproduce with cache either empty (implying false) or true.

Adding this job before using the action fixes the issue.

- name: Export pub environment variable on Windows
  run: |
    if [ "$RUNNER_OS" == "Windows" ]; then
      echo "PUB_CACHE=$LOCALAPPDATA\\Pub\\Cache" >> $GITHUB_ENV
    fi
  shell: bash

I believe the problem is that #265 changes the caching to be two parts: one for the flutter and one for pub cache. However, the default directory for PUB_CACHE is set to $HOME/.pub-cache in all the runners, instead of only macOS and Ubuntu, and then the AppData version in Windows.

On a somewhat related note, I find that supplying a pub-cache-path argument produces a warning

Warning: Unexpected input(s) 'pub-cache-path', valid inputs are ['flutter-version', 'channel', 'cache', 'cache-key', 'pub-cache-key', 'cache-path', 'architecture']

As I understand it from looking at setup.sh, the logic for this parameter seems to be incomplete.

Solution

The solution is to set the value of $GITHUB_ENV's PUB_CACHE to %LOCALAPPDATA%\Pub\Cache if it's empty and the os is Windows. Or use pub-cache-path if it's supplied then export it to $GITHUB_ENV as normal.

Other

Other reports of this issue:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant