Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate path in $PATH #899

Open
dotysan opened this issue Jan 17, 2024 · 2 comments
Open

duplicate path in $PATH #899

dotysan opened this issue Jan 17, 2024 · 2 comments

Comments

@dotysan
Copy link

dotysan commented Jan 17, 2024

Minor nit. We blindly prepend /usr/local/bin onto the $PATH without looking to see if it's already there. This leads to duplication.

docker run --rm -it python:3.12-slim

Python 3.12.1 (main, Jan 11 2024, 10:03:43) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['PATH']
'/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'

Expected output: /usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin

Or possibly the original path is fine? Since /usr/local/sbin already occurs before /usr/bin and /bin.

This applies to all the base images in here. They all come with PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin for the root user.

@tianon
Copy link
Member

tianon commented Jan 17, 2024

We prepend to PATH to ensure that the Python we just installed there is definitely 100% the Python folks will get if they rely on PATH expansion (and because duplicates are otherwise harmless).

@dotysan
Copy link
Author

dotysan commented Jan 18, 2024

Yes, I get it. Minor nit, indeed.

However, on all base images currently used, one would have to install python in /usr/local/sbin for any change in behavior. Which is astronomically unlikely.

I propose the ENV PATH /usr/local/bin:$PATH line in all Dockerfile here be removed entirely, as it is superfluous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants