fix(libero): Windows compatibility shim for robosuite 1.4.0 (closes #4857) #5305
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.
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.
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.
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.
@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
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.
mangeshraut712
Prer1n1
Closes #4857.
What this PR does
Adds a Windows-only compatibility shim in
src/lerobot/sim/integrations/libero.pyso native Windows users can run LIBERO without WSL. It runs before the firstimport robosuiteand 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 missingrobosuite/utils/mujoco.dllto the DLL that ships with themujocoPython package.2. Pre-loads
robosuite.macroswithMUJOCO_GPU_RENDERING = FalsesoMUJOCO_GLis not force-set toegl(invalid on Windows).3. Pre-loads
robosuite.macroswithFILE_LOGGING_LEVEL = Noneso robosuite never writes to the hard-coded/tmp/robosuite.logpath.The shim is a strict no-op on non-Windows and when
robosuiteis already imported.Also updates
pyproject.tomlto allowsys_platform == 'win32'on theliberoextra and theallcomposite. Full Windows install still depends on a follow-uphf-liberoPR to makerobomimic/egl-probeoptional (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
import lerobot.sim.integrations.liberosucceeds end-to-end. See comment below.sys.platform == "win32"gated).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:
finallyrestore); only rewrites the one canonicalized path, every otherWinDLLload is a pass-through.RuntimeWarningpointing users to import the shim before anyrobosuiteimport.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.