Sub topic 13
Update the CLI and manage plugins
The Salesforce CLI changes often. New commands appear, flags are added, and old behavior is fixed or retired. This chapter covers how to update the sf executable, how to move between release channels, and how to add, inspect, and remove plugins. It assumes you can already run sf commands, which the earlier chapters on installation and command structure cover.
Why updates matter
Most CLI features live in plugins that ship bundled with the CLI. Updating the CLI updates those core plugins too. Staying current has practical effects:
- Commands such as
sf project deploy startgain flags and bug fixes over time. - A command that works on a teammate's machine may not exist on yours if your version is older.
- Scripts and CI jobs behave differently across versions, which is why many teams pin a version in automation.
Check what you have before you change anything:
sf --version
sf version --verbosesf --version prints the CLI version, your platform, and your Node.js version. sf version --verbose also lists the installed plugins and their versions. Paste this output into bug reports and support requests.
Choose the right update path
How you update depends on how you installed the CLI. There are two main routes.
| Installed with | Update with | Notes |
|---|---|---|
| OS installer or tarball | `sf update` | The CLI downloads and replaces itself. |
| npm | `npm install --global @salesforce/cli@latest` | npm owns the files, so update through npm. |
If you are not sure how you installed it, find the executable:
which sfOn Windows, use where sf. A path inside a global node_modules folder points to an npm install. A path under an installer directory such as /usr/local/sf points to the installer.
Update with sf update
For installer-based installs, the update command is:
sf update
sf pluginssf update downloads the newest version from the channel you follow and replaces the current one. Run sf --version afterward to confirm. sf plugins then lists the plugins installed alongside the CLI.
Common variations:
sf update --available
sf update stable
sf update stable-rcsf update --availableshows the channels and versions you could install without installing anything.sf update stablemoves you to the stable channel, which is the default.sf update stable-rcmoves you to the release candidate channel, which gets changes a few days before they reach stable.
A third channel, nightly, exists for people testing unreleased changes. Use it only to reproduce a bug against the newest code or to check a fix. Do not use it for work you depend on.
Pin a version for repeatable automation
For a developer machine, tracking latest is reasonable. For a CI pipeline, an unexpected update can break a build that passed yesterday. With npm you can install an exact version:
npm install --global @salesforce/[email protected]
sf --versionThe version number here is an example. Replace it with a version you have tested. Raise it on purpose, in a change you can review, instead of letting each run pick up whatever is newest.
You can also install a release candidate through npm by using the latest-rc tag:
npm install --global @salesforce/cli@latest-rcThis lets a CI job check upcoming changes against your scripts before they reach stable.
What plugins are
A plugin is a package that adds commands to the CLI. Each topic you have used, such as org, project, data, and apex, is delivered by a plugin. The CLI groups plugins into three kinds:
- Core plugins ship with the CLI and are updated when you update the CLI.
- User plugins are ones you install yourself with
sf plugins install. - Linked plugins are ones you point at a local folder while developing your own.
List what is installed:
sf plugins
sf plugins --coresf plugins shows user and linked plugins. Adding --core includes the bundled ones. Each line shows the plugin name and version.
Install a plugin
Install a plugin from npm by name:
sf plugins install sfdx-git-delta
sf pluginsThe CLI downloads the package and its dependencies into its own data directory, separate from your project and separate from your global npm packages. The new commands are available immediately. If you need a specific version or tag, append it to the name:
sf plugins install sfdx-git-delta@latestSigned and unsigned plugins
Salesforce signs the plugins it publishes. When you install a plugin that has no valid signature from Salesforce, the CLI warns you and asks you to confirm. This matters because a plugin is code that runs on your machine with your permissions, and it can read the same authorization files the CLI uses.
Treat the prompt as a real decision:
- Check who publishes the package and whether it is maintained.
- Read its repository or at least its install scripts if the source is available.
- Install it only if you trust it.
In unattended environments, an interactive prompt will stall a job. Salesforce supports an allow list file named unsignedPluginAllowList.json in the CLI's configuration directory. It lists plugin names that may be installed without the prompt. Keep that list short and review it as you would any dependency list.
Inspect, update, and remove plugins
Look at one plugin in detail:
sf plugins inspect sfdx-git-deltaThis prints the plugin's name, version, and the location it was installed from. It is useful when you want to know which package provides a command you are running.
Update the user plugins you installed:
sf plugins updateCore plugins are not updated this way. They change when the CLI changes. Remove a plugin you no longer use:
sf plugins uninstall sfdx-git-deltaRemoving unused plugins keeps the CLI starting quickly and reduces the amount of third-party code you run.
Link a plugin during development
If you write your own plugin, you can link a local folder so the CLI loads it without publishing:
sf plugins link ./my-plugin
sf pluginsThe linked plugin appears in the list as (link) with its path. Changes to the source are picked up after you rebuild it. To remove the link, run sf plugins unlink my-plugin. Most users never need this, but it is how plugin authors test commands.
Common problems
The table lists symptoms you are likely to meet and where to look first.
| Symptom | Likely cause | What to try |
|---|---|---|
| `sf --version` shows the old version after an update | Another `sf` earlier on your `PATH` | Run `which sf` or `where sf`, then remove the older copy. |
| A command or flag is "not found" | CLI or plugin is out of date | Run `sf --version`, update, and check the command in `--help`. |
| A plugin command fails after a CLI update | Plugin is incompatible with the new CLI | Run `sf plugins update`, or uninstall and reinstall the plugin. |
| Install hangs in a script | The unsigned plugin prompt is waiting for input | Review the plugin, then use the allow list. |
| `sf update` reports it cannot update | The CLI was installed with npm | Update with npm instead. |
When a plugin misbehaves in a way you cannot explain, there is a useful check. Uninstall the plugin and run the failing command again. If the problem disappears, the plugin is the cause.
A short routine
A reasonable habit for a developer machine looks like this:
sf --version
sf update
sf plugins update
sf version --verboseRun it every few weeks, or when a command behaves differently from the documentation. In a team, record the CLI version that your scripts were tested with, so that a failure points to a version difference and not to a mystery.
Exercise
You installed the CLI with npm. A teammate says to run sf update, but afterward sf --version still shows the old version. What command should you use instead, and what is the first check you should make when the version still looks wrong?
Show answer
Use npm install --global @salesforce/cli@latest, because npm manages the files for an npm install. If the version is still wrong, run which sf (or where sf on Windows) to see whether an older sf earlier on the PATH is the one being run.
Exercise
Why would you install a plugin that is not signed by Salesforce only after reviewing it, and which file lets an unattended script skip the confirmation prompt?
Show answer
A plugin is code that runs on your machine with your permissions and can read the CLI's authorization data, so you should trust it before installing. The unsignedPluginAllowList.json file in the CLI's configuration directory lists plugin names that can be installed without the prompt, and it should contain only plugins you have reviewed.