1

I was trying to create a scratch org following the trailhead

https://trailhead.salesforce.com/content/learn/projects/quick-start-salesforce-dx/create-and-test-our-scratch-org?trail_id=sfdx_get_started

I'm stuck in the following section Create and Test Our Scratch Org - Step 2

while executing the following command getting the following error.

sfdx force:org:create -s -f config/project-scratch-def.json -a dreamhouse-org

ERROR running force:org:create: Must pass a username and/or OAuth options when creating an AuthInfo instance.

Steps Executed

  1. Created Project in VSCode
  2. Authorized an Org
  3. Executed Trailhead steps as mentioned in the link
4

You have to login first.

sfdx force:auth:web:login -d -a DevHub

(This is in the prior step, you can't work on them separately.)

4

Authorize your Dev Hub on the same folder directory where you will create your scratch org.

\VSCodeQuickstart\my_sfdx_project\dreamhouse-sfdx$ sfdx force:auth:web:login -d -a DevHub

\VSCodeQuickstart\my_sfdx_project\dreamhouse-sfdx$ sfdx force:org:create -s -f config/project-scratch-def.json -a dreamhouse-org
  • That worked for me. – Json May 2 at 21:33
2

I faced the same issue. To resolve it, do the following step :

  1. Re auth your org in ebikes-lwc folder(or your named folder) via following

    sfdx force:auth:web:login -d -a ebikeslwcOrgAlias
    
  2. Now try to create scratch org :

    sfdx force:org:create -s -f config/project-scratch-def.json -a ebikes
    

enter image description here

0

When working on multiple projects I am of the opinion it is a bad idea to have a default devhub org set; only a matter of time when a command gets executed against the wrong org :).

I don't have a default org set and explicitly specify it with --targetdevhubusername= when needed:

$ sfdx force:auth:web:login -a sf3
$ sfdx force:org:create -s -f config/project-scratch-def.json -a dreamhouse-org --targetdevhubusername=sf3

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.