Scratch org creation omits the namespace spec in the sfdx-project and project-scratch-def files
When creating a scratch org (DX connection) in a project with a namespace specified, the resulting scratch org is missing the namespace attribute.
It is easy enough to manually add the line to the scratch org json file, but this used to be automatic in versions prior to 2.0.7.0
Comments (12)
-
repo owner -
reporter Just updated to 2.0.7.2 and the namespace is still omitted in new scratch orgs.
-
repo owner That's correct, Jeff. 2.0.7.1 and 2.0.7.2 have been updates to address issues with JetBrains' 2019.2 IDEs. Once I have that all squared away I'll get a bug fix release out including this. Sorry for the delay!
-
reporter No problem – just wanted to keep this up to date and maybe save you some testing time.
-
repo owner Hi, Jeff. I'm finally getting to take a look at this. Can you explain the workflow that used to work but no longer does? I just want to make sure I understand the nature of the regression so that I'm debugging the right thing.
-
reporter If I have a DX project, and add “namespace” : “jmay” to the project-scratch-def.json. Then, when I create a new scratch org, the new scratch org json file is missing the namespace.
-
repo owner Sorry, Jeff. I still think I'm missing something. I didn't think you could specify a namespace in
project-scratch-def.json
, only insfdx-project.json
. To be thorough I just tried to create an org with"namespace": "<my-namespace>"
in theproject-scratch-def.json
andforce:org:create
failed with a syntax error. I then updated mysfdx-project.json
with that same entry and created a scratch org against the dev hub where<my-namespace>
is registered, and it created a scratch org with that namespace. Can you please explain what you're doing differently? -
reporter No problem at all. Here are the steps I take that repro the issue (I am on IC 2.0.8.3 now)
- Open a DX project
1a) sfdx-project.json
{
"packageDirectories": [
{
"path": "force-app",
"default": true
}
],
"namespace": "XXXX",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "45.0"
}1b) project-scratch-def.json
{
"orgName": "XXXX Place",
"edition": "Developer",
"features": [],
"namespace": "XXXX",
"settings": {
"orgPreferenceSettings": {
"s1DesktopEnabled": true
}
}
}- Click Manage Connections
- Click DX (to create scratch org)
- Select the DevHub with the namespace
- Enter Org name (jtest)
- Click OK
- Yes, I wish to save
- Confirm the scratch org file name
- look at jtest-scratch-def.json and no namespace entry
{
"orgName": "jest",
"edition": "Developer",
"features": [],
"orgPreferences": {
"enabled": [],
"disabled": []
}
}- Manually edit the jtest-scratch-def.json add the line
"namespace": "XXXX",
so the result is
{
"orgName": "jest",
"edition": "Developer",
"namespace": "XXXX",
"features": [],
"orgPreferences": {
"enabled": [],
"disabled": []
}
}- Open the connection and see the namespace is being used
#####
-
repo owner Thanks, Jeff. I don't think that
*-scratch-def.json
supports thenamespace
attribute:That's why it's being lost as it's "laundered" through IC. IC deserializes what you have in your JSON file into an in-memory object which doesn't have a
namespace
property, then when you tell IC to save that back as a file, the property has been stripped.The
force:org:create
command derives its namespace from thesfdx-project.json
in the working directory:https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm
Of course, as you point out, you also need to be working against a dev hub for which that namespace has been registered.
I think this is working properly if not exactly as expected. It could also be that I'm missing something here, but based on my understanding the issue is that adding the namespace in 1b isn't supported. If you tried to use
sfdx force:org:create
against the file from 1b directly it would fail with a syntax error. -
reporter - changed status to resolved
Thanks, Scott. All better.
I removed the namespace attribute from the *-scratch-def.json and left it in the sfdx-project.json. Created a new scratch org and it got namespaced.
Closing this issue now.
-
repo owner Glad that did it, Jeff! Thanks for working through it with me.
-
repo owner - changed component to Metadata Deployment/Retrieval/Removal
- Log in to comment
Hmmm...that's strange. I'm not aware of anything I might have done to regress this, but obviously I did. I'll take a look today and see if I can figure out what's going on. I'll have a new release out in the next few days, so hopefully I can take care of it in that one. Thanks for bringing this to my attention, and sorry for the issue.