You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Non Portable binary, doesn't work with sudo or without LD_LIBRARY_PATH #871
Description:
Python binary is compiled with rpath that's /opt/hostedtoolcache/Python. Now, latest github runners define RUNNER_TOOL_CACHE/AGENT_TOOLSDIRECTORY differently than /opt/hostedtoolcache and that installs python at /home/runner/_work/_tool/Python/. So, with this, there are 2 issues.
sudo python --version doesn't work ( See Error section) because most systems's doesn't allow passing LD_LIBRARY_PATH due to security issues.
python --version doesn't work without setting environment variable LD_LIBRARY_PATH
output of ldd :
runner@arss-runner-xxxx-runner-5jvhz:~/_work/_tool/Python/3.12.3/x64/bin$ ldd python3
linux-vdso.so.1 (0x00007ffceb776000)
libpython3.12.so.1.0 => not found
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7ccc75c000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7ccc991000)
Error:
python: error while loading shared libraries: libpython3.9.so.1.0:
cannot open shared object file: No such file or directory
What could be the reason:
rpath is hardcoded to /opt/hostedtoolcache/Python. if we use $ORIGIN, binaries will be portable. Fix is raised here actions/python-versions#275
Action version:
v5.1.0
Platform:
Ubuntu
macOS
Windows
Runner type:
Hosted
Self-hosted
Tools version:
All versions of Python 3.9.x, 3.10.x, etc.
Repro steps:
You can easily reproduce using following steps. And also, you can unset LD_LIBRARY_PATH and just use without sudo
Expected behavior:
There are times we need to use sudo python and Most system ( also not acceptable to pass) doesn't pass LD_LIBRARY_PATH as environment variable due to security issues.
@priya-kinthali Any update on the PR as it's been 2 months? I see reduced activity with so many open PRs, also see that It's outsourced to some other company. Is this repo still maintained, if not better to handover to other companies which can manage it.
Hello @jaswanthikolla 👋,
Thank you for providing a detailed description of your issue, and we apologize for the delayed response.
For GitHub runners, the default path is /opt/hostedtoolcache, whereas for self-hosted runners, the runner downloads and installs tools into the folder set up by the RUNNER_TOOL_CACHE environment variable. On Linux self-hosted runners, you can change this location by setting the AGENT_TOOLSDIRECTORY environment variable. This allows you to specify any custom directory to install Python on your self-hosted runner using this variable. For more details, refer to the advanced usage documentation.
Here is a potential workaround that you might consider.
Thank you again for the PR. We have already started reviewing it, and testing is underway to check its impact on the overall build environment for both GitHub and self-hosted runners. We will provide feedback once we have tested all possible scenarios.
Now, latest github runners define RUNNER_TOOL_CACHE/AGENT_TOOLSDIRECTORY differently than /opt/hostedtoolcache and that installs python at /home/runner/_work/_tool/Python/
On which runners do you see such behaviour? I would expect all github hosted runners to have tool cache under /opt/hostedtoolcache
@maxim-lobanov For ARSS runners, the default path is /home/runner/_work/_tool/Python/ .
Yes, that workaround will work, but we pursued another workaround internally. Following up if there are any updates on the PR as It's been 3 months. I can't maintain context on it forever to address review comments and so I guess it's time to abandon/close the PR.
I'm not exactly sure why there is a lengthy discussion around this issue. Using ORIGIN is typical in the *nix world, and using hardcoded path (except maybe the standard one like /usr/local/lib) is usually seen as an anti-pattern. In the current case, using a hardcoded path prevents actions/setup-python from being used easily on self-hosted GitHub runners (our case).
Of course there are workarounds, but they decrease the quality of user experience and they increase the maintenance burden of users for their actions and workflows. So let's reverse the question: what are the downsides of starting to use ORIGINas already implemented in the pull request when compared to the status quo? 🤔
If there is no significant downsides, why not just benefit from the community's work and merge the pull request ASAP? 😎
Reacted by Josh Navarro, dmassecoveo, acoricovac, ぐるぐる, Fredrik Wärnsberg, Leo Fang, Zanie Blue and Boris Glimcher
@klalumiere I've resorted to forking both repositories and using that for now. It's been months without a resolution despite @jaswanthikolla's efforts. Her PR works and should be merged.
Reacted by Kevin Lalumiere, dmassecoveo and Moritz-Wohlgenannt
Thank you again for the PR. We have already started reviewing it, and testing is underway to check its impact on the overall build environment for both GitHub and self-hosted runners. We will provide feedback once we have tested all possible scenarios.
This workaround does not work on self-hosted runners with pantsbuild.
We're also affected by this (with our self-hosted runners), did not realize by the end of 2024 there are still real-world Python compiled without relocatability 😢 This is very frustrating for people trying to rely more on GHA and less on custom Python distros (ex: conda)...
I'd like to raise another problem with the LD_LIBRARY_PATH approach — this overrides RUNPATH which means that you can break other Python interpreters on the system. For example, I'm working on musl distributions of CPython over in astral-sh/python-build-standalone#541 and our tests failed in CI because LD_LIBRARY_PATH is set and our Python interpreter loaded the GitHub Actions libpython instead of ours. A bit of an side, but we can't use DT_NEEDED (which takes precedence over LD_LIBRARY_PATH) instead of RUNPATH there because musl doesn't support the $ORIGIN syntax in it.
Using $ORIGIN really is best practice here. If there are downsides to that approach, I'd love to hear it. We've been using $ORIGIN for relocatable Python distributions in python-build-standalone for years now without issue.
Activity
v-aparnajyothi-y commentedon May 20, 2024
Hello @jaswanthikolla, Thank you for creating this issue and we will get back to you once we have some feedback on this :)
jaswanthikolla commentedon May 20, 2024
@aparnajyothi-y I raised the issue just for documentation. PR is already raised to fix this issue, Can you review that.
navarro967 commentedon May 31, 2024
@jaswanthikolla thank you for your efforts thus far, it's a shame there hasn't been more movement on this.
@aparnajyothi-y This is affecting certain ansible modules as well now. I am unable to run my checks now due to this.
jaswanthikolla commentedon Jul 19, 2024
@priya-kinthali Any update on the PR as it's been 2 months? I see reduced activity with so many open PRs, also see that It's outsourced to some other company. Is this repo still maintained, if not better to handover to other companies which can manage it.
v-priya-kinthali commentedon Jul 19, 2024
Hello @jaswanthikolla 👋,
Thank you for providing a detailed description of your issue, and we apologize for the delayed response.
For GitHub runners, the default path is
/opt/hostedtoolcache, whereas for self-hosted runners, the runner downloads and installs tools into the folder set up by theRUNNER_TOOL_CACHEenvironment variable. On Linux self-hosted runners, you can change this location by setting theAGENT_TOOLSDIRECTORYenvironment variable. This allows you to specify any custom directory to install Python on your self-hosted runner using this variable. For more details, refer to the advanced usage documentation.Here is a potential workaround that you might consider.
Thank you again for the PR. We have already started reviewing it, and testing is underway to check its impact on the overall build environment for both GitHub and self-hosted runners. We will provide feedback once we have tested all possible scenarios.
maxim-lobanov commentedon Jul 23, 2024
Hi @jaswanthikolla ,
side question re
On which runners do you see such behaviour? I would expect all github hosted runners to have tool cache under
/opt/hostedtoolcachev-priya-kinthali commentedon Aug 7, 2024
Hello @jaswanthi,
Just a gentle ping to follow up on the previous conversations. Have you had a chance to try the suggested workaround?
Additionally could you please confirm?
Thankyou!
jaswanthikolla commentedon Aug 14, 2024
@maxim-lobanov For ARSS runners, the default path is
/home/runner/_work/_tool/Python/.Yes, that workaround will work, but we pursued another workaround internally. Following up if there are any updates on the PR as It's been 3 months. I can't maintain context on it forever to address review comments and so I guess it's time to abandon/close the PR.
klalumiere commentedon Aug 23, 2024
I'm not exactly sure why there is a lengthy discussion around this issue. Using
ORIGINis typical in the *nix world, and using hardcoded path (except maybe the standard one like/usr/local/lib) is usually seen as an anti-pattern. In the current case, using a hardcoded path preventsactions/setup-pythonfrom being used easily on self-hosted GitHub runners (our case).Of course there are workarounds, but they decrease the quality of user experience and they increase the maintenance burden of users for their actions and workflows. So let's reverse the question: what are the downsides of starting to use
ORIGINas already implemented in the pull request when compared to the status quo? 🤔If there is no significant downsides, why not just benefit from the community's work and merge the pull request ASAP? 😎
navarro967 commentedon Aug 23, 2024
@klalumiere I've resorted to forking both repositories and using that for now. It's been months without a resolution despite @jaswanthikolla's efforts. Her PR works and should be merged.
WTPOptAxe commentedon Nov 7, 2024
This workaround does not work on self-hosted runners with pantsbuild.
leofang commentedon Dec 5, 2024
We're also affected by this (with our self-hosted runners), did not realize by the end of 2024 there are still real-world Python compiled without relocatability 😢 This is very frustrating for people trying to rely more on GHA and less on custom Python distros (ex: conda)...
Abandon setup-python
zanieb commentedon Feb 27, 2025
Hi
I'd like to raise another problem with the
LD_LIBRARY_PATHapproach — this overridesRUNPATHwhich means that you can break other Python interpreters on the system. For example, I'm working on musl distributions of CPython over in astral-sh/python-build-standalone#541 and our tests failed in CI becauseLD_LIBRARY_PATHis set and our Python interpreter loaded the GitHub Actions libpython instead of ours. A bit of an side, but we can't useDT_NEEDED(which takes precedence overLD_LIBRARY_PATH) instead ofRUNPATHthere because musl doesn't support the$ORIGINsyntax in it.Using
$ORIGINreally is best practice here. If there are downsides to that approach, I'd love to hear it. We've been using$ORIGINfor relocatable Python distributions inpython-build-standalonefor years now without issue.mike-essential commentedon Mar 17, 2025
@priya-kinthali please merge this
fix(k9b-live-lab-toolchain): wire LD_LIBRARY_PATH to fix libpython3.1…