2026-04-14 9:42 PM
Hi,
The STM32_Programmer_CLI is installed by the ST VS Code plugin to a directory that will change from version to version and it's also not added to the PATH. I am trying to find a reproducible way to automatically add that install location to the PATH in my Dev Container so I can use command-line tools to program it.
The current location is:
~/.local/share/stm32cube/bundles/programmer/2.22.0+st.1/bin/STM32_Programmer_CLI
where ~ is the user in the Docker container.
I tried searching for it in a script run in "postStartCommand" from devcontainer.json which is run after the Docker container is started. But, the plugins have not been installed yet so that fails.
Any suggestions? Could the plugin on install add it to the .bashrc in the future? Or perhaps an alias to it could be added to a constant location?
2026-04-15 7:38 AM
One reproducible workaround would be to avoid depending on the VS Code extension-managed bundle path.
Instead, install STM32CubeProgrammer manually on the host in a stable location, for example:
/opt/st/STM32CubeProgrammer
or use a versioned install path with a stable symlink, for example:
/opt/st/STM32CubeProgrammer -> /opt/st/STM32CubeProgrammer-2.22.0
Then the Dev Container can bind-mount that directory and add its bin directory to PATH:
"mounts": [
"source=/opt/st/STM32CubeProgrammer,target=/opt/st/STM32CubeProgrammer,type=bind,readonly"
],
"containerEnv": {
"PATH": "/opt/st/STM32CubeProgrammer/bin:${containerEnv:PATH}"
}
This makes the setup independent from the VS Code extension installation timing and from the extension-managed versioned bundle path. The STM32_Programmer_CLI path stays stable, and updating STM32CubeProgrammer only requires updating the symlink on the host.
2026-04-15 8:36 AM
Thanks! That's a great solution if the host is also Linux. I totally forgot to mention that my host is Windows 11 (so I can use legacy embedded tooling)!
My current workaround is having Docker create a wrapper script called STM32_Programmer_CLI in /usr/local/bin in the container, and in that script is a quick search for the real STM32_Programmer_CLI which is then launched. Here's that snippet:
RUN cat <<'EOF' >/usr/local/bin/STM32_Programmer_CLI
#!/usr/bin/env bash
set -euo pipefail
shopt -s nullglob
matches=(/home/vscode/.local/share/stm32cube/bundles/programmer/*/bin/STM32_Programmer_CLI)
if [ "${#matches[@]}" -eq 0 ]; then
printf 'STM32_Programmer_CLI is not installed yet. Allow the STM32 extension to finish installing the programmer bundle.\n' >&2
exit 127
fi
latest_cli=$(printf '%s\n' "${matches[@]}" | sort -V | tail -n 1)
exec "$latest_cli" "$@"
EOF
RUN chmod 755 /usr/local/bin/STM32_Programmer_CLI