1

I am trying to create a Scratch Org with a Namespace using command:

sfdx force:org:create -s -f config/project-scratch-def.json -a my-namespace -d 30

But I get this error:

ERROR running force:org:create: We don’t recognize this namespace: my-namespace. Did you register it in your Dev Hub org?

I realise what the error message is telling me...

I need to create the Namespace.

I want to double-check my understanding of the solution is correct.

Currently, creating a Namespace is only possible via a traditional Developer Org rather than a Scratch Org or just via the Namespace Registries page in my Dev Hub Org

Therefore, there is no way to develop a 2PG Managed Package without first using an old school Developer Org to create the Namespace?

1 Answer 1

5

The documentation specifically says:

Sign up for a new Developer Edition org

I.e. you are right; you must have an org on which the namespace is defined and the (recommended) way of doing that is to use a new Developer Edition org, then to link that namespace to your dev hub.

For us we use a specific pattern for the org name to ensure they are listed in our PBO's Environment Hub together.

6
  • The last line in your answer is a best practice that you follow to efficiently manage both 1GP as well as 2GP in your production org and not really something strictly to be followed from scratch org point of view, right? I would prefer not to get confused by the usage of the term Environment Hub when talking about 2GP. So, this is just for my understanding.
    – arut
    Dec 31, 2020 at 15:24
  • You still need to keep the dev org with the namespace, so having it in the env hub makes sense to me. (The dev hub being something different, but actually also being the PBO itself.)
    – Phil W
    Dec 31, 2020 at 15:45
  • Oh, and scratch orgs are quite a separate thing again.
    – Phil W
    Dec 31, 2020 at 15:45
  • That's right. In second generation packaging, while the dev orgs with namespace needs to be maintained, the namespace registry would be used to manage the namespaces (where it can be on a separate Dev Hub or PBO as Dev Hub). Environment Hub would be something completely different and relevant exclusively to first generation packaging. So, unless you are managing a mix of 1GP & 2GP in your production env, there wouldn't be a need for Env Hub. Since, the question was tagged as 2GP, I felt that mentioning about Env Hub could be confusing. Does that make sense?
    – arut
    Dec 31, 2020 at 17:31
  • 2
    You want the developer org to be in your environment hub for management and access purposes. You don't want to loose the org...
    – Phil W
    Dec 31, 2020 at 18:44

You must log in to answer this question.

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