Skip to content

UnicodeDecodeError when conda-lock install <lock yml> --name <env name> #795

@ETwilight

Description

@ETwilight

Checklist

  • I added a descriptive title
  • I searched open reports and couldn't find a duplicate

What happened?

I am using miniforge3, mamba 2.1.0, conda-lock 3.0.0 on windows 11. My conda-env.yml for the conda environment we are working on, say my-env, previously contains conda-lock and mamba inside as dependencies, and conda-lock.yml is correctly generated from

conda-lock lock --mamba `
  --file conda-env.yml `
  --platform win-64 `
  --platform linux-64 `
  --platform osx-64 `
  --lockfile conda-lock.yml
  1. When I run, insde base, the command
conda-lock install --mamba conda-lock.yml --name my-env

I can successfully update my-env environment with this lock file.
2. When I run, inside my-env, the same command, it will report

Traceback (most recent call last):
  File "C:\Users\username\miniforge3\envs\my-env\Scripts\conda-lock-script.py", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "C:\Users\username\miniforge3\envs\my-env\Lib\site-packages\click\core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\username\miniforge3\envs\my-env\Lib\site-packages\click\core.py", line 1082, in main
    rv = self.invoke(ctx)
  File "C:\Users\username\miniforge3\envs\my-env\Lib\site-packages\click\core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "C:\Users\username\miniforge3\envs\my-env\Lib\site-packages\click\core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\username\miniforge3\envs\my-env\Lib\site-packages\click\core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\username\miniforge3\envs\my-env\Lib\site-packages\click\decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\username\miniforge3\envs\my-env\Lib\site-packages\conda_lock\conda_lock.py", line 1559, in click_install
    install(
    ~~~~~~~^
        conda=conda,
        ^^^^^^^^^^^^
    ...<11 lines>...
        force_platform=force_platform,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\username\miniforge3\envs\my-env\Lib\site-packages\conda_lock\conda_lock.py", line 1618, in install
    install_func(file=lockfile)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "C:\Users\username\miniforge3\envs\my-env\Lib\site-packages\conda_lock\conda_lock.py", line 236, in do_conda_install
    _conda(additional_args)
    ~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\username\miniforge3\envs\my-env\Lib\site-packages\conda_lock\invoke_conda.py", line 139, in _invoke_conda
    stderr = _stderr_to_log(p.stderr)
  File "C:\Users\username\miniforge3\envs\my-env\Lib\site-packages\conda_lock\invoke_conda.py", line 250, in _stderr_to_log
    for line in stderr:
                ^^^^^^
  File "<frozen codecs>", line 325, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbe in position 26: invalid start byte
  1. This is the main issue I found weird. When I run, inside a powershell script import-conda.ps1 (served as a "sub-script" called by a main conda-operation.ps1 --import from inside by & "./import-conda.ps1", although I believe this detail is irrelevant),
conda activate base
conda-lock install --mamba conda-lock.yml --name my-env (the same command as before)

The same UnicodeDecodeError occurs. But I believe I am already in base and the reason "you are updating an environment inside the environment" should really not appear?

**What I hope: **

  1. Is "updating the environment inside the environment" the reason why this UnicodeDecodeError occurs?
  2. If this is the case, probably in usage, help, or when the UnicodeDecodeError occurs, at least warn the users they may be working inside the environment they want to update.
  3. Why after conda activate base would the problem still appear? Is using powershell script instead of working directly in the command line a reason?

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions