Skip to content

Commit 9506b9f

Browse files
committed
Require conda.file when using conda in v1
Some people are migrating from pip to conda, but they were using a v1 config, then when migrating they are using the conda option from v2. We are not validating this, but using conda.file is mandatory when using the conda option (or rtd will fail without any reason). Close readthedocs#5322 Close readthedocs#5228
1 parent ed8dd29 commit 9506b9f

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

readthedocs/config/config.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -489,15 +489,14 @@ def validate_conda(self):
489489
raw_conda = self.raw_config['conda']
490490
with self.catch_validation_error('conda'):
491491
validate_dict(raw_conda)
492-
conda_environment = None
493-
if 'file' in raw_conda:
494-
with self.catch_validation_error('conda.file'):
495-
conda_environment = validate_file(
496-
raw_conda['file'],
497-
self.base_path,
498-
)
499-
conda['environment'] = conda_environment
500-
492+
with self.catch_validation_error('conda.file'):
493+
if 'file' not in raw_conda:
494+
raise ValidationError('file', VALUE_NOT_FOUND)
495+
conda_environment = validate_file(
496+
raw_conda['file'],
497+
self.base_path,
498+
)
499+
conda['environment'] = conda_environment
501500
return conda
502501
return None
503502

readthedocs/config/tests/test_config.py

+12
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,18 @@ def test_validates_conda_file(tmpdir):
582582
assert build.conda.environment == str(tmpdir.join('environment.yml'))
583583

584584

585+
def test_file_is_required_when_using_conda(tmpdir):
586+
apply_fs(tmpdir, {'environment.yml': ''})
587+
build = get_build_config(
588+
{'conda': {'foo': 'environment.yml'}},
589+
source_file=str(tmpdir.join('readthedocs.yml')),
590+
)
591+
with raises(InvalidConfig) as excinfo:
592+
build.validate()
593+
assert excinfo.value.key == 'conda.file'
594+
assert excinfo.value.code == VALUE_NOT_FOUND
595+
596+
585597
def test_requirements_file_empty():
586598
build = get_build_config({})
587599
build.validate()

0 commit comments

Comments
 (0)