Docker-stacks: Missing CONDA_PREFIX

Created on 19 May 2020  Â·  4Comments  Â·  Source: jupyter/docker-stacks

I conda installed code-server and jupyter-vscode-proxy in order to run VS Code from JupyterLab. The feedstock for code-server generates a eponymous bash script which relies on the CONDA_PREFIX environment variable. I get a beautiful "VS Code" launcher icon, but upon pressing it, I get the following error in the console:

Error: Cannot find module '/share/code-server/out/node/entry.js'

The error is easily explained by the fact that the /opt/conda prefix is defined in CONDA_DIR while CONDA_PREFIX is empty.

As far as I can tell, CONDA_PREFIX should be defined in any activated conda environment. (Almost all my conda experience is via these Docker images.) Hence I'm filing the issue here.

Would it be appropriate to rename CONDA_DIR to CONDA_PREFIX everywhere? And for good measure set it inside base-notebook to avoid breaking compatibility? Or is there some reason to instead use CONDA_DIR?

Most helpful comment

Hi @maresb

CONDA_DIR even if not standard is basically used everywhere in these images and probably elsewhere in custom images build by users. So it seems complicated to remove it.
Moreover the two variables have not the same intend

  • CONDA_DIR: the root of the conda distribution installation.
  • CONDA_PREFIX: the path to the conda environment source

So they can be different when using different environment.

(base) jovyan@bf28b762e660:/opt/conda$ env | grep -E '(CONDA_DIR|CONDA_PREFIX)'
# CONDA_PREFIX=/opt/conda
# CONDA_DIR=/opt/conda

# In a custom test env
(base) jovyan@bf28b762e660:/opt/conda$ conda activate test
(test) jovyan@bf28b762e660:/opt/conda$ env | grep -E '(CONDA_DIR|CONDA_PREFIX)'
# CONDA_PREFIX=/opt/conda/envs/test
# CONDA_DIR=/opt/conda
# CONDA_PREFIX_1=/opt/conda

What you have pointed and that could be solved is to properly initiate the base environment in the base-notebook since it's not done and so the CONDA_PREFIX is not defined--what is not correct I agree.

# Not set at startup
$ env | grep -E '(CONDA_DIR|CONDA_PREFIX)'
# CONDA_DIR=/opt/conda

# Activating the base environment
$ conda init bash
$ bash
$ conda activate base
$ env | grep -E '(CONDA_DIR|CONDA_PREFIX)'
# CONDA_PREFIX=/opt/conda
# CONDA_DIR=/opt/conda

Maybe I missing something but I guess is something possible.

All 4 comments

CONDA_DIR is indeed non-standard. Unfortunately, just setting some env vars
is not sufficient. Not fully activating the environment is no doubt a
source of subtle problems.... As packages get more complex (e.g anything
that uses Java, or a runtime compiler) they end up relying on activation
scripts.

About the only thing that would work for arbitrary "docker exec" is a
wrapper script in ENTRYPOINT, which might already be used for tini, to do
"source activate".

On Tue, May 19, 2020, 15:49 Ben Mares notifications@github.com wrote:

I conda installed code-server https://github.com/cdr/code-server and
jupyter-vscode-proxy https://github.com/betatim/vscode-binder in order
to run VS Code from JupyterLab. The feedstock for code-server generates a
eponymous bash script
https://github.com/conda-forge/code-server-feedstock/blob/master/recipe/build.sh
which relies on the CONDA_PREFIX environment variable. I get a beautiful
"VS Code" launcher icon, but upon pressing it, I get the following error in
the console:

Error: Cannot find module '/share/code-server/out/node/entry.js'

The error is easily explained by the fact that the /opt/conda prefix is
defined in CONDA_DIR while CONDA_PREFIX is empty.

As far as I can tell, CONDA_PREFIX should be defined in any activated
conda environment. (Almost all my conda experience is via these Docker
images.) Hence I'm filing the issue here.

Would it be appropriate to rename CONDA_DIR to CONDA_PREFIX everywhere?
And for good measure set it inside base-notebook to avoid breaking
compatibility? Or is there some reason to instead use CONDA_DIR?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/jupyter/docker-stacks/issues/1086, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAALCRA67R7B5HUOZX4WSVDRSLPFJANCNFSM4NFJRREA
.

To clarify, I'm not actually using docker exec. I have my own Dockerfile extending these containers, so I'm still using the standard activation scripts. But perhaps this is yet another factor to consider in https://github.com/jupyter/docker-stacks/pull/1052.

Hi @maresb

CONDA_DIR even if not standard is basically used everywhere in these images and probably elsewhere in custom images build by users. So it seems complicated to remove it.
Moreover the two variables have not the same intend

  • CONDA_DIR: the root of the conda distribution installation.
  • CONDA_PREFIX: the path to the conda environment source

So they can be different when using different environment.

(base) jovyan@bf28b762e660:/opt/conda$ env | grep -E '(CONDA_DIR|CONDA_PREFIX)'
# CONDA_PREFIX=/opt/conda
# CONDA_DIR=/opt/conda

# In a custom test env
(base) jovyan@bf28b762e660:/opt/conda$ conda activate test
(test) jovyan@bf28b762e660:/opt/conda$ env | grep -E '(CONDA_DIR|CONDA_PREFIX)'
# CONDA_PREFIX=/opt/conda/envs/test
# CONDA_DIR=/opt/conda
# CONDA_PREFIX_1=/opt/conda

What you have pointed and that could be solved is to properly initiate the base environment in the base-notebook since it's not done and so the CONDA_PREFIX is not defined--what is not correct I agree.

# Not set at startup
$ env | grep -E '(CONDA_DIR|CONDA_PREFIX)'
# CONDA_DIR=/opt/conda

# Activating the base environment
$ conda init bash
$ bash
$ conda activate base
$ env | grep -E '(CONDA_DIR|CONDA_PREFIX)'
# CONDA_PREFIX=/opt/conda
# CONDA_DIR=/opt/conda

Maybe I missing something but I guess is something possible.

Hello,

This change has been implemented in the PR #1166.

Best.

Was this page helpful?
0 / 5 - 0 ratings