How to install git packages.json dependencies with CircleCI node container?

Hello :slight_smile:
In my packages.json dependencies there’s 2 modules I want to fetch during npm install

“dependencies”: {
@myproj/modules1”: “git+ssh://git@github.com/myproj/mudules1.git#v3.0.0”,
@myproj/modules2”: “git+ssh://git@github.com/myproj/mudules2.git#v3.0.0”
}

I created deploy key for both and added add_ssh_keys step to the config.yml, both of keys are installed during the workflow (Can see in logs that the fingerprints installed) but when executing npm intsall I get:

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/myproj/mudules2.git
npm ERR!
npm ERR! ERROR: Repository not found.
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128

looks like module 1 is working ok - but module 2 cannot be fetched (I’m missing something??)

1 Like

Are they private dependencies?

It may help readers to see your config - would you add it, in a formatted block? Thanks.

1 Like

Yes they are private repos, I’ve tried to connect to the circleci container for debugging and found that when trying to ssh -T git@github.com it replies with
Hi repositoryname! You've successfully authenticated, but GitHub does not provide shell access.
Now the repositoryname is always the first fingerprint in list - and after I checked few times it always fetching successfully the repository with the first fingerprint - any idea ?

Again, may we see your CircleCI config? :slightly_smiling_face:

1 Like

I’m having the same issue. A CircleCI config like this will reproduce it:

version: 2
jobs:
  build:
    docker:
      - image: circleci/node:12
    working_directory: ~/repo
    steps:
      - checkout
      - add_ssh_keys:
          fingerprints:
            - 'FI:NG:ER:PR:INT' # deploy key added to dependency repo
      - run: ssh-add -L # This shows that the key was successfully added
      - run: npm ci # or `npm install` The failure is here
      - run: npm test

and a package.json like

{
  "name": "project",
  "dependencies": {
    "somedep": "git+ssh://git@github.com/organization/repo.git"
  }
}

Hi, I solved it in the following way,

  1. Create a machine user. (If you don’t have it)
    See https://circleci.com/docs/2.0/gh-bb-integration/#controlling-access-via-a-machine-user

  2. Change git+ssh://git@github.com/... to ssh://git@github.com...