Open eccles opened 2 months ago
Actually there is a better way of fixing this. When creating the venv simply create a dummy hash method:
sed -i '1i function hash { :; }' bin/activate
If you need cross platform support, the sed won't work well for BSD and Mac. I use this similar (but less concise, I may have to modify it now) approach, but I read the file in and then write it out again to avoid sed.
- cmd: |
# The mvdan Go sh interpreter doesn't have the 'hash' builtin, which
# newer versions of the venv activation require. Some systems have
# 'hash' available as an external utility, but Gitea Actions doesn't.
# In that case, we patch the venv activation script to emulate 'hash'
# as a no-op if it's not present.
_venv_file="$(< $VENV_ACTIVATE)"
{
cat << EOF
if ! command -v hash 2>&1 > /dev/null; then
hash(){
true
}
fi
EOF
echo "$_venv_file"
} > $VENV_ACTIVATE
silent: true
When upgrading to ubuntu 24.04 and using a python venv in a task using the builtin shell, an error occurs.
This error is because the built-in shell in go-task does not honour the 'hash' command and the python3 devs removed the conditional check in the 'activate' command.
See https://github.com/pypa/virtualenv/pull/2086
This was mitigated by explicitly using bash.
Example
Fix: