Temporary folder "shape" not cleared out before `force:org:create` command executes
Last updated 13 days ago ·Reference W-7287154 ·Reported By 6 users
In Review
Summary
If you have multiple DX projects with varying configurations within each project's project-scratch-def.json files, the system temporary folder that the Salesforce CLI uses to define the shape of the scratch org can include definition files from previous force:org:create executions. This can lead to errors during the scratch org creation that are not present on other machines or from previous scratch org creation events.
Repro
1) execute the following command
sfdx force:org:create --setdefaultusername --wait 30 --setalias scratch-A --durationdays 1 --definitionfile config/a-project-scratch-def.json
2) examine the contents of the temporary folder used to define the "shape" of the scratch org.
It's contents are:
/shape
/objects
Account.object
package.xml
The Account.object file contains:
<?xml version="1.0" encoding="UTF-8"?>
<Object xmlns="http://soap.sforce.com/2006/04/metadata">
<recordTypes>
<fullName>Default</fullName>
<label>Default</label>
<active>true</active>
</recordTypes>
</Object>
The package.xml file contains:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Account</members>
<name>CustomObject</name>
</types>
<types>
<members>Account.Default</members>
<name>RecordType</name>
</types>
<version>50.0</version>
</Package>
3) execute the following command
sfdx force:org:create --setdefaultusername --wait 30 --setalias scratch-B --durationdays 1 --definitionfile config/b-project-scratch-def.json
4) examine the contents of the temporary folder used to define the "shape" of the scratch org.
It's contents are:
/shape
/objects
Account.object
Case.object
Contact.object
/settings
FieldService.settings
package.xml
The Account.object file remains the same as above.
The package.xml file now contains:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>FieldService</members>
<name>Settings</name>
</types>
<types>
<members>Account</members>
<members>Case</members>
<members>Contact</members>
<name>CustomObject</name>
</types>
<types>
<members>Account.Default</members>
<members>Case.Default</members>
<members>Contact.Default</members>
<name>RecordType</name>
</types>
<types>
<members>Case.DefaultProcess</members>
<name>BusinessProcess</name>
</types>
<version>50.0</version>
</Package>
5) execute the first force:org:create command again. This time with a different alias.
sfdx force:org:create --setdefaultusername --wait 30 --setalias scratch-FAILS --durationdays 1 --definitionfile config/a-project-scratch-def.json
The following failure message seen at this point:
=== Component Failures [4]
TYPE FILE NAME PROBLEM
───── ──────────────────────────────────── ───────────────────
Error shape/objects/Case.object Case.Default Not in package.xml
Error shape/objects/Case.object Case.DefaultProcess Not in package.xml
Error shape/objects/Contact.object Contact.Default Not in package.xml
Error shape/settings/FieldService.settings FieldService Not available for deploy for this organization
This error results from the fact that the "shape definition temp files" from the previous scratch org creation were not cleaned out at the beginning of the third execution of the force:org:create command.
Workaround
Workaround is to locate the folder and delete it manually.
Reported By (6)
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.
