3

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
5

5 Answers 5

10

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.)

5

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
1
  • That worked for me.
    – Json
    May 2, 2019 at 21:33
3

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
1
  • BEST ANSWER FOR ME!!! It's super important to note that in the real world where you work with multiple projects at a time it's a terrible idea to set a default org. Thanks for this valuable additional information!!
    – Bahman.A
    Mar 30, 2021 at 23:11
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

I know this is an old thread but here is my finding who needs it. Need to provide

--edition=developer|enterprise|group|professional|partner-developer|partner-enterprise|partner-group|partner-professional

Like this

    sf org create scratch --definition-file config/project-scratch-def.json --alias MyScratchOrg --set-default --edition=developer
1
  • 1
    Note that the reported error message was "Must pass a username..." Do you want to state that you get this error message by not providing the edition parameter in the prescribed way?! This is not even a required parameter - see here. Mar 8 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .