Add sglang sglang check env compiler no shell - #4
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the environment check in python/sglang/check_env.py by removing shell=True from subprocess.check_output calls for nvcc and hipcc, passing arguments as lists instead, and adds corresponding unit tests. The reviewer noted that removing shell=True can cause FileNotFoundError (an OSError) to be raised if the binaries are missing. Since the outer try-except blocks only catch subprocess.SubprocessError, this could lead to uncaught exceptions and crashes. The reviewer suggested wrapping these subprocess calls in nested try-except blocks to catch OSError and return 'Not Available' gracefully.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| .decode("utf-8") | ||
| .strip() | ||
| ) | ||
| nvcc_output = subprocess.check_output([nvcc, "-V"], text=True).strip() |
There was a problem hiding this comment.
By removing shell=True, if the nvcc binary does not exist at the specified path, subprocess.check_output will raise a FileNotFoundError (which inherits from OSError). Since the surrounding except block only catches subprocess.SubprocessError, this FileNotFoundError will go uncaught and crash the environment check. To prevent this, we should wrap the call in a nested try-except block to catch OSError and return "Not Available" gracefully.
try:
nvcc_output = subprocess.check_output([nvcc, "-V"], text=True).strip()
except OSError:
return {"NVCC": "Not Available"}| .decode("utf-8") | ||
| .strip() | ||
| ) | ||
| hipcc_output = subprocess.check_output([hipcc, "--version"], text=True).strip() |
There was a problem hiding this comment.
By removing shell=True, if the hipcc binary does not exist at the specified path, subprocess.check_output will raise a FileNotFoundError (which inherits from OSError). Since the surrounding except block only catches subprocess.SubprocessError, this FileNotFoundError will go uncaught and crash the environment check. To prevent this, we should wrap the call in a nested try-except block to catch OSError and return "Not Available" gracefully.
try:
hipcc_output = subprocess.check_output([hipcc, "--version"], text=True).strip()
except OSError:
return {"HIPCC": "Not Available"}- Avoid shell for compiler version checks - Catch compiler launch OSError in check_env
Summary
Validation
Review notes