[SalesForce] Issue with Prod deployment from VS Code sfdx CLI

I'm trying to deploy my objects from VS Code to Prod. All my object is in Source format. But when I try to deploy, I get below error :

sf:INVALID_OPERATION: INVALID_OPERATION: testLevel of NoTestRun cannot be used in production organizations

And if I give RunLocalTest command it gives below error:

ERROR running force:source:deploy: ERROR: This command doesn't support wildcards. Remove the wildcard, and run the command again.
See –help for examples.

Here is my command which I'm trying to run for Prod deployment

sfdx force:source:deploy –sourcepath /Users/salesforceDeveloper/Desktop/SFDC Project/Prod Migration/force-app/main/default/objects -l RunLocalTests -u TargetEnv

Also is there any command using which I can only validate my component in Prod?

Thanks

Best Answer

You have a space in your file path, so the CLI thinks you're trying to add multiple paths. Make sure you either quote:

"/Users/salesforceDeveloper/Desktop/SFDC Project/Prod Migration/force-app/main/default/objects"

Or backslash escape:

/Users/salesforceDeveloper/Desktop/SFDC\ Project/Prod\ Migration/force-app/main/default/objects

Or ideally, move the folder to a place without spaces. They tend to cause problems wherever you go. I recommend something like /workspace/salesforce/migration or something like that.


To verify only, use -c as a parameter:

sfdx force:source:deploy -p force-app/ -c -w 100 -l RunLocalTests -u targetOrg

I also recommend a wait time (-w 100) so that you can get feedback when the deployment is finished. If you don't use this parameter, you need to run force:source:deploy:report later, which is usually just annoying.