Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The feature downloads the official CmdStan release tarball, pre-compiles the Sta
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/MiguelRodo/DevContainerFeatures/cmdstan:1": {
"version": "latest"
"version": "2.36.0"
}
}
}
Expand All @@ -72,7 +72,7 @@ The feature downloads the official CmdStan release tarball, pre-compiles the Sta

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `version` | string | `"latest"` | CmdStan version to install (e.g. `"2.36.0"`). Use `"latest"` to always pull the newest release. |
| `version` | string | `"2.36.0"` | CmdStan version to install (e.g. `"2.36.0"`). Use `"latest"` to always pull the newest release. |
| `installDir` | string | `"/opt/cmdstan"` | Base directory under which the versioned CmdStan folder is created. |
| `installRPackage` | boolean | `true` | When `true` and R is present, install the `cmdstanr` R package and configure it to use the system CmdStan installation. |

Expand Down
2 changes: 1 addition & 1 deletion docs/features/cmdstan.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ With Python integration disabled:

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `version` | string | `"latest"` | CmdStan version to install (e.g. `"2.36.0"`). Use `"latest"` to always pull the newest release. |
| `version` | string | `"2.36.0"` | CmdStan version to install (e.g. `"2.36.0"`). Use `"latest"` to always pull the newest release. |
| `installDir` | string | `"/opt/cmdstan"` | Base directory under which the versioned CmdStan folder is created (e.g. `/opt/cmdstan/cmdstan-2.36.0`). |
| `installRPackage` | boolean | `true` | When `true` and R is present in the image, install the `cmdstanr` R package and configure it to use the system CmdStan installation. |
| `installPythonPackage` | boolean | `true` | When `true` and Python/pip is present in the image, install the `cmdstanpy` Python package and configure it to use the system CmdStan installation. |
Expand Down
2 changes: 1 addition & 1 deletion src/cmdstan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Installs CmdStan (the Stan probabilistic programming system command-line interfa

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| version | CmdStan version to install (e.g. '2.36.0'). Use 'latest' to always pull the newest release. | string | latest |
| version | CmdStan version to install (e.g. '2.36.0'). Use 'latest' to always pull the newest release. | string | 2.36.0 |
| installDir | Base directory under which the versioned CmdStan folder is created (e.g. /opt/cmdstan/cmdstan-2.36.0). | string | /opt/cmdstan |
| installRPackage | When true and R is present in the image, install the 'cmdstanr' R package and configure it to use the system CmdStan installation. | boolean | true |
| installPythonPackage | When true and Python/pip is present in the image, install the 'cmdstanpy' Python package and configure it to use the system CmdStan installation. | boolean | true |
Expand Down
4 changes: 2 additions & 2 deletions src/cmdstan/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"version": {
"type": "string",
"proposals": [
"latest",
"2.36.0",
"latest",
"2.35.0",
"2.34.1"
],
"default": "latest",
"default": "2.36.0",
"description": "CmdStan version to install (e.g. '2.36.0'). Use 'latest' to always pull the newest release."
},
"installDir": {
Expand Down
29 changes: 20 additions & 9 deletions src/cmdstan/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

set -e

CMDSTAN_VERSION="${VERSION:-"latest"}"
CMDSTAN_VERSION="${VERSION:-"2.36.0"}"
INSTALL_DIR="${INSTALLDIR:-"/opt/cmdstan"}"
INSTALL_R_PACKAGE="${INSTALLRPACKAGE:-"true"}"
INSTALL_PYTHON_PACKAGE="${INSTALLPYTHONPACKAGE:-"true"}"
Expand Down Expand Up @@ -102,15 +102,26 @@ esac
# ---------------------------------------------------------------------------
if [ "${CMDSTAN_VERSION}" = "latest" ] || [ -z "${CMDSTAN_VERSION}" ]; then
echo "Resolving latest CmdStan version from GitHub..."
CMDSTAN_VERSION=$(curl -sSfL \
https://api.github.com/repos/stan-dev/cmdstan/releases/latest \
| grep '"tag_name"' \
| sed -E 's/.*"v([^"]+)".*/\1/')
if [ -z "${CMDSTAN_VERSION}" ]; then
echo "Error: Could not determine latest CmdStan version from GitHub API." >&2
exit 1

# Try fast resolution first, then fallback to API if that fails
LATEST_VERSION=$(curl -sSfLI -o /dev/null -w '%{url_effective}' \
https://github.com/stan-dev/cmdstan/releases/latest \
| sed 's|.*/v||' || true)

if [ -z "${LATEST_VERSION}" ] || [ "${LATEST_VERSION}" = "https://github.com/stan-dev/cmdstan/releases/latest" ]; then
LATEST_VERSION=$(curl -sSfL \
https://api.github.com/repos/stan-dev/cmdstan/releases/latest \
| grep '"tag_name"' \
| sed -E 's/.*"v([^"]+)".*/\1/' || true)
fi

if [ -z "${LATEST_VERSION}" ]; then
echo "Warning: Could not determine latest CmdStan version from GitHub. Falling back to default 2.36.0." >&2
CMDSTAN_VERSION="2.36.0"
else
CMDSTAN_VERSION="${LATEST_VERSION}"
echo "Resolved latest version: ${CMDSTAN_VERSION}"
fi
echo "Resolved latest version: ${CMDSTAN_VERSION}"
fi

# 🛡️ Sentinel: Validate version format (X.Y.Z) to prevent path injection
Expand Down
Loading