Fix TypeError when CONDA_PREFIX is not set

I ran a build with the mode set to `conda` by accident and did not
have the `CONDA_PREFIX` env var set. In that case, `os.getenv` returns
`None`, and passing `None` to create an `os.Path` is not valid. It
will raise a `TypeError`.

> TypeError: expected str, bytes or os.PathLike object, not NoneType

Signed-off-by: Russell Bryant <rbryant@redhat.com>
This commit is contained in:
Russell Bryant 2024-09-28 23:39:01 +00:00
parent 6236634d84
commit 31e235490c
2 changed files with 2 additions and 2 deletions

View file

@ -101,7 +101,7 @@ class StackBuild(Subcommand):
)
else:
build_dir = (
Path(os.getenv("CONDA_PREFIX")).parent
Path(os.getenv("CONDA_PREFIX", "")).parent
/ f"llamastack-{build_config.name}"
)

View file

@ -67,7 +67,7 @@ class StackConfigure(Subcommand):
)
if os.getenv("CONDA_PREFIX"):
conda_dir = (
Path(os.getenv("CONDA_PREFIX")).parent / f"llamastack-{args.config}"
Path(os.getenv("CONDA_PREFIX", "")).parent / f"llamastack-{args.config}"
)
build_config_file = Path(conda_dir) / f"{args.config}-build.yaml"