I have these pieces of configurations in my workflow.
steps:
- uses: actions/checkout@v1
- uses: DanTup/gh-actions/setup-dart@master
- name: Build
run: |
pub get
mkdir build
dart2native bin/main.dart -v -o build/${{ matrix.output-name }}
shell: bash
I got pub: command not found issue.
If I remove shell: bash and use the builtin shell, then it’s ok.
@liudonghua123 ,
You can try using " pub.bat" instead of directly " pub" to run the commands, this can also work on bash shell.
For example:
- name: Run pub with bash
shell: bash
run: |
pub.bat get
- name: Run pub with pwsh
shell: pwsh
run: |
pub.bat get
1 Like
I can’t use this syntax, because I used matrix strategy and I need to run the command in MacOS and Linux too. In my opinion, we should find the true reasons, fix the PATH inheritance in bash of git in Windows. Command of Windows can run without extension defined in PATHEXT environment variable.
Finally, I refactor the code like the following.
- name: Build
run: |
# check Linux/MacOS or Windows
if hash pub 2>/dev/null; then PUB=pub; DART2NATIVE=dart2native; else PUB=pub.bat; DART2NATIVE=dart2native.bat; fi
mkdir build
$PUB get
$DART2NATIVE bin/main.dart -v -o build/${{ matrix.output-name }}
shell: bash
@liudonghua123 ,
Thanks for sharing your workarond.
I also tested the pub commands after installing the Dart-SDK on my local Windows machine, and I also reproduce same issue. Looks like, this problem occurs on Windows, and it should not be an issue for GitHub Actions.
Similar to your shared workaround, I also have a workaround to run the pub commands with bash shell on different OSs.
jobs:
TEST:
name: Test
runs-on: ${{ matrix.os }}
env:
PUB: pub
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: setup-dart
uses: DanTup/gh-actions/setup-dart@master
- name: Change env
if: matrix.os == 'windows-latest'
run: echo "::set-env name=PUB::pub.bat"
- name: Test pub command
shell: bash
run: |
$PUB --help
1 Like
@brightran wrote:
@liudonghua123 ,
Thanks for sharing your workarond.
I also tested the pub commands after installing the Dart-SDK on my local Windows machine, and I also reproduce same issue. Looks like, this problem occurs on Windows, and it should not be an issue for GitHub Actions.
Similar to your shared workaround, I also have a workaround to run the pub commands with bash shell on different OSs.
jobs:
TEST:
name: Test
runs-on: ${{ matrix.os }}
env:
PUB: pub
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: setup-dart
uses: DanTup/gh-actions/setup-dart@master
- name: Change env
if: matrix.os == ‘windows-latest’
run: echo “::set-env name=PUB::pub.bat”
- name: Test pub command
shell: bash
run: |
$PUB --help
Thanks, your solution is more elegance and readable.