Open crazy4pi314 opened 1 year ago
Hi @crazy4pi314,
Thank you for filling this bug report. Unfortunately, the YAML parsing in conda is quite brittle and can sometime lead to undesirable and confusing errors such as the one you experienced.
We cannot say for sure when this particular bug will be resolve, but I have added this to a general user experience concerns epic (i.e. mega-issue) under the section "YAML parsing gone awry". This will be very helpful for us as we continue to make conda better.
Thanks again for the time you took to file this and help make conda better.
Hi there, thank you for your contribution!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed automatically if no further activity occurs.
If you would like this issue to remain open please:
NOTE: If this issue was closed prematurely, please leave a comment.
Thanks!
I just checked this and the latest conda (24.1.0) still has a problem with this malformed file.
(base) andrew@Andrews-MBP-3 ~ % conda env create -f demo.yml
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/conda/exception_handler.py", line 17, in __call__
return func(*args, **kwargs)
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/conda_env/cli/main.py", line 56, in do_call
exit_code = getattr(module, func_name)(arguments, parser)
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/conda/notices/core.py", line 124, in wrapper
return func(*args, **kwargs)
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/conda_env/cli/main_create.py", line 107, in execute
spec = specs.detect(
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/conda_env/specs/__init__.py", line 72, in detect
if spec.can_handle():
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/conda_env/specs/yaml_file.py", line 19, in can_handle
self._environment = env.from_file(self.filename)
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/conda_env/env.py", line 191, in from_file
return from_yaml(yamlstr, filename=filename)
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/conda_env/env.py", line 158, in from_yaml
data = yaml_safe_load(yamlstr)
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/conda/common/serialize.py", line 45, in yaml_safe_load
return _yaml_safe().load(string)
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/ruamel/yaml/main.py", line 451, in load
return constructor.get_single_data()
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/ruamel/yaml/constructor.py", line 112, in get_single_data
node = self.composer.get_single_node()
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/ruamel/yaml/composer.py", line 70, in get_single_node
document = self.compose_document()
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/ruamel/yaml/composer.py", line 92, in compose_document
node = self.compose_node(None, None)
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/ruamel/yaml/composer.py", line 128, in compose_node
node = self.compose_mapping_node(anchor)
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/ruamel/yaml/composer.py", line 209, in compose_mapping_node
item_value = self.compose_node(node, item_key)
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/ruamel/yaml/composer.py", line 126, in compose_node
node = self.compose_sequence_node(anchor)
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/ruamel/yaml/composer.py", line 170, in compose_sequence_node
while not self.parser.check_event(SequenceEndEvent):
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/ruamel/yaml/parser.py", line 139, in check_event
self.current_event = self.state()
File "/Users/andrew/miniforge3/lib/python3.10/site-packages/ruamel/yaml/parser.py", line 544, in parse_block_sequence_entry
raise ParserError(
ruamel.yaml.parser.ParserError: while parsing a block collection
in "<unicode string>", line 6, column 3:
- pip
^ (line: 6)
expected <block end>, but found '?'
in "<unicode string>", line 7, column 3:
pip:
^ (line: 7)
`$ /Users/andrew/miniforge3/bin/conda-env create -f demo.yml`
environment variables:
CIO_TEST=<not set>
CONDA_AUTO_UPDATE_CONDA=false
CONDA_DEFAULT_ENV=base
CONDA_EXE=/Users/andrew/miniforge3/bin/conda
CONDA_PREFIX=/Users/andrew/miniforge3
CONDA_PROMPT_MODIFIER=(base)
CONDA_PYTHON_EXE=/Users/andrew/miniforge3/bin/python
CONDA_ROOT=/Users/andrew/miniforge3
CONDA_SHLVL=1
CURL_CA_BUNDLE=<not set>
LD_PRELOAD=<not set>
PATH=/Users/andrew/miniforge3/bin:/Users/andrew/miniforge3/condabin:/Users/
andrew/anaconda3/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr
/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.s
ystem/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/cod
ex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex
.system/bootstrap/usr/appleinternal/bin:/Library/TeX/texbin:/usr/local
/share/dotnet:~/.dotnet/tools:/Applications/Xamarin
Workbooks.app/Contents/SharedSupport/path-bin:/Users/andrew/.cargo/bin
:/Users/andrew/.dotnet/tools:/usr/local/Cellar/rakudo-
star/2017.07/share/perl6/site/bin
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=<not set>
active environment : base
active env location : /Users/andrew/miniforge3
shell level : 1
user config file : /Users/andrew/.condarc
populated config files : /Users/andrew/miniforge3/.condarc
/Users/andrew/.condarc
conda version : 23.11.0
conda-build version : not installed
python version : 3.10.13.final.0
solver : libmamba (default)
virtual packages : __archspec=1=m2
__conda=23.11.0=0
__osx=14.2.1=0
__unix=0=0
base environment : /Users/andrew/miniforge3 (writable)
conda av data dir : /Users/andrew/miniforge3/etc/conda
conda av metadata url : None
channel URLs : https://conda.anaconda.org/conda-forge/osx-arm64
https://conda.anaconda.org/conda-forge/noarch
https://repo.anaconda.com/pkgs/main/osx-arm64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/osx-arm64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /Users/andrew/miniforge3/pkgs
/Users/andrew/.conda/pkgs
envs directories : /Users/andrew/miniforge3/envs
/Users/andrew/.conda/envs
platform : osx-arm64
user-agent : conda/23.11.0 requests/2.31.0 CPython/3.10.13 Darwin/23.2.0 OSX/14.2.1 solver/libmamba conda-libmamba-solver/23.12.0 libmambapy/1.5.5
UID:GID : 501:20
netrc file : None
offline mode : False
An unexpected error has occurred. Conda has prepared the above report.
If you suspect this error is being caused by a malfunctioning plugin,
consider using the --no-plugins option to turn off plugins.
Example: conda --no-plugins install <package>
Alternatively, you can set the CONDA_NO_PLUGINS environment variable on
the command line to run the command without plugins enabled.
Example: CONDA_NO_PLUGINS=true conda install <package>
If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers? [y/N]: y
Upload successful.
Checklist
What happened?
If you try to create a Conda env from a yaml file that does not match Conda's spec, you get an error from internal to conda with a big stack trace. If you sort through it, you can figure out it was a badly formatted yaml, but it can take a bit for such a simple error. It would be helpful to have a simpler error message surfaced from the parsing step that makes it clearer to the user what happened and easier for them to address quickly.
Reproduce:
environment.yml
Output:
Conda Info
Conda Config
Conda list
Additional Context
This seems to be the same error in #9161