conda-build fails with miniforge in base environment

270 Views Asked by At

I am trying to install conda-build into the base environment of Conda (installed via miniforge).

I take the following steps:

  1. Install conda through miniforge
  2. Install conda-build to the base environment using conda install
  3. Try to invoke conda build and get an error

The following dockerfile can be used to demonstrate this problem.

Note: This issue occurs irrespective of using docker or not, I'm just using a dockerfile to make this easier for others to reproduce.

FROM ubuntu:jammy as base
RUN apt update && apt install -y curl
ENV CONDA_HOME=/opt/miniforge
ENV PATH=${CONDA_HOME}/bin:${PATH}
RUN curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" && \
    bash Miniforge3-$(uname)-$(uname -m).sh -b -p $CONDA_HOME && \
    rm Miniforge3-$(uname)-$(uname -m).sh

RUN conda init bash && conda config --set auto_activate_base false


FROM base as test

RUN conda install -n base -y conda-build
RUN conda build --help

The docker build produces the following error even just when trying to invoke --help (the error will also occur when proving normal commands to build a recipe)

 > [test 2/2] RUN conda build --help:                                                                                                                                                   
#0 1.160 
#0 1.160 # >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
#0 1.160 
#0 1.160     Traceback (most recent call last):
#0 1.160       File "/opt/miniforge/lib/python3.10/site-packages/conda/exceptions.py", line 1132, in __call__
#0 1.160         return func(*args, **kwargs)
#0 1.160       File "/opt/miniforge/lib/python3.10/site-packages/conda/cli/main.py", line 69, in main_subshell
#0 1.160         exit_code = do_call(args, p)
#0 1.160       File "/opt/miniforge/lib/python3.10/site-packages/conda/cli/conda_argparse.py", line 115, in do_call
#0 1.160         return args.plugin_subcommand.action(sys.argv[2:])
#0 1.160       File "/opt/miniforge/lib/python3.10/site-packages/conda_build/plugin.py", line 10, in build
#0 1.160         execute(*args, **kwargs)
#0 1.160       File "/opt/miniforge/lib/python3.10/site-packages/conda_build/cli/main_build.py", line 516, in execute
#0 1.160         _parser, args = parse_args(args)
#0 1.160       File "/opt/miniforge/lib/python3.10/site-packages/conda_build/cli/main_build.py", line 470, in parse_args
#0 1.160         check_recipe(args.recipe)
#0 1.160     AttributeError: 'Namespace' object has no attribute 'recipe'
#0 1.160 
#0 1.160 `$ /opt/miniforge/bin/conda build --help`
#0 1.160 
#0 1.160   environment variables:
#0 1.160                  CIO_TEST=<not set>
#0 1.160     CONDA_ALLOW_SOFTLINKS=false
#0 1.160                CONDA_HOME=/opt/miniforge
#0 1.160                CONDA_ROOT=/opt/miniforge
#0 1.160            CURL_CA_BUNDLE=<not set>
#0 1.160                LD_PRELOAD=<not set>
#0 1.160                      PATH=/opt/miniforge/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/
#0 1.160                           sbin:/bin
#0 1.160        REQUESTS_CA_BUNDLE=<not set>
#0 1.160             SSL_CERT_FILE=<not set>
#0 1.160 
#0 1.160      active environment : None
#0 1.160        user config file : /root/.condarc
#0 1.160  populated config files : /opt/miniforge/.condarc
#0 1.160           conda version : 23.3.1
#0 1.160     conda-build version : 3.27.0
#0 1.160          python version : 3.10.12.final.0
#0 1.160        virtual packages : __archspec=1=x86_64
#0 1.160                           __glibc=2.35=0
#0 1.160                           __linux=5.15.49=0
#0 1.160                           __unix=0=0
#0 1.160        base environment : /opt/miniforge  (writable)
#0 1.160       conda av data dir : /opt/miniforge/etc/conda
#0 1.160   conda av metadata url : None
#0 1.160            channel URLs : https://conda.anaconda.org/conda-forge/linux-64
#0 1.160                           https://conda.anaconda.org/conda-forge/noarch
#0 1.160           package cache : /opt/miniforge/pkgs
#0 1.160                           /root/.conda/pkgs
#0 1.160        envs directories : /opt/miniforge/envs
#0 1.160                           /root/.conda/envs
#0 1.160                platform : linux-64
#0 1.160              user-agent : conda/23.3.1 requests/2.31.0 CPython/3.10.12 Linux/5.15.49-linuxkit ubuntu/22.04.3 glibc/2.35
#0 1.160                 UID:GID : 0:0
#0 1.160              netrc file : None
#0 1.160            offline mode : False
#0 1.160 
#0 1.160 
#0 1.160 An unexpected error has occurred. Conda has prepared the above report.

Notably, however, this error won't occur if I first create a new environment:

FROM base as test

# create a separate environment
RUN conda create -n myenv -y conda-build
# now this works
RUN conda run --no-capture-output -n myenv conda build --help

What is causing the error when conda build is used in the base environment and how can it be fixed?

0

There are 0 best solutions below