Newer Version Available
Error: No default dev hub found
Let’s say you successfully authorize a Dev Hub org using the --set-default-dev-hub flag. The username associated with the org is your default Dev Hub username. You then successfully create a scratch org without using the --target-dev-hub flag. But when you try to create a scratch org another time using the same CLI command, you get this error:
1Error (1): No default dev hub found. Use -v or --target-dev-hub to specify an environment.What happened?
Answer: You’re no longer in the directory where you ran the authorization command. The directory from which you use the --set-default-dev-hub flag matters.
If you run the authorization command from the root of your project directory, the target-dev-hub config variable is set locally. The value applies only when you run the command from the same project directory. If you change to a different directory and run org create scratch, the local setting of the default Dev Hub org no longer applies and you get an error.
Solve the problem by doing one of the following.
-
Set target-dev-hub globally so that you can run org create scratch from any directory.
1sf config set target-dev-hub=<devhubusername> --global -
Run org create scratch from the same project directory where you authorized your Dev Hub org.
-
Use the --target-dev-hub flag with org create scratch to run it from any directory.
1sf target-dev-hub --definition-file <file> --target-dev-hub <devhubusername> --alias my-scratch-org -
To check whether you’ve set configuration values globally or locally, use this command and check the Location column.
1sf config list