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.
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.
How do you remove a dev-hub org, or any other non-scratch org from the list of orgs in the SFDX CLI?
Best Answer
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.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 peter@dx.pilot, so sure enough, there it was: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:
That appears to have cleaned it all up, and I'm no longer bothered by the "invalid grant" message and the shadow org.