shivammathur / setup-php

GitHub action to set up PHP with extensions, php.ini configuration, coverage drivers, and various tools.
https://setup-php.com
MIT License
2.92k stars 341 forks source link

Can't run using nektos/act #494

Closed apepindev closed 3 years ago

apepindev commented 3 years ago

Describe the bug I'm trying to run my workflow locally using nektos/act and this error keeps coming up in the output when setting up PHP, tools and exts;

| /usr/bin/php: error while loading shared libraries: libsodium.so.23: cannot open shared object file: No such file or directory

It eventually fails completely with anything using the php executable;

| /usr/bin/php: error while loading shared libraries: libsodium.so.23: cannot open shared object file: No such file or directory
| /run/act/actions/shivammathur-setup-php@v2/dist/../src/scripts/common.sh: line 134: ext_dir: parameter null or not set
[Testing Laravel/Laravel (PHP 8.0 on ubuntu-latest)]   ❗  ::error::The process '/usr/bin/bash' failed with exit code 1
[Testing Laravel/Laravel (PHP 8.0 on ubuntu-latest)]   ❌  Failure - Setup PHP, with composer and extensions
Error: exit with `FAILURE`: 1

Without tools and extensions defined I get this;

| /usr/bin/php: error while loading shared libraries: libsodium.so.23: cannot open shared object file: No such file or directory
[Testing Laravel/Laravel]   ❌  Failure - PHP version

I've used this action before for a package I made and it worked fine. I just ran it again (both projects using v2) and now I'm getting the same error there too.

Version

Runners

Operating systems ubuntu-latest

PHP versions 8.0

To Reproduce Use the setup-php action, create a step to output php version and run it locally using act.

Expected behavior Run workflow locally without errors.

Screenshots/Logs

❯ act --secret-file ~/.config/act/secrets --container-architecture linux/amd64
[Testing Laravel/Laravel] 🚀  Start image=catthehacker/ubuntu:act-latest
[Testing Laravel/Laravel]   🐳  docker run image=catthehacker/ubuntu:act-latest platform=linux/amd64 entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Testing Laravel/Laravel]   🐳  docker exec cmd=[mkdir -m 0777 -p /var/run/act] user=root
[Testing Laravel/Laravel]   🐳  docker cp src=/Users/andrew/Code/gateway/. dst=/Users/andrew/Code/gateway
[Testing Laravel/Laravel]   🐳  docker exec cmd=[mkdir -p /Users/andrew/Code/gateway] user=
[Testing Laravel/Laravel] ⭐  Run Checkout
[Testing Laravel/Laravel]   ✅  Success - Checkout
[Testing Laravel/Laravel] ⭐  Run Setup PHP, with composer and extensions
INFO[0002]   ☁  git clone 'https://github.com/shivammathur/setup-php' # ref=v2
[Testing Laravel/Laravel] Non-terminating error while running 'git clone': some refs were not updated
[Testing Laravel/Laravel]   🐳  docker cp src=/Users/andrew/.cache/act/shivammathur-setup-php@v2/ dst=/var/run/act/actions/shivammathur-setup-php@v2/
[Testing Laravel/Laravel]   🐳  docker exec cmd=[mkdir -p /var/run/act/actions/shivammathur-setup-php@v2/] user=
[Testing Laravel/Laravel]   🐳  docker exec cmd=[node /var/run/act/actions/shivammathur-setup-php@v2/dist/index.js] user=
| [command]/usr/bin/bash /opt/hostedtoolcache/linux.sh 8.0 /run/act/actions/shivammathur-setup-php@v2/dist
|
| ==> Setup PHP
| /usr/bin/php: error while loading shared libraries: libsodium.so.23: cannot open shared object file: No such file or directory
| /usr/bin/php: error while loading shared libraries: libsodium.so.23: cannot open shared object file: No such file or directory
| /usr/bin/php: error while loading shared libraries: libsodium.so.23: cannot open shared object file: No such file or directory
| /usr/bin/php: error while loading shared libraries: libsodium.so.23: cannot open shared object file: No such file or directory
| /usr/bin/ln: failed to create symbolic link '/Users/andrew/Code/gateway/docker/8.0/conf.d/99-pecl.ini': No such file or directory
[Testing Laravel/Laravel]   ⚙  ::set-output:: php-version=
| ✓ PHP Installed PHP
|
| ==> Setup Tools
| /usr/bin/php: error while loading shared libraries: libsodium.so.23: cannot open shared object file: No such file or directory
| /usr/bin/php: error while loading shared libraries: libsodium.so.23: cannot open shared object file: No such file or directory
| ✓ composer Added composer 2.1.8
|
| ==> Support this project
| ✓ setup-php https://setup-php.com/support
[Testing Laravel/Laravel]   ✅  Success - Setup PHP, with composer and extensions
[Testing Laravel/Laravel] ⭐  Run PHP version
[Testing Laravel/Laravel]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /Users/andrew/Code/gateway/workflow/2] user=
| /usr/bin/php: error while loading shared libraries: libsodium.so.23: cannot open shared object file: No such file or directory
[Testing Laravel/Laravel]   ❌  Failure - PHP version
Error: exit with `FAILURE`: 127

Additional context act version 0.2.24

Are you willing to submit a PR?

apepindev commented 3 years ago

Here's a simplified workflow for reproducing.

# GitHub Action for Laravel
name: Testing Laravel

on: [push, pull_request]

jobs:
  laravel:
    name: Laravel

    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup PHP, with composer and extensions
        uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
        with:
          php-version: '8.0'
#          extensions: mbstring, dom, fileinfo
#          coverage: xdebug #optional

      - name: PHP version
        run: php -v
apepindev commented 3 years ago

Oh and I'm using Docker for Mac on a MBP M1 macOS 11.6. Error persists when using arch emulation too for act. (--container-architecture linux/amd64)

shivammathur commented 3 years ago

@Paradiddley It is recommended to use shivammathur/node images for running setup-php on act. https://hub.docker.com/r/shivammathur/node

act -P ubuntu-latest=shivammathur/node:latest

Refer to: https://github.com/shivammathur/setup-php#local-testing-setup

for other images, you will have to specify the runner as self-hosted.

- name: Setup PHP
  uses: shivammathur/setup-php@v2
  env:
    runner: self-hosted
  with:
    php-version: '8.0'
apepindev commented 3 years ago

Sorry, I missed that in the readme. I've tried it and it's running fine now. Thank you for your help and the quick response.