Skip to content

nanoresearch health crashes with NameError: name 'os' is not defined in discover_environments() on Windows #2

@cqyzc99

Description

@cqyzc99

Summary

Running nanoresearch health on Windows crashes during environment discovery because nanoresearch/agents/runtime_env/_discovery.py uses os.environ / os.path.expanduser(...) without importing os.

Environment

  • OS: Windows 11
  • Shell: PowerShell
  • Python: conda environment
  • Project path: D:\NanoResearch

Steps to reproduce

  1. Clone the repo on Windows.
  2. Create and activate a conda environment.
  3. Install the project in editable mode.
  4. Run:
nanoresearch health

Actual behavior

The command crashes with:

NameError:` name 'os' is not defined

Traceback excerpt:

File "D:\NanoResearch\nanoresearch\agents\runtime_env_discovery.py", line 85, in discover_environments
pyenv_root = os.environ.get("PYENV_ROOT") or os.path.expanduser("~/.pyenv")
NameError: name 'os' is not defined

Expected behavior

nanoresearch health should complete normally and report detected Python environments.

Root cause

nanoresearch/agents/runtime_env/_discovery.py references os.environ and os.path.expanduser(...) but does not import os.

Suggested fix

Add the missing import at the top of nanoresearch/agents/runtime_env/_discovery.py:

import os

For example:

from __future__ import annotations

import json
import logging
import os
import platform
import re
import shutil
import subprocess
from pathlib import Path
from typing import Any

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