taiki-e / install-action

GitHub Action for installing development tools (mainly from GitHub Releases).
Apache License 2.0
246 stars 32 forks source link

Fails to install binaries when running on `actions-runner-controller` default images #543

Closed lukehsiao closed 3 weeks ago

lukehsiao commented 4 weeks ago

GitHub actions publishes their own images which are used by default by the actions-runner-controller.

However, these images appear to differ from when we run actions with GitHub-hosted runners in that the taiki-e/install-action fails due to lack of permissions.

Run taiki-e/install-action@just
Run bash --noprofile --norc "${GITHUB_ACTION_PATH:?}/main.sh"
info: host platform: x86_64_linux
Install packages required for installation (jq, curl, and/or tar)
  Reading package lists...
  Building dependency tree...
  Reading state information...
  ca-certificates is already the newest version (20230311ubuntu0.22.04.1).
  The following additional packages will be installed:
    libcurl4 libjq1 libonig5
  The following NEW packages will be installed:
    curl jq libcurl4 libjq1 libonig5
  0 upgraded, 5 newly installed, 0 to remove and 2 not upgraded.
  Need to get 841 kB of archives.
  After this operation, 2347 kB of additional disk space will be used.
  Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libcurl4 amd64 7.81.0-1ubuntu1.16 [2[9](https://github.com/NumbersStationAI/hive/actions/runs/9553638958/job/26334269964#step:3:10)0 kB]
  Get:2 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 curl amd64 7.81.0-1ubuntu1.16 [[19](https://github.com/NumbersStationAI/hive/actions/runs/9553638958/job/26334269964#step:3:21)4 kB]
  Get:3 http://archive.ubuntu.com/ubuntu jammy/main amd64 libonig5 amd64 6.9.7.1-2build1 [172 kB]
  Get:4 http://archive.ubuntu.com/ubuntu jammy/main amd64 libjq1 amd64 1.6-2.1ubuntu3 [133 kB]
  Get:5 http://archive.ubuntu.com/ubuntu jammy/main amd64 jq amd64 1.6-2.1ubuntu3 [52.5 kB]
  debconf: delaying package configuration, since apt-utils is not installed
  Fetched 841 kB in 1s (643 kB/s)
  Selecting previously unselected package libcurl4:amd64.
  (Reading database ... 9137 files and directories currently installed.)
  Preparing to unpack .../libcurl4_7.81.0-1ubuntu1.16_amd64.deb ...
  Unpacking libcurl4:amd64 (7.81.0-1ubuntu1.16) ...
  Selecting previously unselected package curl.
  Preparing to unpack .../curl_7.81.0-1ubuntu1.16_amd64.deb ...
  Unpacking curl (7.81.0-1ubuntu1.16) ...
  Selecting previously unselected package libonig5:amd64.
  Preparing to unpack .../libonig5_6.9.7.1-2build1_amd64.deb ...
  Unpacking libonig5:amd64 (6.9.7.1-2build1) ...
  Selecting previously unselected package libjq1:amd64.
  Preparing to unpack .../libjq1_1.6-2.1ubuntu3_amd64.deb ...
  Unpacking libjq1:amd64 (1.6-2.1ubuntu3) ...
  Selecting previously unselected package jq.
  Preparing to unpack .../jq_1.6-2.1ubuntu3_amd64.deb ...
  Unpacking jq (1.6-2.1ubuntu3) ...
  Setting up libcurl4:amd64 (7.81.0-1ubuntu1.16) ...
  Setting up curl (7.81.0-1ubuntu1.16) ...
  Setting up libonig5:amd64 (6.9.7.1-2build1) ...
  Setting up libjq1:amd64 (1.6-2.1ubuntu3) ...
  Setting up jq (1.6-2.1ubuntu3) ...
  Processing triggers for libc-bin (2.35-0ubuntu3.7) ...
info: installing just@latest
info: downloading https://github.com/casey/just/releases/download/1.29.1/just-1.29.1-x86_64-unknown-linux-musl.tar.gz
info: verifying sha[25](https://github.com/NumbersStationAI/hive/actions/runs/9553638958/job/26334269964#step:3:27)6 checksum for just-1.29.1-x86_64-unknown-linux-musl.tar.gz
mv: cannot move 'just' to '/usr/local/bin/just': Permission denied
Error: Process completed with exit code 1.

It seems like the main.sh already accounts for potentially needing sudo with _sudo, so I'm not exactly sure what the issue is here. Is there perhaps a missing sudo check?

This can be semi-replicated interactively with the following

❯ docker run --rm -it ghcr.io/actions/actions-runner:latest /bin/bash
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

runner@e83d4323c34c:~$ sudo apt update
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [128 kB]
Get:3 http://security.ubuntu.com/ubuntu jammy-security InRelease [129 kB]
Get:4 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy InRelease [24.6 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [127 kB]
Get:6 http://security.ubuntu.com/ubuntu jammy-security/restricted amd64 Packages [2469 kB]
Get:7 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy/main amd64 Packages [2972 B]
Get:8 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages [2183 kB]
Get:9 http://security.ubuntu.com/ubuntu jammy-security/universe amd64 Packages [1092 kB]
Get:10 http://archive.ubuntu.com/ubuntu jammy-updates/restricted amd64 Packages [2542 kB]
Get:11 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages [1917 kB]
Get:12 http://archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 Packages [51.5 kB]
Get:13 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 Packages [1391 kB]
Get:14 http://archive.ubuntu.com/ubuntu jammy-backports/universe amd64 Packages [31.8 kB]
Fetched 12.1 MB in 7s (1661 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
2 packages can be upgraded. Run 'apt list --upgradable' to see them.
runner@e83d4323c34c:~$ touch tmp
runner@e83d4323c34c:~$ mv tmp /usr/local/bin/
mv: cannot move 'tmp' to '/usr/local/bin/tmp': Permission denied

Perhaps these mv commands should have a _sudo prefix?

https://github.com/taiki-e/install-action/blob/0ed897e40fe9188f681f7c6f07cc2128813ceb40/main.sh#L148-L172

taiki-e commented 4 weeks ago

I guess due to the permissions granted to the user, they can't move binaries to /usr/local/bin. We don't want to use sudo if it's possible, so it would be better to stop installing to /usr/local/bin and install to ~/.install-action/bin as we already do on Windows.

taiki-e commented 3 weeks ago

Fixed in 2.40.0.