+ 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

Ashish Yaduka TrailheadAshish Yaduka Trailhead
I was having similar errors and the following package.xml fixed it: 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>*</members>
<name>ApexClass</name>
</types>
<types>
<members>*</members>
<name>ApexComponent</name>
</types>
<types>
<members>*</members>
<name>ApexPage</name>
</types>
<types>
<members>*</members>
<name>ApexTestSuite</name>
</types>
<types>
<members>*</members>
<name>ApexTrigger</name>
</types>
<types>
<members>*</members>
<name>AuraDefinitionBundle</name>
</types>
<types>
<members>*</members>
<name>LightningComponentBundle</name>
</types>
<!-- <types>
<members>*</members>
<name>StaticResource</name>
</types> -->

<version>49.0</version>
</Package>

I still can't right click on the package.xml and retrieve. I instead pick the Terminal tab inside VSCode and run this command: sfdx force:source:retrieve -x manifest/package.xml


 
Nikhil Reddy 26Nikhil Reddy 26
I had the same issue but running the below command from the terminal worked for me.

sfdx force:source:deploy -p force-app/main/default
Dawid Sobkowiak 30Dawid Sobkowiak 30
Thanks Nikhil and profBrains! sfdx force:source:deploy -p force-app/main/default was the correct solution for me!
Nitesh 22Nitesh 22
.. and retrieve source from org by right lick on "Package.Xml" and not on "manifest".

thanks, this was it
Fatima ParveenFatima Parveen

I have resolved this issue by simply adding "/" in the path of packageDirectories,

{
"packageDirectories": [
{
"path": "/force-app",
"default": true
}
],
"name": "DevOrg",
"namespace": "",
"sfdcLoginUrl": "https://login.salesforce.com",
"sourceApiVersion": "52.0"
}

praveen pandempraveen pandem
When I cloned git repository there is no manifest folder in the package it only had package.xml file. I created manifest folder and moved package.xml to manifest folder it resolved the issue.


 
Mitesh Parmar 3Mitesh Parmar 3
If you are asking this question in July 2022, just revert back the Salesforce CLI Integration extension to the previous version. It worked for me.  
eclarke-bceclarke-bc
Great catch Mitesh! Reverting the vscode extension back to v55.3.0 fixed the issue for me.
MAGESK SFDC DE 1MAGESK SFDC DE 1
can you  please help me to steps Reverting the vscode extension back to v55.3.0. While uninstall getting below error "Cannot uninstall 'Salesforce CLI Integration' extension. 'Visualforce' extension depends on this."
 
Francisco Daniel MolinaFrancisco Daniel Molina
Hello! I had the same problem and solved it this way:

1 - I returned the "Salesforce CLI" extension to version 55.3.0

2 - Then, I cleaned the connection of my Org (deactivate the ones I didn't use) and I connected from VSCode to the Playground that was "Developer Edition".

3 - I reopened VSCode and that's it! I was able to do the Deploy with right click and pass the challenge I was going through.

I hope it works for you!

P/D: If you don't understand something, excuse me, I don't speak English well.
KrishKeerKrishKeer
Thanks it worked.
Here is the clarfication on step one for those like me..     go to vscode-- extensions--select salesforce cli integration--on right pane try to uninstall then it will ask if you want to install a specific version... choose 55.3.0  .. enable if not done already...  re authorize the org.  
 
Shawn Welsh 6Shawn Welsh 6
Thanks, Francisco. That worked for me too.
Douglas MolinaDouglas Molina
I was facing this issue today... Just updating the Visual Studio "Salesforce CLI Integration" extention to the version v55.4.1 (relesed on 7/8/2022, 20:16:18), and restarting the VS solved the problem.
Mayur Pardeshi 1Mayur Pardeshi 1

I've managed to solve this issue by just changing the Salesforce CLI version 55.4.1 to 55.3.0:

Just goto Extention in VS code >> Search for Salesforce CLI Integration >> near Uninstall button there is drop-down >> Install another version (55.3.0).

hope this will solve your problem.

Karan_JainKaran_Jain
Hey 
I've managed to solve this issue 
you have to just check if your CLI is not updated then update your salesforce CLI version 55.4.1 
and if your CLI is updated then also is not working then change your salesforce CLI version 55.4.1 to 55.3.0
you can change the CLI version from Just goto Extention in VS code >> Search for Salesforce CLI Integration >> near Uninstall button there is a drop-down >> Install another version 
this error comes from salesforce CLI 
 
Nazrul AminNazrul Amin
Finally managed to download the source code onto my VS Code Editor..seems I had to specifically use the Retrieve Source Command from the Package.xml file, not the Package.json file...