Skip to content

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

Open

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

Activity

  1. YujunWu03 commented on Mar 20, 2026

    @YujunWu03
    Collaborator

    Hi @cqyzc99, thanks for reporting this!Fixed in 283374b. The missing import os has been added to _discovery.py. We also audited the rest of the codebase and fixed 4other files with the same kind of missing stdlib imports (re, shutil).Please pull the latest main and let us know if the issue persists. Thanks again for catching this!

  2. added 2 commits that reference this issue on Mar 20, 2026
    283374b
    67031af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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