Cached wrong host means I can't run npm install

So I accidently pushed a package.json file containing the wrong host for git.

"dependencies": {
    "private-repo": "git+ssh://git@github.com-wronghost/etc"
    ...
}

I’ve since corrected this replacing github.com-wronghost with just github.com but circleci seems to have cached the old host and I can’t seem to bust it. The docs describing how to bust the cache are frankly terrible, it seems to describe a button I should be able to click without describing where this is located and I can’t see one anywhere. I’ve tried busting it from the api but that didn’t work.

git cloning the repo works when I ssh into the rerun job which suggests this is a npm/caching issue.

I’m unable to run a build for this job now because npm install keeps failing to resolve the host

ssh: Could not resolve hostname github.com-wronghost: Name or service not known

So here’s the ridiculous length I had to go to to get around this.

Create a config file containing the ssh configs including the wrong hostname that resolves to just github.com

Host github.com
     HostName github.com
     User git
     IdentityFile ~/.ssh/id_rsa

Host github.com-wronghost
     HostName github.com
     User git
     IdentityFile ~/.ssh/id_rsa_somefingerprint

Base64 encode it to preserve whitespace/newlines and add this as a project environment variable in the CircleCI project settings. I’m also adding an ssh key via the “SSH Permissions” tab and injecting it below.

Then decode and write the result to a file in ~/.ssh/config

- add_ssh_keys:
    fingerprints:
    - "so:me:fi:ng:er:pr:in:t"

- run:
    name: "Setup ssh"
    command: |
      echo $SSH_CONFIG | base64 --decode > ${HOME}/.ssh/config

- run: npm install

Now it works. But this is a hack not a solution.