question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

force:org:create doesn't use namespace from sfdx-project.json (or perhaps that entire file) sometimes (metadata format vs. source format?)

See original GitHub issue

I’ve been working through some IC2 issues with the NPSP project lately, many due to the fact that it’s a strange hybrid of SFDX and traditional. It has an sfdx-project.json file and numerous scratch org definition files under its orgs directory, but the actual files are (mostly) in metadata format instead of source format. I say “mostly” because the documents seem to follow the source format conventions rather than metadata format conventions. Otherwise all XML metadata filenames use their metadata type-specific file extensions instead of that plus -meta.xml, and there’s no metadata decomposition.

So that’s the setup. The actual issue I’m reporting here is that if I specify a namespace in the sfdx-project.json file that is properly associated with the dev hub against which I’m creating a scratch org, then run sfdx force:org:create from the NPSP project directory, the scratch org is not created with that (or any) namespace. In fact, if I specify an invalid namespace in sfdx-project.json there are no errors, so it seems it’s either not consulting that file or it’s deciding not to use the namespace from that file for some reason.

On the other hand, if I create a dummy SFDX project using sfdx force:project:create such that its sfdx-project.json file contains the same namespace and create the scratch org from that project directory, the scratch org is created with the specified namespace.

How does the sfdx force:org:create command decide whether/how to use the information in sfdx-project.json? Does it also look at the contents of the specified package directories? This disparity in behavior is confusing and seemingly incorrect when the org is created without a namespace.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
davidmreedcommented, Mar 26, 2021

Background on the unusual project layout for the Nonprofit Success Pack:

NPSP is built using CumulusCI, Salesforce.org’s orchestration layer on top of Salesforce DX. The NPSP project is in Metadata API format. However, it also comes with all of the infrastructure to define and build scratch orgs, because CumulusCI supports building scratch orgs for products in both Metadata API and Salesforce DX source formats.

CumulusCI is the recommended route to build a scratch org for NPSP. Salesforce DX itself will not work without walking through a lot of manual steps, as NPSP includes six managed packages and unmanaged setup that must be deployed prior to pushing source into the org.

0reactions
SCWells72commented, Mar 29, 2021

Okay, I’ve figured out the part where the namespace wasn’t being set. Because of the hybrid nature of the NPSP project, IC2 wasn’t setting the working directory for the CLI when it executes, instead causing that process’ working directory to be the sfdx script’s parent directory. When IC2 properly sets the working directory to be the parent directory of sfdx-project.json when executed for the NPSP project, the namespace is set properly even when the plugins property is present in sfdx-project.json.

It’s still strange that the namespace is set properly when a scratch org is created from a non-project working directory if plugins is not present but isn’t set when plugins is present in that same scenario, but since that’s a weird use case, I’d say go ahead and resolve this case since the other problem with settings deployment via the REST API is being handled elsewhere.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: SFDX Deploy source to org - Salesforce Stack Exchange
By default, all source code/metadata is stored in a folder called " force-app ". Currently, my sfdx-project.json file looks like:
Read more >
Salesforce DX Project Configuration - Salesforce Developers
We provide sample sfdx-project.json files in the sample repos for creating a project using Salesforce CLI or Salesforce Extensions for VS Code.
Read more >
CI and Delivery Using Salesforce Developer Experience
Continuous Integration is the practice of merging all developer working copies to a ... SFDX source format differs from Metadata API format.
Read more >
Random handy CumulusCI notes - Katie Kodes
I created a file /.sfdx/sfdx-config.json whose contents are: ... project from scratch, using a source format of sfdx , not mdapi , and...
Read more >
SalesforceDX - Salesforce Application Architect
Sometimes, you have files in your local DX project that you don't want to ... your metadata packages, it's important to have the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found