Update Salesforce CLI
If you want to ensure that you’re running the latest version of Salesforce CLI, you can manually update it.
Because the method to update or uninstall Salesforce CLI differs depending on whether you used the operating system-specific installers or npm, you must know how you installed before you can update or uninstall. In case you forgot, here are some tips.
-
Run
sf updatein a terminal (macOS and Linux) or command prompt (Windows). If Salesforce CLI successfully updates, then you installed with the installers. If the command returns this or similar warning, then you installed with npm:If you get an error similar to this one, then you’re probably still using
sf(v1), which was bundled withsfdx(v7):Both
sf(v1) andsfdx(v7) are deprecated, so see Move from sfdx (v7) to sf (v2) for information on how to move to the latest supported version of Salesforce CLI, which issf(v2). -
Run
npm list -g --depth 0. If you got valid output, and the displayed list includes the entry@salesforce/cli@<version>, then you installed Salesforce CLI withnpm.
To install the latest Salesforce CLI and plugin versions, run this command in a terminal (macOS) or command prompt (Windows):
By default, the CLI periodically checks for and installs updates. To disable auto-update, set the SF_AUTOUPDATE_DISABLE environment variable to true.
When you update Salesforce CLI, we automatically display the release notes for the version you’re updating to so you can learn about the new, changed, and fixed features. To silence the display, set the SF_HIDE_RELEASE_NOTES and SF_HIDE_RELEASE_NOTES_FOOTER environment variables to true.
The auto-update option isn’t available. When a new version of the CLI is available, run this command in a terminal (macOS and Linux) or command prompt (Windows):
As previously described, you can update Salesforce CLI using two methods: sf update or npm install --global @salesforce/cli. Let’s break down the upgrade process for both methods. See Salesforce CLI Plugins for terminology and architecture information about plugins.
Common Updates for Both Methods
- Salesforce CLI: Updated to the latest version, which is the public
@salesforce/clinpm package that has the latest tag. - Core plugins: All core plugins are also updated to their latest versions based on the
latesttag. Examples include @salesforce/plugin-org and @salesforce/plugin-deploy-retrieve.
Update Behavior of Non-Core Plugins
-
If you used
sf updateto update Salesforce CLI, then the update process attempts to update all non-core plugins to their latest available versions. Specifically, the process updates a non-core plugin only if the currently-installed one is older than the latest version. If the installed non-core plugin is newer than the latest version, then this plugin isn’t updated.For example, let’s say the latest available version of the
code-analyzerplugin is5.3.0. If the installed version is5.3.1, then thecode-analyzerplugin isn’t updated when you runsf update. If, however, if the installed version is5.2.0, then the plugin is updated to5.3.0. -
If you used
npm install --global @salesforce/clito update, then the non-core plugins (JIT and user-installed) aren’t updated. You must update them yourself manually. -
Update to the CLI Release Candidate or Nightly
We release a new version of the CLI weekly. At the same time we also publish a release candidate of the CLI that contains changes that we plan to include in the next weekly release. Think of the release candidate as the CLI-version of the Salesforce sandbox preview. You can update to a release candidate if you want to check out upcoming features. Or stay on the current and official release. Or go back and forth. It’s up to you!
-
Disable Automatic Update of the CLI
When you run a command, Salesforce CLI checks to see if you have the latest version. If not, the CLI automatically updates itself. You can disable this automatic update with an environment variable.