12

I'm wondering whether it's possible to downgrade sfdx-cli to use an earlier version? I'm trying to debug an issue with using it in pipeline scripts. When I run sfdx version --core I get sfdx-cli 7.28.7 (core) .

If I run sfdx version I get sfdx-cli/7.28.7-7bceba6f24 darwin-x64 node-v10.15.3 .

If I do cat package.json inside the actual package dir for sfdx-cli after doing npm install sfdx-cli@7.26.0 I get "sfdx-cli": "^7.26.0"

Why does it then show that the version is 7.28.7? How can I force the lower version to have preference? I do understand that this question is not really salesforce specific but hopefully someone has run into the same problem.

17

Updated answer (thanks to Shane McLaughlin's answer, please upvote their answer as well):

It depends how you installed the CLI originally. If you installed via npm, lie npm install -g sfdx-cli then you can use npm to install whatever version you like, ex: npm install -g sfdx-cli@7.109.0

If you installed via the installer (downloading a tarball, pkg, windows installer, etc) then you don't have an easy downgrade path without uninstalling the CLI first (it's not hard, it won't lose all your orgs).

Then you can install an older version (and turn off auto-update if you want to stay on the older version).


Original Answer (outdated)

You can change to any version you want by using the @version notation:

sfdx plugins:install sfdx-cli@7.26.0

(Or any other version).

Note that ordinarily there is some "gap" between the various version parts, and is not likely the issue. Normally, you'd upgrade/downgrade the entire salesforcedx package:

sfdx plugins:install salesforcedx@latest

Or

sfdx plugins:install salesforcedx@46.16.0

As a quick fix, I recommend:

sfdx update
sfdx plugins:update

This should ensure that all plugins are up to date.

Alternatively:

sfdx salesforcedx@latest

Also, you might be having some conflicts because, apparently, you wouldn't normally have both sfdx-cli and salesforcedx installed at the same time (you should be using the latter). DX works just fine on my computer without sfdx-cli installed. Here's what my config looks like, for reference:

$ sfdx plugins --core
@oclif/plugin-commands 1.2.2 (core)
@oclif/plugin-help 2.1.6 (core)
@oclif/plugin-not-found 1.2.2 (core)
@oclif/plugin-plugins 1.7.8 (core)
@oclif/plugin-update 1.3.9 (core)
@oclif/plugin-warn-if-update-available 1.7.0 (core)
@oclif/plugin-which 1.0.3 (core)
@salesforce/sfdx-trust 3.0.2 (core)
analytics 1.1.2 (core)
generator 1.1.0 (core)
mo-dx-plugin 0.2.5
salesforcedx 46.16.0
├─ force-language-services 46.23.0
└─ salesforce-alm 46.21.0
5
  • salesforcedx seems to follow a API version notation while sfdx-cli doesn't. If one supersedes the other what is the point of having both? Is there any? We have sfdx-cli installed because we are using a custom plugin to build scratch orgs and push code to them.
    – akarnid
    Oct 28 '19 at 20:38
  • @akarnid Looking at the "npm" repo, it appears that salesforcedx and sfdx-cli are both the same thing. Having both installed sounds like it would probably muck things up. Consider using one or the other, but not both. I think the default installer uses salesforcedx, so you don't need the other. I tried installing sfdx-cli and it just hung the process.
    – sfdcfox
    Oct 28 '19 at 21:23
  • I'm marking the answer as valuable. This convo may help others that stumble onto this in the future :)
    – akarnid
    Oct 29 '19 at 9:22
  • 2
    This didn't seem to work for me. I tried downgrading my sfdx-cli to 7.26, but this broke VS Code. sfdx still worked from the commandline, but it was still on the latest version. To address this I had to completely uninstall. Strange.
    – bpilling
    Nov 10 '19 at 20:59
  • 6
    this doesn't seem to work anymore. the cmd sfdx plugins:install sfdx-cli@downgrade-version succeeds, but then a quick check via sfdx plugins --core shows the version i had (and not the downgraded one). just FYI.
    – Zerkz
    Feb 24 '21 at 17:08
5

The accepted answer is not correct.

It depends how you installed the CLI originally. If you installed via npm, lie npm install -g sfdx-cli then you can use npm to install whatever version you like, ex: npm install -g sfdx-cli@7.109.0

If you installed via the installer (downloading a tarball, pkg, windows installer, etc) then you don't have an easy downgrade path without uninstalling the CLI first (it's not hard, it won't lose all your orgs).

Then you can install an older version (and turn off auto-update if you want to stay on the older version).

3

I recently had to downgrade sfdx cli and the solution proposed above did not work:

sfdx plugins:install salesforcedx@<version>

It appeared to, but then didn't really change anything. However, this blog post presented an answer that worked for me.

npm install sfdx-cli@<version> --global

replace with the version number you need.

After you have downgraded sfdx-cli to upgrade back to the latest version of sfdx-cli you will need to first uninstall using the npm command:

npm uninstall sfdx-cli

Then reinstall sfdx using the latest version available

2
  • thanks. sfdx:force:deploy was not working with latest release so downgraded to 100. Can you tell you what kind of issue you were facing? Aug 24 '21 at 7:54
  • 1
    @ManjotSingh, I was having trouble with creating 2gp packages. I was getting the error "package.xml: No package.xml found" and was advised to downgrade.
    – Thad
    Oct 1 '21 at 15:19
0
npm install sfdx-cli@<version> –global

did not work for me.

npm install -g sfdx-cli@<version>

worked. Replace the version number as per your need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.