Salesforce CLI deploy files with spaces failing

I am trying to deploy files to a non-source tracked org with the cli deploy command as follows:

sfdx force:source:deploy -u [ORG] -p "force-app/main/default/layouts/Snapshot__mdt-Snapshot Layout.layout-meta.xml"

but am getting this error:

ERROR running force:source:deploy:  The Layout named Snapshot__mdt-Snapshot Layout was not found in the workspace.

I’ve tried -p ''"[path/to/file]"'' and -p "\"[path/to/file]\"" and neither worked.

The file definitely exists and I am able to use the beta diff command from VSCode on this file.

So how do we include files with spaces in the name in our -p arg?

Answer

OK I figured it out on Mac OSX. For a single file -p works as follows:

sfdx force:source:deploy -p "force-app/main/default/layouts/Snapshot__mdt-Snapshot Layout.layout-meta.xml"

However, for multiple files with your -p argument, you need to surround each filename with escaped double quotes as follows:

sfdx force:source:deploy -p """force-app/main/default/layouts/SnapshotDetail__mdt-SnapshotDetail Layout.layout-meta.xml"",""force-app/main/default/layouts/Snapshot__mdt-Snapshot Layout.layout-meta.xml"""

And finally, another problem I had, make sure none of the files are in your .forceignore or you will get the Not Found In Workspace error.

Attribution
Source : Link , Question Author : Shane K , Answer Author : Shane K

Leave a Comment