@@ -441,7 +441,9 @@ def display_output(self, out):
441441 response = out ["content" ]
442442 self .send_response (self .iopub_socket , msg_type , response )
443443
444- async def perform_startup_checks (self , iframe_src : str = None ):
444+ async def perform_startup_checks (
445+ self , jupyter_base_url : str = None , matlab_proxy_base_url : str = None
446+ ):
445447 """
446448 One time checks triggered during the first execution request. Displays
447449 login window if matlab is not licensed using matlab-proxy.
@@ -470,19 +472,32 @@ async def perform_startup_checks(self, iframe_src: str = None):
470472 # as src for iframe to avoid hardcoding any hostname/domain information. This is done to
471473 # ensure the kernel works in Jupyter deployments. VS Code however does not work the same way
472474 # as other browser based Jupyter clients.
473- #
474- # TODO: Find a workaround for users to be able to use our Jupyter kernel in VS Code.
475475 if not is_matlab_licensed :
476+ if not jupyter_base_url :
477+ # happens for non-jupyter environments (like VSCode), we expect licensing to
478+ # be completed before hand
479+ self .log .debug (
480+ "MATLAB is not licensed and is in a non-jupyter environment. licensing via other means required."
481+ )
482+ raise MATLABConnectionError (
483+ """
484+ Error: Cannot start MATLAB as no licensing information was found.
485+ Resolution: Set the environment variable MLM_LICENSE_FILE to provide a network license manager,
486+ or set MWI_USE_EXISTING_LICENSE to True if the installed MATLAB is already licensed.
487+ See https://github.com/mathworks/matlab-proxy/blob/main/Advanced-Usage.md for more information.
488+ To use Online licensing, start a MATLAB Kernel in a Jupyter notebook and login using the web interface
489+ shown upon execution of any code.
490+ """
491+ )
476492 self .log .debug (
477493 "MATLAB is not licensed. Displaying HTML output to enable licensing."
478494 )
479- self .log .debug (f"{ iframe_src = } " )
480495 self .display_output (
481496 {
482497 "type" : "display_data" ,
483498 "content" : {
484499 "data" : {
485- "text/html" : f'<iframe src={ iframe_src } width=700 height=600"></iframe>'
500+ "text/html" : f'<iframe src={ jupyter_base_url } { matlab_proxy_base_url } width=700 height=600"></iframe>'
486501 },
487502 "metadata" : {},
488503 },
0 commit comments