mathworks / matlab-proxy

Python® package enables you to open a MATLAB® desktop in a web browser tab.
Other
43 stars 23 forks source link

`env={}` instead of `env=matlab_env` #17

Closed jhgoebbert closed 1 year ago

jhgoebbert commented 1 year ago

Hello,

thank you for this great package! I came across one issue while adding it to our software stage.

Xvfb ist started by from https://github.com/mathworks/matlab-proxy/blob/main/matlab_proxy/app_state.py#L644 This calls mw.create_xvfb_process(xvfb_cmd, dpipe) from https://github.com/mathworks/matlab-proxy/blob/main/matlab_proxy/util/mw.py#L260 with env={} for the call

    xvfb = await asyncio.create_subprocess_exec(
        *xvfb_cmd, close_fds=False, env=env, stderr=asyncio.subprocess.PIPE
    )

Hence, the command Xvfb must be located on system paths. For the start of matlab the environment is correctly set with matlab_env https://github.com/mathworks/matlab-proxy/blob/main/matlab_proxy/app_state.py#L686 But this is not the case for Xvfb

On our systems Xvfb is loaded via a module. So I created a wrapper script called Xvfb located at some location added to $PATH. But this wrapper script is not found because of env={} instead of env=matlab_env.

jhgoebbert commented 1 year ago

To fix this I added os.environ.copy() in matlab_proxy/app_state.py

-            xvfb, display_port = await mw.create_xvfb_process(xvfb_cmd, dpipe)
+            xvfb, display_port = await mw.create_xvfb_process(xvfb_cmd, dpipe, os.environ.copy())
prabhakk-mw commented 1 year ago

@jhgoebbert , Thank you for bringing this to our attention, and for the pull request #18.

We will be investigating this issue over the next few days and will get back to you if there are any more questions that might help us with our investigation.

Thank you!

jhgoebbert commented 1 year ago

Great. Thank you for the fix.

AndrewHerzing commented 1 year ago

I continue to have the same error as originally reported even after the latest fix (v0.77 installed from pip). The error output is:

ERROR:MATLABProxyApp:Unable to start the Xvfb process. Ensure Xvfb is installed and is available on the System Path. See https://github.com/mathworks/matlab-proxy#requirements for information on Xvfb

I also cloned the repo and installed the development version with the same result.

krisctl commented 1 year ago

@AndrewHerzing Thank you for trying out matlab-proxy. Can you confirm that in your environment, the Xvfb executable is indeed on the path either via the system path or via environment modules similar to how the original issue reporter had set up Xvfb? If yes, please open a new issue and provide more details about your setup and we'll be happy to help you resolve it.

AndrewHerzing commented 1 year ago

Xvfb is on the system path installed via apt.

$ which Xvfb
/usr/bin/Xvfb

I will start a new issue.