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.
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-hubalias 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?
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
.sfdxin your user home directory.
On windows, you can use
In that folder there are a host of
.jsonfiles, 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:
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.