I need to retrieve a package with a comma inside by command -> sfdx force:mdapi:retrieve -p "package, name".

I understand -p accepts multiple packages in one go with comma as a separator. This makes me no idea how to pass in a package name with comma inside.

Already tested these scenarios below, they do not work:

  • double-quoted package name,
  • double-quoted package name with Back-slashed comma,
  • double-quoted package name with double back-slashed comma

Escaping the comma would have been my first approach - however if you execute the sfdx command in a shell, then the shell will also interpret characters in arguments. You could try to "double-escape", e.g. write ... "package\\, name". The shell would interpret \\ as an escaped backslash sign and pass one backslash sign towards the sfdx command.

| improve this answer | |
  • good point, I did just give it a try, the command still doesn't accept -> ERROR running force:mdapi:retrieve: The metadata retrieve operation failed: INVALID_CROSS_REFERENCE_KEY: No package named 'package\' found – Xi Xiao Sep 23 '19 at 8:33
  • This looks like the sfdx command sees the backslash character in its argument but doesn't interpret it as an escape character. I've tried URL encoding the comma and space in the package name, thinking that sfdx being a node.js tool this could lead somewhere - but it doesn't. – Magnus Kreth Sep 23 '19 at 8:58

As source:retrieve is available now, it is better to use this latest retrieve method (mdapi had some bugs)

sfdx force:source:retrieve -n "Package1, PackageName With Spaces, Package3"
| improve this answer | |
  • 1
    Good to know. However, trying this command results in the same error that a package with a comma in its name can not be retrieved. – Magnus Kreth Sep 23 '19 at 9:45
  • Could you point out what bugs mdapi could have? Just out of curiosity. – Xi Xiao Sep 24 '19 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.