I am new at my organization. I'd like to download all the Apex classes. I am on a Mac and I am working directly in the Terminal. (I might setup VSCode later, but for now I'm just working in the Terminal.)

I start by getting authorized:

sfdx auth:device:login -r https://fakename.my.salesforce.com

That went well.

I tried:

sfdx force:source:retrieve -m ApexClass

but I got an error message about not having my local folder setup correctly. I needed to create this file:


Okay, no problem, I create the problem. I look up a generic example online and I copy-and-paste this:

  "packageDirectories": [
      "path": "force-app",
      "default": true
  "namespace": "",
  "sfdcLoginUrl": "https://login.salesforce.com",
  "sourceApiVersion": "56.0"

The only thing I change is sourceApiVersion.

Now I can run:

sfdx force:source:retrieve -m ApexClass

that sort of works but it only downloads two folders with config files:


I know that we have hundreds of Apex classes, but none of them download.

I'm thinking maybe the problem is that I don't have the correct metadata in sfdx-project.json? How would I find such information? Or is the problem something else?

1 Answer 1


To make the folder be set up correctly, consider just moving to the parent folder and creating a project:

sfdx force project create -n myExistingFolderName

It'll create all the necessary files and folders you need to get started for real.

Next, move into that directory and set the default user:

cd myExistingFolderName
sfdx force config set defaultusername=my-username-or-alias

And also, use npm to install any dependencies you might need:

npm i

Now, you should be able to get your metadata:

sfdx force source retrieve -m ApexClass
  • This worked like a charm! I've been trying to set this up for weeks and I could not find these exact instructions anywhere! Salesforce needs to take what you wrote here and add it to their setup instructions, especially for anyone with a Mac! Commented Mar 26, 2023 at 18:17

You must log in to answer this question.

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