Closed GabrielL closed 7 months ago
Can you run the import once as root? It looks like it can't write the generated file because it doesn't have permissions. Once the file is created, it should just read it.
Alternatively, install the package in user
home directory so it has access.
Can you run the import once as root? It looks like it can't write the generated file because it doesn't have permissions. Once the file is created, it should just read it.
Alternatively, install the package in
user
home directory so it has access.
That is not an option for me. The user I run can't write into installed python packages, and this is exactly the point.
Here is a sample (reduced) of the situation I am in:
Dockerfile:
FROM python
RUN pip install bashlex
RUN useradd -u 1000 -m -d /user user
WORKDIR /user
USER user
and the execution:
docker run $image_name python -c "import bashlex"
I could run that as root, but packages should be able to be run without extra manipulation.
Perhaps bashlex as a package should run the initial import as a post install sort of thing, while it's still running as the correct user.
This is the first I've heard of someone hitting this issue, and sadly I don't have the time to work on a fix. Suggest you workaround this somehow or maybe you can figure out if what I suggested above is a good approach and implement it.
I was unable to reproduce this issue.
Created the following Dockerfile
:
FROM python
RUN pip install bashlex
RUN useradd -u 1000 -m -d /user user
WORKDIR /user
USER user
Built the Docker image:
$ docker build -t bashlex .
[+] Building 1.2s (9/9) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 37B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:latest 0.9s
=> [auth] library/python:pull token for registry-1.docker.io 0.0s
=> [1/4] FROM docker.io/library/python@sha256:b9683fa80e22970150741c974f45bf1d25856bd76443ea561df4e6fc00c2bc17 0.0s
=> CACHED [2/4] RUN pip install bashlex 0.0s
=> CACHED [3/4] RUN useradd -u 1000 -m -d /user user 0.0s
=> CACHED [4/4] WORKDIR /user 0.0s
=> exporting to image 0.1s
=> => exporting layers 0.0s
=> => writing image sha256:9f42a4e360035637e39ac0dece9140af0d1432ed7db56e8f8622efe577ed403e 0.0s
=> => naming to docker.io/library/bashlex
Ran the command reported to cause error:
$ docker run bashlex python -c "import bashlex"
No apparent errors occur.
Hi,
I am using bashlex, installed system wide (in a container, but that's not the issue), and when I try to import it as an unprivileged user, it shows some errors:
tracking the issue, it seems that https://github.com/idank/bashlex/blob/master/bashlex/yacc.py#L3291 is the call that write this file.