Github.action_path contains `\` on windows runners even when the shell is set to bash

I’m trying to use ${{ github.action_path }} in a composite action.

When I run a workflow containing this action on a Windows runner, the path contains backslashes, even if the shell is set to bash:

##[debug]Evaluating: format('julia --color=yes {0}/main.jl', github.action_path)
##[debug]Evaluating format:
##[debug]..Evaluating String:
##[debug]..=> 'julia --color=yes {0}/main.jl'
##[debug]..Evaluating Index:
##[debug]....Evaluating github:
##[debug]....=> Object
##[debug]....Evaluating String:
##[debug]....=> 'action_path'
##[debug]..=> 'd:\a\_actions\julia-actions\julia-processcoverage\composite'
##[debug]=> 'julia --color=yes d:\a\_actions\julia-actions\julia-processcoverage\composite/main.jl'
##[debug]Result: 'julia --color=yes d:\a\_actions\julia-actions\julia-processcoverage\composite/main.jl'
##[debug]Loading env
##[debug]Run julia --color=yes d:\a\_actions\julia-actions\julia-processcoverage\composite/main.jl
##[debug]julia --color=yes d:\a\_actions\julia-actions\julia-processcoverage\composite/main.jl
##[debug]shell: C:\Program Files\Git\bin\bash.EXE --noprofile --norc -e -o pipefail {0}
##[debug]
##[debug]C:\Program Files\Git\bin\bash.EXE --noprofile --norc -e -o pipefail d:\a\_temp\574911a6-bba0-4689-9ca9-7ed9a1eaba1c.sh
ERROR: could not open file d:\a\StringBuilders.jl\StringBuilders.jl\a_actionsjulia-actionsjulia-processcoveragecomposite\main.jl

Example build

This makes the step fail, because the backslashes aren’t escaped properly to be used in bash.

What is the recommended way to use github.action_path in a cross-platform way while using bash as shell for the step?

Hi @saschamann,

Please use $GITHUB_ACTION_PATH instead.

    - run: julia --color=yes $GITHUB_ACTION_PATH/main.jl
      shell: bash

Doc here: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsstepsrun

Thanks.

1 Like

That worked, thank you :slight_smile: