+ Start a Discussion
Daniel RobertsDaniel Roberts 

The file or directory that you tried to deploy or retrieve isn't in a package directory

Hey guys trying to get comfortable with the Salesforce CLI, and went to deploy my code changes to my Dev Org but I keep getting the following error message. I checked out the link that they listed, but couldn't seem to figure out what issue was. I modified the JSON with the folder name that I'm trying to deploy, but still had no luck. 
 
Error deploying or retrieving source: The file or directory that you tried to deploy or retrieve isn't in a package directory that's specified in your sfdx-project.json file. Add this location to your "packageDirectories" value, or deploy or retrieve a different file or directory. For details about sfdx-project.json, see: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm

 
NagendraNagendra (Salesforce Developers) 
Hi Daniel,

Sorry for this issue you are facing.

May I suggest you please refer to below link from the stack exchange community with a similar discussion and suggested workaround. Please let us know if this helps.

Kindly mark this as solved if the reply was helpful.

Thanks,
Nagendra
Shakir Beg 23Shakir Beg 23
Hi,
I am facing the same issue. I have used force-app with a relative path to the directory. Still i am facing the same issue. Kindly help me on this.
If possible please provide any example of solution.

Thanks,
Shakir
Ankit GuptaAnkit Gupta
I was getting the same error on retrieving the components from org. So i went to the actual package.xml file on my vs code ide and right click > SFDX:Retreive Source in Manifest from org and it worked. Then you can try the SFDX: Deploy this source to Org
Daniel LoaderDaniel Loader
I'm having the same problem but it runs when executing 
sfdx force:source:deploy --sourcepath .\force-app\
However it doesn't run when trying to use the action in VSCode:
SFDX: deploy this source to org

My sfdx-project.json looks like the following though:
{
  "packageDirectories": [
    {
      "path": "force-app",
      "default": true
    }
  ],
  "namespace": "",
  "sfdcLoginUrl": "https://test.salesforce.com",
  "sourceApiVersion": "45.0"
}

 
Shakir Beg 23Shakir Beg 23
Hi, 
I had removed Static resource from from package.xml file then it worked fine for me.

Thanks,
Shakir
BraneBrane
I had the same issue and the problem was the package.xml file. I've removed the AuraDefinitionBundle and LighningComponentBundle from the manifest file and everyting was retrived as expeced (My Application is not using Aura and LightningComponentBundle).
 
<types>
    <members>*</members>
    <name>AuraDefinitionBundle</name>
</types>
<types>
    <members>*</members>
    <name>LightningComponentBundle</name>
</types>

 
sridhar j 26sridhar j 26
Hi all 
 is any one find the solution for this error ,if yes please share with mw
Thanks
Sri
Chandramohan Yetukuri 1Chandramohan Yetukuri 1
Hi,
I too had the same problem. I got the error when i right click and Deploy to Source Org.

Error deploying or retrieving source: The file or directory that you tried to deploy or retrieve isn't in a package directory that's specified in your sfdx-project.json file. Add this location to your "packageDirectories" value, or deploy or retrieve a different file or directory. For details about sfdx-project.json, see: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm

But i was able to deploy with the following command.

sfdx force:source:deploy --sourcepath .\force-app\main\default\classes\testFirstClass.cls --json --loglevel trace

Regards,
Chandra
Saket Ranjan 3Saket Ranjan 3
update your sfdx through cmd using command " C:\Users\username>sfdx update "  and retrieve source from org by right lick on "Package.Xml" and not on "manifest".
profBrainsprofBrains

Hi Guys - I had a similar issue listed above.

Resolution: Use Terminal to deploy through this command.

sfdx force:source:deploy -p force-app/main/default