Today I again tried to Authorize Developer Hub (Dev Hub) org, set it as default by using below command:
sfdx force:auth:web:login --setdefaultdevhubusername --setalias DevHub
After authorizing dev hub, I was able to create scratch org.
I'll answer as I did find some kind of workaround
Those steps allow me to work DX-style with Managed Package, Namespace and Person Account
1 Create scratch org WITHOUT Namespace, using flag -n, --nonamespace
sfdx force:org:create -f config/project-scratch-def.json -a ScratchNONameSpace -s -n
2 First thing is to pull Account.Business_Account, which works as expected
$ sfdx force:source:status -r
=== Source Status
STATE FULL NAME TYPE PROJECT PATH
Remote Add Account.Business_Account RecordType
$ sfdx force:source:pull
=== Pulled SourceSTATE FULL NAME TYPE PROJECT PATH
Add Account.Business_Account RecordType force-app/main/default/objects/Account/recordTypes/Business_Account.recordType-meta.xml
3 Create scratch org WITH Namespace
sfdx force:org:create -f config/project-scratch-def.json -a ScratchWithNameSpace -s
4 Check status, you'll see conflicts
$ sfdx force:source:status
=== Source Status
STATE FULL NAME TYPE PROJECT PATH
Local Add (Conflict) Account.Business_Account RecordType force-app/main/default/objects/Account/recordTypes/Business_Account.recordType-meta.xml
Remote Changed (Conflict) Account.Business_Account RecordType force-app/main/default/objects/Account/recordTypes/Business_Account.recordType-meta.xml
5 Push your code using flag -f, --forceoverwrite
$ sfdx force:source:push -f
=== Pushed Source
STATE FULL NAME TYPE PROJECT PATH
Add Account.Business_Account RecordType force-app/main/default/objects/Account/recordTypes/Business_Account.recordType-meta.xml
$ sfdx force:source:status
=== Source Status
No results found
After that you would be able to push/pull without issues.
Best Answer
From the script you provided you created Scratch Org with alias 'scratchorg4', but then you're trying to open 'myscracthorg'. Try running
sfdx force:org:list
to display list of your Scratch OrgsSide Note. You use 3 different aliases:
- scratchorg4 for creation
- myscratchorg for push
- myscracthorg for openning
probably typos. If this is one bash/cmd script set org value to some variable or just add
-s
param so org:create, so this Scratch Org will be used by default if no username is specified