Removing old hub org, or non-scratch org from Salesforce DX org list

  • In the Salesforce DX pilot, every pilot participant was given a temporary dev hub org. These orgs expired, were destroyed, and sent back to the matrix in advance of the open beta.

    I had an existing installation of the Salesforce DX cli, and I found after upgrading, my old dev hub was still hanging about showing it had an invalid grant. So time to do some tidying.

    enter image description here

    Normally, to delete a scratch org, you'd just delete it. I wasn't sure, so first I attempted to remove it that way:

    sfdx force:org:delete -u dev-hub

    Only this didn't work. Salesforce DX only allows the deletion of scratch orgs, not other org types.

    I then created my new dev hub and attempted to replace the existing dev-hub alias by doing...

    sfdx force:auth:web:login -a dev-hub -d

    Only I was left with it still registered in the list, just with no more alias.

    enter image description here

    How do you remove a dev-hub org, or any other non-scratch org from the list of orgs in the SFDX CLI?

    Is that your music collection hiding in the back of the screenshots?! Good eye. LOL.

  • pchittum

    pchittum Correct answer

    4 years ago

    It would be nice for this to be something in the actual CLI commands: the ability to clean up old orgs that are no longer needed.

    For the time being, you need to manually cleanup the DX configs in the local installation.

    On mac/linux, you can find your DX config folder, called .sfdx in your user home directory.

    cd ~/.sfdx

    On windows, you can use %USERPROFILE%\.sfdx

    In that folder there are a host of .json files, named for the username of the admin user you registered for that org. In my case, in this instance it was called [email protected], so sure enough, there it was:

    [email protected]

    Inside the file, or the hashes for current access token, refresh token, and all the other OAuth goodness that allows DX to access your org. So I simply deleted that file:

    > rm [email protected]

    That appears to have cleaned it all up, and I'm no longer bothered by the "invalid grant" message and the shadow org.

    I believe SalesforceDX is still in beta state, so I would suggest not to use for big projects.

    To windows go to path like "C:\Users\ [MyUserName] \.sfdx" and you can to see the files

License under CC-BY-SA with attribution

Content dated before 7/24/2021 11:53 AM