Sub topic 13
Update the CLI and manage plugins
This chapter assumes you have installed the CLI with npm, can run sf --version, and have authorized at least one org. You should also know how sf commands are built from topics, commands, and flags.
Why updates and plugins matter
The sf command is a small core plus a set of plugins. Each plugin adds commands. For example, the commands under sf project and sf org come from plugins that ship with the CLI. Salesforce releases new CLI versions often, and each release can add commands, fix bugs, and change flags. Keeping the CLI current avoids the situation where a tutorial or a teammate's script uses a command that your copy does not have.
Update the CLI
Run sf update to move to the latest version. Then list the installed plugins.
sf update
sf pluginssf update downloads the newest release and replaces the one you have. Run sf --version afterward to confirm the change. sf plugins prints each installed plugin and its version.
A few points to know:
sf updateworks for installs made with the standalone installer. If you installed with npm, as in this tutorial, update with npm instead.- Run the update from the same method you used to install. Mixing methods can leave two copies of
sfon your machine, and your shell will run whichever comes first on thePATH. - If
sf --versiondoes not change after an update, check which copy runs withwhich sf(macOS and Linux) orwhere sf(Windows).
npm install --global @salesforce/cli@latest
sf --versionSee what is installed
sf plugins lists the plugins you have added yourself. To include the plugins that come with the CLI, add the --core flag.
sf plugins --coreThe output shows plugin names such as @salesforce/plugin-deploy-retrieve or @salesforce/plugin-data, with their versions. Reading this list is the quickest way to answer "why does my machine not have this command?" If the plugin that owns a command is missing, the command is missing too.
Install and remove plugins
You can add extra plugins with sf plugins install. Pass the plugin's package name.
sf plugins install <plugin-name>
sf plugins uninstall <plugin-name>Replace <plugin-name> with the package name from the plugin's documentation. After the install finishes, run sf plugins to confirm it appears, and sf <topic> --help to see its new commands.
Plugins are code that runs on your machine with your permissions, and some of them can reach your authorized orgs. Install only plugins from sources you trust, such as Salesforce itself or a vendor you already use. When the CLI warns that a plugin is not signed by Salesforce, treat the warning as a reason to check the source before you continue.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| `sf update` says the command is not available | The CLI was installed with npm | Run `npm install --global @salesforce/cli@latest` |
| Version stays the same after updating | A second copy of `sf` earlier on the `PATH` | Find it with `which sf` or `where sf`, then remove the old copy |
| A command is "not found" | The plugin that provides it is not installed | Check `sf plugins --core` and install the plugin |
| Permission error during a global npm install | npm's global folder needs elevated rights | Change npm's global prefix to a folder you own, or ask your administrator |
A short maintenance routine
The diagram shows a routine you can repeat every few weeks.
If your team shares scripts, agree on a minimum CLI version and write it in the project README. Then a failing script points to an outdated install, and nobody has to guess.
Exercise
You installed the CLI with npm and ran sf update, but sf --version still shows the old version. Name two likely causes and one command that helps you find the problem.
Show answer
The CLI was installed with npm, so it must be updated with npm install --global @salesforce/cli@latest. Alternatively, a second, older copy of sf is earlier on the PATH. Run which sf (or where sf on Windows) to see which copy your shell runs.
Exercise
A teammate's script calls a command that your terminal reports as not found. Which command lists the plugins on your machine, including those bundled with the CLI?
Show answer
sf plugins --core. If the plugin that provides the command is not in the list, install it with sf plugins install <plugin-name>.