← Back to Pull requests

fix(libero): Windows compatibility shim for robosuite 1.4.0 (closes #4857) #5305

Closed
Prer1n1 closed this pull request without merging on Nov 19, 2026 03:35 UTC
View on GitHub
Prer1n1 Prer1n1 commented on Nov 10, 2026 16:18 UTC
Author

Closes #4857.

What this PR does

Adds a Windows-only compatibility shim in src/lerobot/sim/integrations/libero.py so native Windows users can run LIBERO without WSL. It runs before the first import robosuite and replicates the robosuite 1.5 behavior that LIBERO's pinned robosuite 1.4.0 lacks on Windows:

1. Redirects ctypes.WinDLL's load of the missing robosuite/utils/mujoco.dll to the DLL that ships with the mujoco Python package.
2. Pre-loads robosuite.macros with MUJOCO_GPU_RENDERING = False so MUJOCO_GL is not force-set to egl (invalid on Windows).
3. Pre-loads robosuite.macros with FILE_LOGGING_LEVEL = None so robosuite never writes to the hard-coded /tmp/robosuite.log path.

The shim is a strict no-op on non-Windows and when robosuite is already imported.

Also updates pyproject.toml to allow sys_platform == 'win32' on the libero extra and the all composite. Full Windows install still depends on a follow-up hf-libero PR to make robomimic/egl-probe optional (CMake unavailable on Windows); will open that once this PR's direction is confirmed.

Context

The four Windows blockers (CMake install failure + the three import failures above) and the compat function were identified and tested on Windows 11 + RTX 3060 by @ahmedsleem109 in #4857, who measured ~41ms/step with both cameras at 256×256 natively vs ~200ms/step in WSL2. Credited as co-author on the commit.

Status


Ready for review. Would appreciate a maintainer's steer on direction:
LeRobot-side shim (this PR) vs. upstream-first fix in hf-libero.

Verification


  • Native Windows 11, Python 3.12 (uv): import lerobot.sim.integrations.libero succeeds end-to-end. See comment below.

  • Linux CI: unaffected (shim is sys.platform == "win32" gated).

  • Tests: 4 unit tests in tests/sim/integrations/test_libero_windows_compat.py, all runnable on Linux CI (no robosuite/mujoco/hf-libero install required on the runner).
  • Review round 1 (addressed in af113b2)


    Thanks to @mangeshraut712 for review. Three substantive points addressed:
  • WinDLL restored too early → redirect now installed for the process lifetime (no finally restore); only rewrites the one canonicalized path, every other WinDLL load is a pass-through.

  • Silent no-op when robosuite is pre-imported → now emits a RuntimeWarning pointing users to import the shim before any robosuite import.

  • No tests → added 4 unit tests (see above).
  • AI disclosure

    This PR was drafted with Claude's help. The architectural choice (shim gated at import time in sim/integrations/libero.py, over patching robosuite's installed source), the specific Windows behaviors being worked around, and the tested compat function all originate from @ahmedsleem109's reproduction in #4857. I reviewed every line and ran local lint/format/security checks; mypy was skipped locally due to pre-existing Windows-only stdlib errors in unrelated files (detailed in the commit message), and passes on Linux CI.

    Diff: 158 lines (+153 / -5) across 3 files Reviewer: mangeshraut712 Review duration: 12197m
    All Vouch review confidence checks passed
    Residual risk 0.06 = Change Risk (0.36) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 158 lines diff across 3 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.77 · 5 substantive comment(s)
    0.77
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    84%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.303
    Real PR Conversation Timeline
    7 items
    Prer1n1 Prer1n1 commented on Nov 10, 2026 17:19 UTC
    Author

    Local verification on native Windows 11 ✅

    Ran the import test today on Windows 11, Python 3.12 via uv (not Anaconda — see note below):

    python -c "import lerobot.sim.integrations.libero; print('OK')"
    ...
    Initializing the default config file...
    The following information is stored in the config file: C:\Users....libero\config.yaml
    ...
    OK

    The shim redirects the missing robosuite\utils\mujoco.dll to the DLL that ships with the mujoco package, pre-loads robosuite.macros with MUJOCO_GPU_RENDERING=False and FILE_LOGGING_LEVEL=None, and then lets robosuite import cleanly. Only noise is the harmless robosuite banner and warnings about an unset private macro file, both pre-existing upstream behavior.

    I did not run a rollout benchmark (my laptop is CPU-only); I verified end-to-end import, which was the failing surface in #4857. @ahmedsleem109's reported ~41ms/step with both cameras at 256×256 on an RTX 3060 stands as the GPU-side evidence.

    Two notes for maintainers

    1. Anaconda-based Python 3.12 fails independently with WinError 1114 on import mujoco — mujoco's own DLL load conflicts with Anaconda base's DLL search path. Not something this PR can or should fix. It works on any non-Anaconda Python 3.12 (python.org, uv, pyenv).

    2. robomimic==0.2.0 prints an interactive prompt on first import: Do you want to specify a custom path for the dataset folder? (Y/N). This is unrelated to this PR but would hang CI on Windows. The follow-up hf-libero PR (making robomimic optional) sidesteps this; alternatively, pre-populating ~/.libero/config.yaml before the first import libero suppresses it.

    Marking Ready for review next.

    mangeshraut712 mangeshraut712 commented on Nov 10, 2026 17:39 UTC
    Reviewer

    The three Windows failures you describe in robosuite 1.4.0 are real, and pre-seeding robosuite.macros plus redirecting the missing mujoco.dll is a reasonable interim shim. A few things that can still break on native Windows:

    1. WinDLL is restored immediately after import robosuite. If 1.4.0 only imports the binding during import robosuite and actually WinDLL()s robosuite/utils/mujoco.dll later (first env construction, first render, lazy utils import), the redirect is already gone and you are back to the missing private DLL. I'd keep the redirect installed for the process, or also drop a real/symlink mujoco.dll into robosuite/utils so later loads succeed without the monkeypatch.

    2. Already-imported robosuite. If the user (or another library) imported robosuite before this module, the shim is a documented no-op — including the MUJOCO_GL=egl and /tmp logging fixes, which then never apply. A warning on that path would save a confusing Windows failure.

    3. No test. This is hard to run on Linux CI, but a test that the helper is a no-op when sys.platform != "win32" and when robosuite is already in sys.modules, plus a unit test of the path-rewrite predicate (normcase(name) == wanted), would at least lock the control flow down.

    Small nit: ctypes.WinDLL = _RedirectedWinDLL is process-global for the duration of the import, which is probably fine, but any concurrent WinDLL of that exact path would also be redirected.

    Prer1n1 Prer1n1 commented on Nov 10, 2026 17:54 UTC
    Author

    Thanks for the careful review @mangeshraut712 — all three substantive points land and I've pushed af113b2 addressing them. Walking through each:

    1. WinDLL restored too early → fixed

    You're right that if robosuite 1.4.0 loads robosuite/utils/mujoco.dll after the initial import robosuite (lazy env construction, first render, submodule reload), the redirect is already gone. I've removed the finally: ctypes.WinDLL = orig_windll restore so the subclass stays installed for the process lifetime. It only rewrites one canonicalized path (os.path.normcase(name) == wanted), so every other WinDLL load in the process is a pass-through to the parent. The docstring now spells this out.

    Considered the symlink/real-file approach you mentioned (dropping a mujoco.dll next to robosuite/utils/) but ruled it out: creating symlinks on Windows requires admin or Developer Mode, and dropping a real file would mutate the installed package on disk — I'd rather keep the fix fully in-process and reversible.

    2. Silent no-op when robosuite is pre-imported → now warns

    Agreed this was a silent-fail trap. The gating now splits:

  • sys.platform != "win32" → return silently (unchanged)

  • "robosuite" in sys.modules → warnings.warn(RuntimeWarning, ...) with a message pointing users to import lerobot.sim.integrations.libero before any robosuite import, then return.
  • 3. No tests → added tests/sim/integrations/test_libero_windows_compat.py

    Four unit tests, all runnable on Linux CI (and verified locally):

  • test_shim_is_noop_on_linux — monkeypatches sys.platform="linux", calls shim, asserts no raise/warn

  • test_shim_is_noop_on_darwin — same for macOS

  • test_shim_warns_when_robosuite_is_already_imported — sys.platform="win32" + stubbed robosuite in sys.modules, asserts RuntimeWarning matching "already imported"

  • test_dll_redirect_predicate_canonicalizes_paths — pins the normcase(name) == wanted predicate on case-variant and non-target path inputs
  • They use the existing tests/utils.import_without_simulator("libero", monkeypatch) pattern (the one test_libero.py already uses), so hf-libero/robosuite/mujoco don't need to be installed on the runner.

    End-to-end import test still stands on my Windows 11 setup from the earlier comment.

    4. Nit on process-global ctypes.WinDLL

    Acknowledged — now moreso since the redirect is permanent. Keeping it as-is: the subclass only matches one specific canonicalized path (site-packages/robosuite/utils/mujoco.dll), so any concurrent WinDLL load targeting that exact path would be the robosuite 1.4.0 path we're trying to rescue anyway. Open to reworking if you can think of a concrete conflict case.

    Also credit back: @ahmedsleem109's original reproduction + compat function in #4857 is the basis for all three patches.

    Prer1n1 Prer1n1 commented on Nov 15, 2026 23:33 UTC
    Author

    Marking this as ready for a maintainer look. The three substantive review points from @mangeshraut712 are addressed in af113b2; Windows 11 import verified; 4 unit tests added that run on Linux CI.

    The one open question is direction: LeRobot-side shim (this PR) vs. upstream-first in hf-libero. Happy to go either way just flagging this since #4857 has been open since early October without a steer. @Maximellerbach would appreciate ~5 minutes of your time to say yes/no/wait.

    Maximellerbach Maximellerbach commented on Nov 18, 2026 16:31 UTC
    Contributor

    @Prer1n1 Hi! Thanks, this seem a bit complex to maintain going forward. Another option for windows users is to use docker and to just serve the simulator using lerobot-env-server --config_path=docker/sim/configs/libero.yaml --docker=true
    see the whole doc here: https://huggingface.co/docs/lerobot/v0.7.0/simulation#serve-an-environment

    The fixes in this PR are probably valid but they seem really sensible to a version bump. If that helps, note that we don't depend anymore from robomimic and egl_probe since https://github.com/huggingface/lerobot/pull/5386 landed.
    If there would be a fix to be done, it would be better to open a PR against hf-libero rather than lerobot

    Prer1n1 Prer1n1 commented on Nov 19, 2026 03:35 UTC
    Author

    Thanks for the clear direction @Maximellerbach : that lines up with what #5386 did to the dep structure, and the Docker/lerobot-env-server path makes sense as the supported Windows surface.

    I'll close this one. If there's still a real gap after Docker, I'll look at huggingface/LIBERO as the right upstream venue, and credit @ahmedsleem109's reproduction from #4857 there.

    Assignees
    Prer1n1 Prer1n1
    Labels
    risk: low confidence: 84.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.2% (MEDIUM) · Higher = larger blast radius
    36.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 84.3% · Lower = rushed or shallow review
    84.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 5.7% · Safe to merge
    5.7%