We are trying to start using custom labels, but are having issues deploying them using our ant script.

Our custom labels file looks something like this:

<?xml version="1.0" encoding="UTF-8"?> 
<CustomLabels xmlns="http://soap.sforce.com/2006/04/metadata">
         <shortDescription>Inspection Name</shortDescription>

In the package.xml we have added this:


We are getting the following error when deploying:

Error: labels/CustomLabels.labels(Inspection_Name):Not in package.xml

Ant command (variables come from a properties file):


The package.xml and migration toolkit are both at API 27.0. What are we missing?

  • The first few lines of your XML are incorrect. Is that just a typo? You have the xmlns declaration running on in an un-opened tag after CustomLabels.
    – Mike Chale
    Commented May 30, 2013 at 18:56
  • Yep. Sorry, typo. Edited original post.
    – Rob Scott
    Commented May 30, 2013 at 19:07
  • Those files look fine to me, what is the ANT command and have you ensured that the customLabels file is actually present in the subdirectory /labels of the directory you have in the script? You will get that error if the filepath is wrong.
    – Doug B
    Commented May 30, 2013 at 19:21
  • Updated post with Ant command. The "target.dir" folder does contain the CustomLabels.labels file in the "labels" directory. This works (and has been working) with every file type except custom labels.
    – Rob Scott
    Commented May 30, 2013 at 20:06
  • Clutching at straws a bit here, but could it be because the label is <protected>? Labels I've deployed before have always had this attribute set to false. Not sure if this should make a difference though.
    – Doug B
    Commented May 31, 2013 at 10:17

2 Answers 2


I got the same error and tried the code below. It worked. The metadata type is CustomLabel not CustomLabels. It's very strange.


Salesforce Metadata Types

  • This works. I guess it's not terribly strange seeing that every other metadata type is also singular. It is unique though in that there is only a single file with a plural name and a plural file extension. A touch confusing.
    – Rob Scott
    Commented Nov 5, 2013 at 22:38

Are you sure that the package.xml in "${target.dir}/src" does indeed contain:


The error message like this

Error: labels/CustomLabels.labels(Inspection_Name):Not in package.xml

usually means that the package.xml file in your ${target.dir}/src" does not have labels definition. I.e. target dir contains more subfolders/types than specified in the package.xml. Every file in the deployRoot must be in package.xml.

  • The package.xml file being used definitely has the labels definition.
    – Rob Scott
    Commented May 31, 2013 at 16:21
  • Everything looks fine with your xml and ant. Try doing a refresh to see if the Custom Labels can be pulled down from an org or use the Force.com IDE rather than ANT. I've found that I sometimes get more meaningful errors using the IDE
    – BarCotter
    Commented Oct 17, 2013 at 10:33

You must log in to answer this question.

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