How to exclude objects from other packages (prefix) in sfdx? Since I created a dependent unlocked package when I add custom fields to objects of the "needed/parent" package when I retrieve the custom field sfdx also retrieves the object which later results in an error since we cannot overwrite components of another package.

How kan ik exclude objects from another package?

** Update:

My .forceignore file is in the root folder of my project.

  • I created a map ignore under the default map
  • I tried adding /force-app/main/default/ignore to the .forceignore file
  • I tried adding force-app/main/default/ignore .forceignore file

I get the same error : Must specify a non-empty label for the CustomObject

Which is resolved if I remove the object of the other package from my package

** Update:

Here is my force ignore file this is at the root of my project

# .forceignore v2
# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm

# LWC configuration files

# LWC Jest

2 Answers 2


Manually move the object files into another directory after retrieval and add the new directory into the .forceignore

  • Thanks for your answer please check my update this is not working
    – Thomas
    Commented Dec 1, 2021 at 11:38
  • @Thomas Can you add an example of what you are specifying? It might be worth to look into your folder structure and the XML you have. Commented Dec 2, 2021 at 0:18
  • I added my force ignore file, What/which do you mean with XML
    – Thomas
    Commented Dec 7, 2021 at 6:21

For anyone who bumps into this issue my findings:

  1. There is a difference between os systems windows uses \ in the gitignore and mac /
  2. Add the directory path and filename to the force.ignorefile after retrieval. Do not move the files after retrieval into a new directory since after a new retrieval the files will be retrieved in the original map and will still cause issues.

Example (mac):


You must log in to answer this question.

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