Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 3

[BUG] shebang (#!) maximum line length limit 128 in ubuntu-latest workers instead of 256

Solved! Go to Solution.



I am sucessfully using GitHub Actions in one of my open source projects, but I think I came across a small, but important issue in the "ubuntu-latest" worker environment which prevent one of my build jobs to sucessfully build. In this project I run long build jobs and build a complete OS image based on the linux distribution.


As said, for one of my matrix jobs the build fails and after some investigation I found the root cause of the issue being that within the "ubuntu-latest" runner/worker environment the shebang maximum line length limit (BINPRM_BUF_SIZE in /usr/include/linux/binfmts.h) seem to be 128 in the ubuntu-latest 18.04 workers, while in a standard ubuntu 19.10 environment the shebang limit is set to 256. See here:


Standard Ubuntu 19.10:

$ grep BINPRM_BUF_SIZE /usr/include/linux/binfmts.h
#define BINPRM_BUF_SIZE 256

"ubuntu-latest" worker in GitHub Actions:

runner@fv-az32:$ grep BINPRM_BUF_SIZE /usr/include/linux/binfmts.h
#define BINPRM_BUF_SIZE 128


As a result, shell scripts using the shebang qualifier (#! in the top-line of the script) are limited to path length of 128 characters rather than 256 which seem to be more sufficient these days, especially since the checked out directory on a worker is located in /home/runner/work/<PROJECTNAME>/<PROJECTNAME>, which can easily make up already quite a portion of the maximum allowed path/shebang line length limit. In my case this standard path already sums up to 48 out of 128 max characters (/home/runner/work/RaspberryMatic/RaspberryMatic).


So here, in one of the workers the following shell script cannot be executed successfully on the GitHub Actions "ubuntu-latest" workers:

# EASY-INSTALL-ENTRY-SCRIPT: 'meson==0.52.0','console_scripts','meson'
__requires__ = 'meson==0.52.0'
import re
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
        load_entry_point('meson==0.52.0', 'console_scripts', 'meson')()

And that's because the shebang at the top-line sums up to 132 characters. 


After reducing the directory path length by renaming the last "RaspberryMatic" directory to a shortcut name the script can be successfully executed and the build runs correctly.


However, I still feel that the shebang limit should be increased to 256 characters like this already seem to be the case for newer ubuntu versions as otherwise build jobs like mine (which use a third party build environment with automatically generated pathes) may run into the same issue.

2 Replies
GitHub Partner
Message 2 of 3

Re: [BUG] shebang (#!) maximum line length limit 128 in ubuntu-latest workers instead of 256

Looks like this is an OS limitation, not a virtual environment problem.

Currently the latest Linux virtual environment for GitHub-hosted runner is Ubuntu 18.04, I recommend you can try using a self-hosted runner which is installed on your local machine (or VM) with OS is Ubuntu 19.10 or later.

There is a similar case as reference:

Copilot Lvl 3
Message 3 of 3

Re: [BUG] shebang (#!) maximum line length limit 128 in ubuntu-latest workers instead of 256

Please note that I worked around this OS limitation issue within GitHub Actions by having added the following step snippet right after the checkout:


    - uses: actions/checkout@v2

    - name: rename worker directory
      working-directory: ../
      run: |
        mv RaspberryMatic b
        ln -s b RaspberryMatic

Thus, I am simply renaming my working directory from "RaspberryMatic" to "b" and added a symbolic link. This has the effect that during the buildroot build this drops the shebang length limit below 128 and thus the build finishes correctly.