Warning: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence

my GitHub action.yml contains https://github.com/wegmans/actions/blob/main/sonarqube/dotnet/begin/action.yml

    - name: Cache SonarQube packages
      uses: actions/cache@v3
      with:
        path: ~/.sonar/cache
        key: ${{ runner.os }}-sonar
        restore-keys: ${{ runner.os }}-sonar

Post Run sonarqube/dotnet/begin@v1
Is throwing this error
Warning: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.

I have tried
path: ~/.sonar/cache
path: ~/sonar/cache
path: ./.sonar/cache

Hi,

Welcome to the community!

Can you share your full pipeline and your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Ann

This is our shared github action and an example of it getting called

Log
Post Run wegmans/actions/sonarqube/dotnet/begin@v1
Post job cleanup.
Post job cleanup.
Cache hit occurred on the primary key Linux-sonar-scanner, not saving cache.
Post job cleanup.
Warning: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.
Post job cleanup.

I think its this line in build.yml is the issue but Ive tried everything
path: ~/.sonar/cache

sq.zip (4.9 KB)

Run wegmans/actions/sonarqube/dotnet/begin@v1
  with:
    sonar_project_key: enterprise-library
    sonar_token: ***
    sonar_args: /d:sonar.cs.opencover.reportsPaths="**/*.opencover.xml"
    github_token: ***
    sonar_host_url: https://sonarqube.wegmans.dev
    working-directory: /home/runner/work/enterprise-library/enterprise-library
  env:
    DOTNET_NOLOGO: true
    DOTNET_CLI_TELEMETRY_OPTOUT: true
    DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
    NUGET_PACKAGES: /home/runner/work/enterprise-library/enterprise-library/.nuget/packages
    VersionPrefix: 8.1.14
    VersionSuffix: pr424.692.0
    DOTNET_ROOT: /usr/share/dotnet
    NUGET: /opt/hostedtoolcache/nuget.exe/6.9.1/x64/nuget.exe
Run actions/setup-java@v3
  with:
    java-version: 17
    distribution: zulu
    java-package: jdk
    check-latest: false
    server-id: github
    server-username: GITHUB_ACTOR
    server-password: GITHUB_TOKEN
    overwrite-settings: true
    job-status: success
    token: ***
  env:
    DOTNET_NOLOGO: true
    DOTNET_CLI_TELEMETRY_OPTOUT: true
    DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
    NUGET_PACKAGES: /home/runner/work/enterprise-library/enterprise-library/.nuget/packages
    VersionPrefix: 8.1.14
    VersionSuffix: pr424.692.0
    DOTNET_ROOT: /usr/share/dotnet
    NUGET: /opt/hostedtoolcache/nuget.exe/6.9.1/x64/nuget.exe
Installed distributions
  Trying to resolve the latest version from remote
  Resolved latest version as 17.0.10+7
  Trying to download...
  Downloading Java 17.0.10+7 (Zulu) from https://cdn.azul.com/zulu/bin/zulu17.48.15-ca-crac-jdk17.0.10-linux_x64.tar.gz ...
  Extracting Java archive...
  /usr/bin/tar xz --warning=no-unknown-keyword -C /home/runner/work/_temp/2623509e-c2bd-4ab3-ae02-aed25691de73 -f /home/runner/work/_temp/2f12651a-56c5-4652-9638-86977e4672f7
  Java 17.0.10+7 was downloaded
  Setting Java 17.0.10+7 as the default
  Creating toolchains.xml for JDK version 17 from zulu
  Writing to /home/runner/.m2/toolchains.xml
  
  Java configuration:
    Distribution: zulu
    Version: 17.0.10+7
    Path: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.10-7/x64
  
Creating settings.xml with server-id: github
Writing to /home/runner/.m2/settings.xml
Run actions/cache@v3
  with:
    path: ./.sonar/cache
    key: Linux-sonar
    restore-keys: Linux-sonar
    enableCrossOsArchive: false
    fail-on-cache-miss: false
    lookup-only: false
  env:
    DOTNET_NOLOGO: true
    DOTNET_CLI_TELEMETRY_OPTOUT: true
    DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
    NUGET_PACKAGES: /home/runner/work/enterprise-library/enterprise-library/.nuget/packages
    VersionPrefix: 8.1.14
    VersionSuffix: pr424.692.0
    DOTNET_ROOT: /usr/share/dotnet
    NUGET: /opt/hostedtoolcache/nuget.exe/6.9.1/x64/nuget.exe
    JAVA_HOME: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.10-7/x64
    JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.10-7/x64
Cache not found for input keys: Linux-sonar, Linux-sonar
Run actions/cache@v3
  with:
    path: ./.sonar/scanner
    key: Linux-sonar-scanner
    restore-keys: Linux-sonar-scanner
    enableCrossOsArchive: false
    fail-on-cache-miss: false
    lookup-only: false
  env:
    DOTNET_NOLOGO: true
    DOTNET_CLI_TELEMETRY_OPTOUT: true
    DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
    NUGET_PACKAGES: /home/runner/work/enterprise-library/enterprise-library/.nuget/packages
    VersionPrefix: 8.1.14
    VersionSuffix: pr424.692.0
    DOTNET_ROOT: /usr/share/dotnet
    NUGET: /opt/hostedtoolcache/nuget.exe/6.9.1/x64/nuget.exe
    JAVA_HOME: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.10-7/x64
    JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.10-7/x64
Cache Size: ~6 MB (6082784 B)
/usr/bin/tar -xf /home/runner/work/_temp/4ba2c309-535f-4547-bb31-d70106ad3c37/cache.tzst -P -C /home/runner/work/enterprise-library/enterprise-library --use-compress-program unzstd
Cache restored successfully
Cache restored from key: Linux-sonar-scanner
Run /home/runner/work/enterprise-library/enterprise-library/.sonar/scanner/dotnet-sonarscanner begin /k:"enterprise-library" /d:sonar.token="***" /d:sonar.host.url="https://sonarqube.wegmans.dev" /d:sonar.cs.opencover.reportsPaths="**/*.opencover.xml"
  /home/runner/work/enterprise-library/enterprise-library/.sonar/scanner/dotnet-sonarscanner begin /k:"enterprise-library" /d:sonar.token="***" /d:sonar.host.url="https://sonarqube.wegmans.dev" /d:sonar.cs.opencover.reportsPaths="**/*.opencover.xml"
  shell: /usr/bin/pwsh -command ". '{0}'"
  env:
    DOTNET_NOLOGO: true
    DOTNET_CLI_TELEMETRY_OPTOUT: true
    DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
    NUGET_PACKAGES: /home/runner/work/enterprise-library/enterprise-library/.nuget/packages
    VersionPrefix: 8.1.14
    VersionSuffix: pr424.692.0
    DOTNET_ROOT: /usr/share/dotnet
    NUGET: /opt/hostedtoolcache/nuget.exe/6.9.1/x64/nuget.exe
    JAVA_HOME: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.10-7/x64
    JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.10-7/x64
    GITHUB_TOKEN: ***
SonarScanner for MSBuild 5.14
Using the .NET Core version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories...
19:10:58.865  Updating build integration targets...
19:10:59.209  Fetching analysis configuration settings...
19:10:59.509  Provisioning analyzer assemblies for cs...
19:10:59.509  Installing required Roslyn analyzers...
19:10:59.51  Processing plugin: csharp version 9.13.0.79967
19:10:59.657  Processing plugin: vbnet version 9.13.0.79967
19:10:59.707  Processing plugin: securitycsharpfrontend version 10.3.0.27281
19:10:59.88  Provisioning analyzer assemblies for vbnet...
19:10:59.88  Installing required Roslyn analyzers...
19:10:59.88  Processing plugin: csharp version 9.13.0.79967
19:10:59.881  Processing plugin: vbnet version 9.13.0.79967
19:10:59.885  Incremental PR analysis: Automatically detected base branch 'main' from CI Provider 'GitHub Actions'.
19:10:59.885  Downloading cache. Project key: enterprise-library, branch: main.
19:10:59.937  Incremental PR analysis: 857 files out of 859 are unchanged.
19:10:59.96  Pre-processing succeeded.

Hi,

That’s the begin step log. What we need comes after that.

Share the Scanner for .NET verbose logs

  • Add /d:"sonar.verbose=true" to the…
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
    • “SonarQubePrepare” or “SonarCloudPrepare” task’s extraProperties argument if you are using Azure DevOps
      • For example:
        - task: SonarCloudPrepare@1
            inputs:
              SonarCloud: 'sonarcloud'
              organization: 'foo'
              scannerMode: 'MSBuild'
              projectKey: 'foo_sonar-scanning-someconsoleapp'
              projectName: 'sonar-scanning-someconsoleapp'
              extraProperties: |
                sonar.verbose=true
        
  • The important logs are in the END step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)

Share the msbuild detailed logs

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

 
Ann

Here is our GitHub Actions with your verbose parm and all sq logs
sq.log (194.6 KB)

Hi,

Thanks for the log.

In the analysis portion of the log, I see this:

INFO: User cache: /home/runner/.sonar/cache

So it looks like that caching is happening automatically.

You’ve specified

path: ~/.sonar/cache

So I suppose ~ isn’t /home/runner but some other user’s home directory.

Does this help?

 
Ann

“automatically” means I dont need this block or I should change the path to /home/runner/.sonar/cache ??

- name: Cache SonarQube packages
  uses: actions/cache@v3
  with:
    path: ~/.sonar/cache
    key: ${{ runner.os }}-sonar
    restore-keys: ${{ runner.os }}-sonar

Thank You,
Rob

Is this in part because we are calling a shared github action in a different repo instead of an action in our own repo?

Hi,

I suspect you don’t need this block. Can you check to see if /home/running/.sonar/cache is non-empty?

 
Ann