1

I just created a new scratch org and then went to push the current metadata source to it with the command:

sfdx force:source:push

The failed with an error:

ERROR running force:source:push: Expected file at path: D:\p\force-app\main\default\classes\BatchClassThatDoesNotExist.cls-meta.xml

Which seemed odd, as there never was a BatchClassThatDoesNotExist class in the project. Somehow there was a BatchClassThatDoesNotExist.cls in the file system (but no corresponding .cls-meta.xml). I chalked that up to some oddity that accidentally created a new file and just removed the offending file BatchClassThatDoesNotExist.cls.

Now when I attempt the same push operation to the scratch org I get the error:

ERROR running force:source:push: Expected file at path: D:\p\force-app\main\default\classes\BatchClassThatDoesNotExist.cls

Which seems odd, as I just intentionally deleted that file in VSCode.

How can I get the source pushing to the scratch org correctly without the unwanted class?

2

Beyond the problem of the rogue class file, I assume the problem is related to the local source tracking that the SFDX CLI performs. It still wants to push the file to Salesforce even though it no longer exists.

The following command will reset the local source tracking.

force:source:tracking:clear

It does come with the following warning:

WARNING: This operation will modify all your local source tracking files.
The operation can have unintended consequences on all the force:source commands. 
Are you sure you want to proceed (y/n)?

This should be fine for a scratch org that is otherwise empty.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.