Skip to content

Python setup.sh deleting major version directory instead of arch specific directory #1255

Description

@fergoid

Description:
When I use setup-python with a matrix (e.g. arch: [arm, x86]). The setup script (setup.sh) that is being run will delete the Python version directory (e.g. python3.12.8) and not the architecture specific version. This means if I use a matrix and install 'arm' first the 'x86' install will delete the 'arm' installation before proceeding.

We observed this because we want to cache Python runtimes in a shared resource so they can be used by our self hosted runners. We will run scheduled workflows that install/refresh all of the cached versions we need.

Action version:
v6

Platform:

  • [x ] Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • [x ] Self-hosted

Tools version:

Install any Python version using a matrix.

Repro steps:
A description with steps to reproduce the issue. If your have a public example or repo to share, please provide the link.

      matrix:
        arch: [arm, x86]
        version: ['3.12.8']

Expected behavior:
The setup script should delete the architecture specific directory only.

Actual behavior:
You can see clearly from this snippet of the script what is happening

echo "Check if Python hostedtoolcache folder exist..."
if [ ! -d $PYTHON_TOOLCACHE_PATH ]; then
    echo "Creating Python hostedtoolcache folder..."
    mkdir -p $PYTHON_TOOLCACHE_PATH
elif [ -d $PYTHON_TOOLCACHE_VERSION_PATH ]; then
    echo "Deleting Python $PYTHON_FULL_VERSION"
    rm -rf $PYTHON_TOOLCACHE_VERSION_PATH
fi

echo "Create Python $PYTHON_FULL_VERSION folder"
mkdir -p $PYTHON_TOOLCACHE_VERSION_ARCH_PATH

We can work around this by using max-parallel: 1 in our matrix configuration but this significantly slows down our refreshes.

Activity

  1. changed the title [-]setup.sh deleting najor version directory[/-] [+]Python setup.sh deleting major version directory instead of arch specific directory[/+] on Dec 8, 2025
  2. v-priya-kinthali commented on Dec 8, 2025

    @v-priya-kinthali
    Contributor

    Hello @fergoid👋,
    Thank you for reporting this issue. We will investigate it and get back to you as soon as we have some feedback.

  3. v-mahabaleshwars commented on Dec 23, 2025

    @v-mahabaleshwars
    Contributor

    Hi @fergoid,

    The bug exists in the setup.sh script that's bundled inside Python release archives. The script was incorrectly deleting the entire version directory instead of just the architecture-specific subdirectory.

    Resolution:

    This was fixed in actions/python-versions#319 (February 20, 2025).

    Fixed Code:

    if [ ! -d $PYTHON_TOOLCACHE_PATH ]; then
    echo ""Creating Python hostedtoolcache folder...""
    mkdir -p $PYTHON_TOOLCACHE_PATH
    elif [ -d $PYTHON_TOOLCACHE_VERSION_ARCH_PATH ]; then
    echo ""Deleting Python $PYTHON_FULL_VERSION ($ARCH)""
    rm -rf $PYTHON_TOOLCACHE_VERSION_ARCH_PATH
    fi

    However, since the fix is in the installer template, only Python versions built after this date contain the fix.

    Recommended Actions:

    • Upgrade to Python versions built after February 2025:
      Python 3.12.11+ (for 3.12.x series)
      Python 3.13.4+ (for 3.13.x series)

    • Update to actions/setup-python@v6

    • Clear your existing tool cache to get fresh installations:

      rm -rf $RUNNER_TOOL_CACHE/Python/
      

    This should resolve the issue with matrix installations overwriting each other. Please let us know if you have any questions!

  4. v-mahabaleshwars commented on Jan 6, 2026

    @v-mahabaleshwars
    Contributor

    Hi @fergoid,

    Just wanted to follow up on this issue. Were you able to try the recommended actions mentioned above?

    Please let us know if the fix resolved your issue or if you're still experiencing problems. If everything is working as expected, we can go ahead and close this issue.

    Thanks!

  5. fergoid commented on Jan 6, 2026

    @fergoid
    Author

    Hi , no I haven't tried it but we have numerous versions of Python in use so whilst it may work in some situations, it will still be an issue for us. Happy to close this issue though.

    Hi @fergoid,

    Just wanted to follow up on this issue. Were you able to try the recommended actions mentioned above?

    Please let us know if the fix resolved your issue or if you're still experiencing problems. If everything is working as expected, we can go ahead and close this issue.

    Thanks!

  6. v-mahabaleshwars commented on Jan 8, 2026

    @v-mahabaleshwars
    Contributor

    Hi @fergoid,
    We’re going to close this issue.

    If you’re still running into this behavior with the latest version of actions/setup-python after making those adjustments, please feel free to re-open this issue with updated logs and details about your configuration so we can continue to investigate and refine the behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions