CLI version policy

Keep every project in your organization on a consistent Fern CLI version.

View as Markdown

Admins can set an organization-level CLI version policy to bound the Fern CLI version that every project in your organization runs. Set a minimum, a maximum, or an exact version. A policy lives on your organization, and applies to every project without a change to any fern.config.json.

By default, no policy is set, and each project runs the version it pins in fern.config.json. Those pins can diverge across repositories, leaving the same API definition to compile against a different CLI in each one.

Which version runs

Each time you run a Fern CLI command in your project, Fern compares the version pinned in fern.config.json against your organization’s bounds and runs the nearest allowed version.

Version pinned in fern.config.jsonVersion that runs
Below the minimumThe minimum
Above the maximumThe maximum
Inside the rangeThe pinned version, unchanged

A version already inside the range prints nothing. When the version changes, the CLI names the bound that applied before the command proceeds:

Org "acme" requires Fern CLI >= 5.40.0 — running 5.40.0.

A policy never blocks a command. When the CLI can’t read your organization’s bounds, such as when it isn’t authenticated or can’t reach Fern, the project runs its own pinned version.

Set the policy

fern org set cli-version writes the bounds. It requires an organization admin and an authenticated session from fern login. The organization is read from fern.config.json; pass --org to target a different one.

$# Pin an exact version
$fern org set cli-version 5.45.0
$
$# Set a minimum
$fern org set cli-version --min 5.40.0
$
$# Set a maximum
$fern org set cli-version --max 5.50.0
$
$# Set both
$fern org set cli-version --min 5.40.0 --max 5.50.0

Each bound is an exact published version of the fern-api package, such as 5.45.0 or 5.45.0-rc0.

--min and --max update only the bound you pass. Setting --min 5.40.0 on an organization already pinned to 5.45.0 leaves the maximum at 5.45.0, turning the pin into the range 5.40.0 to 5.45.0.

Read the policy

$fern org get
$fern org get --json

fern org get prints the policy in one line — Fern CLI must be between 5.40.0 and 5.50.0, or the equivalent for a minimum, maximum, or exact pin — and reports when no policy is set. --json returns the raw cliVersionMin and cliVersionMax fields instead.

Clear the policy

fern org unset cli-version clears the bounds, and like setting them it requires an organization admin.

$# Remove both bounds
$fern org unset cli-version
$
$# Remove only the minimum, keeping the maximum
$fern org unset cli-version --min
$
$# Remove only the maximum, keeping the minimum
$fern org unset cli-version --max

Interaction with fern upgrade

A policy changes the version that runs, not the version on disk, so a project stays out of range until it’s upgraded. fern upgrade brings the file itself into range: it applies the bounds to the upgrade target before writing it.

CommandPolicyVersion written
fern upgradeMaximum 5.50.05.50.0
fern upgradePinned to 5.45.05.45.0
fern upgrade --version 5.35.0Minimum 5.40.05.40.0

A plain fern upgrade resolves to the latest release, which is never below the minimum, so only the maximum changes what it writes. The minimum applies when you request an older version with --version: the bounds win over the version you asked for.

fern downgrade is the exception: it writes whatever version you pass, including one below the minimum. The policy then overrides that pin the same way it overrides any other out-of-range pin, so the project’s commands keep running the minimum.

Running a newer CLI doesn’t apply the migrations that fern upgrade performs. Raising the minimum across a major version therefore still requires each project to run fern upgrade.