Closed solipsist01 closed 3 years ago
I've seen the this behavior as well, with containers built with the latest theia. Oddly, my theia terminals are fine on a fresh container, but after a while new terminals have a badly truncated $PATH. Here's a session in a new terminal:
bash-4.4$ echo $PATH
/usr/local/go/bin:
bash-4.4$ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/robot/go/bin:/usr/local/go/bin:/opt/gopherbot
bash-4.4$ ps -ef | grep [m]ain.js
robot 115 97 0 Nov16 ? 00:04:40 node /usr/local/theia/src-gen/backend/main.js /home/robot --hostname 0.0.0.0
bash-4.4$ ps -ef | grep $$
robot 230392 115 0 14:45 pts/4 00:00:00 /bin/bash
robot 230633 230392 0 14:49 pts/4 00:00:00 ps -ef
robot 230634 230392 0 14:49 pts/4 00:00:00 grep 230392
bash-4.4$ cat /proc/115/environ | tr '\0' '\n' | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/robot/go/bin:/usr/local/go/bin:/opt/gopherbot
So, from the above I can see the $PATH is correct in the main.js
process, but in the child bash
process it has been mysteriously pared down to /usr/local/go/bin:
. My workaround for this is exporting the proper path in .bashrc
.
@DukeNgn could you please try to reproduce this issue?
You can fetch one of the image mentioned from dockerhub. e.g.:
$> docker pull theiaide/theia-python:latest
I tried briefly with the python
image on Linux, and could not reproduce.
I can not reproduce this issue on my side as well. Tried with python:latest
image on MacOS
Edit: I also tried with the theia-full
image, freshly pulled from Docker Hub, but still couldn't reproduce the issue
@solipsist01 , @parsley42 ,
Could you share any extra details you may remember? On which OS is your host, and how do you start your containers?
My setup is fairly unusual; I've continued investigating this issue, and my best guess is that something's going wrong with the system /etc/bashrc
definition for pathmunge
. My image is derived from RedHat's ubi8
image. What I don't understand is where pathmunge could be called from; my PATH is strangely truncated to just /usr/local/go/bin:
, but I can't find any shell snippets that configure that path. I have to guess that it's somehow pruning it. Unfortunately, using set -x; exec >$LOG 2>&1
in /etc/profile and /etc/bashrc don't seem to have any effect. I'm going to guess that my issue is different and unrelated to the original posted issue, and more likely related to a strange interaction with the ubi8
profile and bashrc scripts.
... continuing to investigate, I believe I was wrong about any involvement with /etc/profile or /etc/bashrc, neither of which would be invoked by calling just /bin/bash
. Further, I have found that the contents of /prod/<pid>/environ
are the environment vars the process starts with - so when theia creates the /bin/bash process, it's definitely passing on the bad PATH:
$ cat /proc/$$/environ | tr '\0' '\n' | grep PATH
PATH=/usr/local/go/bin:
I'm at a loss on how to further troubleshoot this.
In case it helps, here are the container files used to create my image: 1) https://github.com/lnxjedi/gopherbot-base-containers/blob/master/base/Containerfile 2) https://github.com/lnxjedi/gopherbot-base-containers/blob/master/theia/Containerfile 3) https://github.com/lnxjedi/gopherbot/blob/master/resources/containers/theia/Containerfile
The final container runs the gopherbot
process, which later starts Theia in a sub-process:
SHELL=/bin/bash
THEIA_DEFAULT_PLUGINS=local-dir:/usr/local/theia/plugins
USE_LOCAL_GIT=true
export SHELL THEIA_DEFAULT_PLUGINS USE_LOCAL_GIT
Say "My PATH is $PATH"
cd /usr/local/theia
node /usr/local/theia/src-gen/backend/main.js /home/robot --hostname 0.0.0.0
As expected, the robot says "My PATH is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/robot/go/bin:/usr/local/go/bin:/opt/gopherbot"
Is there something I can do to help track this down?
Hello,
I have changed my docker-compose.yml file to use the latest theia-python image. I cannot reproduce this problem.
I'm running on debian buster and docker 19.03.12 or the image changed, or some update fixed the issue.
This is how i run the container
services:
theia:
container_name: theia
image: theiaide/theia-python:latest
user: "0:0"
hostname: theia
volumes:
- ${SSD}/workspace:/home/project
- /etc/localtime:/etc/localtime:ro
labels:
- "traefik.http.routers.theia.entrypoints=websecure"
- "traefik.http.routers.theia.tls.certresolver=cloudflare"
- "traefik.http.routers.theia.middlewares=cloudflare@docker, auth@docker"
- TZ=${TZ}
networks:
- ${NETWORK}
restart: ${RESTARTPOLICY}
networks:
docker:
name: ${NETWORK}
I'm at a loss on how to further troubleshoot this. [...] As expected, the robot says "My PATH is /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/robot/go/bin:/usr/local/go/bin:/opt/gopherbot"
Is there something I can do to help track this down?
Hi @solipsist01 @parsley42
I really have no idea why that happens. Here's an interesting, related area in the code.
https://github.com/eclipse-theia/theia/blob/master/packages/terminal/src/node/shell-process.ts#L42
function setUpEnvVariables(customEnv?: { [key: string]: string | null }): { [key: string]: string } {
const processEnv: { [key: string]: string } = {};
const prEnv: NodeJS.ProcessEnv = process.env;
Object.keys(prEnv).forEach((key: string) => {
processEnv[key] = prEnv[key] || '';
});
if (customEnv) {
for (const envName of Object.keys(customEnv)) {
processEnv[envName] = customEnv[envName] || '';
}
}
return processEnv;
}
From what I understand, the shell process associated to the terminal starts with the exact same environment as its parent process, the Theia backend process - the entries are copied one-by-one above. There's a provision for adding custom environment variables, that I assume is unused by default.
Oh, looking at the code made me think of one thing: make sure you do not have something funky defined in this preference:
"terminal.integrated.shellArgs.linux"
.
Closing according to feedback from issue creator @solipsist01 confirming this no longer happens in our vanilla images.
I am having the same issue with my image which is a slight variation of the official one.
ARG NODE_VERSION=12.18.3
FROM theiaide/theia-full:1.12.1
USER root
# install docker
ENV DOCKERVERSION=20.10.2
RUN curl -fsSLO https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKERVERSION}.tgz \
&& tar xzvf docker-${DOCKERVERSION}.tgz --strip 1 -C /usr/local/bin docker/docker \
&& rm docker-${DOCKERVERSION}.tgz \
&& apt-get update \
&& apt install -y python3-pip vim \
&& pip3 install docker docker-compose \
&& apt-get clean autoclean \
&& apt-get autoremove --yes
WORKDIR /home/theia
ADD .bashrc /home/theia/.bashrc
ADD .bashrc /root/.bashrc
USER theia
ENTRYPOINT []
CMD [ "node", "/home/theia/src-gen/backend/main.js", "/home/project", "--hostname=0.0.0.0" ]
works fine for a bit, and then the path is broken with all the symptomps above.
root@3b3ba88d7342:/home/project# echo $PATH
/usr/local/go/bin:
I have a suspicion this is caused by the golang extension,
in the local storage on chrome I can see an entry with the key
theia:/:file:///home/project:terminal.integrated.environmentVariableCollections
and value "[{\"extensionIdentifier\":\"golang.go\",\"collection\":[[\"PATH\",{\"value\":\"/usr/local/go/bin:\",\"type\":3}]]}]"
I have the broken version up and running now, tell me if you want me to run any commands for debugging.
Cheers
Hi @alekc ,
Thanks for the detailed problem report. We are looking into it.
This issue is related to issue https://github.com/eclipse-theia/theia/issues/9392, The description of the problem is very detailed. The 'go' language extension is attempting to prepend the location of the 'go' installation folder but the application merge the value too early and it ends up overriding the value of the whole PATH variable. A proposed solution will be posted shortly.
Perhaps it's me, but the latest docker images don't have a default PATH in the terminal I have tested this with the theia-full and theia-python images.
commands like ls or cat don't work in the terminal. I have to set the path manually.
for now i have pulled theiaide/theia-python:1.6.0-next.e36195e0 and here path works as expected