2

I am getting this error while trying to fetch(retrieve) source from VS Code and SF Extension Pack.

STR :

Right click on sfdx-project-json -> click on Retreiev Source from Org.

enter image description here

The file is present in the directory. So the problem doesn't exist here.

3 Answers 3

6

The problem is that your sfdx-project.json file isn't a source file that can be retrieved. You'll need to select something valid to retrieve.

This can be a particular metadata file (e.g., a specific class file to retrieve just that class), a folder (e.g., the classes folder to retrieve all classes in the folder) or a manifest (package.xml file).

2
  • 1
    Hey John, Actually the situation is that I need to fetch all customObjects using VS Code and I added the entry of Custom Object in package.xml and tried again to retrieve data by right clicking on sfdx-project.json and clicking retrieve source and there I get error. Is there a way to retrieve the custom objects in that project Jan 2, 2019 at 12:49
  • 3
    For that, you should right-click on the package.xml file and click 'Retrieve Source from Org' to retrieve the metadata in your manifest. If you want to retrieve all of your custom objects and nothing else in the manifest you could also run the following command: sfdx force:source:retrieve -m CustomObject Jan 2, 2019 at 12:59
1

SOLVED This will solve for sure,

to retrieve multiple Unlocked packages to local system we need to add multiple path locations to Sfdx.JSON file. this make DX to look at these paths and retriev/Deploye without any error.

Your sfdx-project.json should looks like this.

{
  "packageDirectories": [
      { "path" : "force-app" ,"default": true }, 
      { "path" : "./ItemsToApprove" }
  ],
  "name": "Sandbox-Umesh",
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "56.0",
  "pushPackageDirectoriesSequentially": true
}

documentation given here

In my case the important part is "path" : "./ItemsToApprove", where ItemsToApprove is unlocked Package that I want retrieve/update.

I have answered here also :Link to my answer

2
  • It's not clear to me how this solves this specific question.
    – David Reed
    Feb 2 at 17:50
  • Hi @DavidReed, I have updated my answers. this error comes when we have unlocked the package along with the org metadata, and when we try to deploy or retrieve it throws the error. i think that it should be good to solve this error.
    – Umesh Beti
    Feb 3 at 6:38
0

While retrieving using sfdx:force:source:retrieve --manifest <path of Package.xml> was getting InvalidPackageDirectory error.

Steps:

  1. Go to Package.xml file
  2. Right-click on this file and select "Retrieve Source in Manifest from Org.

Resolution: From sfdx-project.json file removed unnecessary path. My sfdx-project.json looks like this.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .