[SalesForce] Accidentally created wrong directory then pushed, deleted directory now can’t push

When creating lightning components with sfdx I was giving the full path,

force-app/main/default/aura

when I was already in the directory that I wanted to place the component in. Therefore I created a bunch of unecessary sub directories. Before I knew it I had pushed to the org with all these wrong directories:

/home/maxbisesi/Public/geolocation/force-app/main/default/aura/force-app/main/default/aura/AccountLocator/AccountLocator.cmp.

I deleted the subdirectories and put all the components in the same dir where they belong but now when trying to push or pull I get:

ERROR: Expected content file(s) at source path(s): /home/maxbisesi/Public/geolocation/force-app/main/default/aura/force-app/main/default/aura/AccountLocator/AccountLocator.cmp.

What do I do ?

edit:

I tried

sfdx force:source:push --forceoverwrite

No dice…

Best Answer

In the root of your project, there should be a folder called

.sfdx

In there you will find a folder called

orgs

And in there will be a folder for each org you are pushing to. Inside each of those folders you will find a file called

sourcePathInfos.json

This file is where SFDX keeps track of what files it knows about, when they were last edited, what type of thing they are, etc etc etc

To fix your problem, you can do one of two things:

  1. Find and replace all instances of

    force-app/main/default/aura/force-app/main/default/aura/ 
    

    in that file with

     force-app/main/default/aura/
    

    if you're on Windows you may need to swap the / with \\ but you'll be able to see what you need when you open the file. Once that's done you can do

    sfdx force:source:push -u <your alias>
    

    and it should succeed.

  2. Alternatively you can just delete the entire file, and do

    sfdx force:source:push -u <your alias>
    

    Note: This will cause your whole project to be pushed rather than just changes, but afaict that just makes it slower - it doesn't break anything (or hasn't for me)

I've done it both ways and still haven't decided which is faster/easier. It would be nice if there was an sfdx cli command to re-scan the directory rather than having to do this by hand, but I've not found it yet...