All of a sudden I started getting this error everytime I'm trying to deploy or retrieve a file directly (right click on apex file and retrieve). This always worked and now it doesn't for all of my projects. I tried opening new ones, etc. 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
5 Answers
You are not alone Walker. This fearture was working fine until 8th Jul 2022. This is a bug in the new "Salesforce CLI Integration" extension.
The only one way I was able to made it work is to downgrade the "Salesforce CLI Integration" extension version.
Hope this issue will be fixed soon!

- 31
- 1
-
I will try downgrading tomorrow. Let's hope it works – Walker Jul 08 '22 at 18:03
I was facing the same issue while deploying from Visual Studio. I refreshed the Apex Extensions, restarted Visual Studio and the problem was resolved.

- 11
- 1
-
I reloaded the Apex extension and everything started working again... This was the solution for me! Although I did also uninstall and install most of them the other day, but this time it worked. Cheers brother. – Walker Jul 11 '22 at 08:15
Another work around is by right-clicking on /manifest/package.xml and selecting 'SFDX: Deploy Source in Manifest to Org' to deploy all your source listed in there. Not ideal, but this successfully deploys for me.

- 13
- 3
-
Yes Michael, that way it works, probably with sfdx commands as well, but it's a drag... – Walker Jul 08 '22 at 18:02
The extension has been fixed as of today.
If you're still getting the error navigate to the Extensions button and click reload on one of the Salesforce extensions:
See this image for instructions on reloading VS Code Extensions

- 26
- 3
I was having this issue and I had to downgrade the version number in the manifest\package.xml file. (I got my copy of the package.xml from https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/manifest_samples.htm)
In my case, the file from the website was v58.0 and I had downgrade to v57.0.
Additionally, I had to run the command by right clicking on the package.xml file, otherwise it would not work!

- 8,872
- 12
- 69
- 83