Why does MATLAB get stuck during startup using a Jenkins container?

I am using Jenkins to start MATLAB R2025b in an Ubuntu container, using a wrapper script that uses the "-batch" startup flag. When I run this script, it gets stuck on a line that calls the "renderinfo" function. Similarly, if I call the "plot" function in my wrapper script, it also gets stuck. I am initializing my environment variables for the container as shown below:
### Init Environment
HOME=/runner
JENKINS_ROOT="$HOME/$JOBID"
. "$HOME/.profile"
TMPDIR="/tmp"
mkdir -p "$JENKINS_ROOT"
export HOME JENKINS_ROOT TMPDIR
cd "$JENKINS_ROOT"
Why does MATLAB freeze during this startup process and how can I resolve this?

 채택된 답변

When setting environment variables for the container, the variable "TMPDIR" must be set and exported before sourcing ".profile". 
This is because MATLAB incorporates an "autostart at login" functionality, which optimizes startup by starting MathWorks Service Host (MSH) when ".profile" is sourced. Therefore, in this case, MSH is started even though MATLAB is started up through batch. When "TMPDIR" is changed after MSH is started, MSH launches with a different "TMPDIR" to MATLAB, so MATLAB is unable to communicate with MSH, causing the freeze.
Our recommendation is to override any environment variables as early as possible, before any other processes are started. In this case, set and export "TMPDIR" first before initializing other processes:
### Init Environment
TMPDIR="/tmp"
export TMPDIR
HOME=/runner
export HOME
JENKINS_ROOT="$HOME/js"
export JENKINS_ROOT
. "$HOME/.profile"
mkdir -p "$JENKINS_ROOT"
cd "$JENKINS_ROOT"

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

릴리스

R2025b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by