Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jwilson's avatar

Envoyer composer install - not working with private repositories

I have a Laravel app that has a private repository dependency in the composer.json file:

    "repositories": [
        {
            "type": "git",
            "url": "[email protected]:example/example-package.git"
        },
    ]

When deploying with Envoyer - it will always fail on the composer install step

  Failed to execute git clone --no-checkout '[email protected]:example/example-package.git'
  Permission denied (publickey).                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  fatal: Could not read from remote repository.                                                                                                                                                                                                                                                                                                                                                                                                                                                               

I've created an ssh key for the user that Envoyer is using to run this deployment and added that key to the example-package repository. But it still fails with the same message.

What am I missing? There is nothing in the docs about this, and cannot find any solid answers on this anywhere.

Thanks

0 likes
1 reply
jwilson's avatar
jwilson
OP
Best Answer
Level 6

I finally was able to figure this out.

I discovered that the ssh key for accessing bitbucket needs to be added to the ssh-agent on the server. But the ssh-agent doesn't load automatically, and the added keys do not persist between ssh requests. So I had to add commands to the .bashrc file to load the ssh-agent and add the ssh key so this would happen on every ssh command request.

These are the commands I added to the top of the .bashrc file:

eval `ssh-agent`
ssh-add ~/.ssh/<my_pubic_bitbucket_key>

Note: I had to put these commands at the top of my .bashrc file because there is an if statement at the top that stops evaluating the file if it's not running interactively.

Please or to participate in this conversation.