Laravel Nova installation via composer fails on production server
Asked Answered
K

3

5

I have added Laravel Nova to our application and purchased a license. On the local server everything works perfectly. However, when I try to deploy the updated application to our linux server and run composer update it says:

Failed to download laravel/nova from dist: /var/www/{myPath} does not exist and could not be created.
    Now trying to download from source

Syncing laravel/nova (3.29.0) into cache

Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos
Head to https://github.com/settings/tokens/new It will be stored in "/var/www/{myPath}"

So I created a GitHub Token and added the Laravel Nova credentials to the auth.json file on the server too. Everything should be correct and it is working on the local copy as I said before. However, I am getting the following errors:

[RuntimeException]                                                                                                                                    
Failed to execute git clone --mirror -- '[email protected]:laravel/nova.git' '/var/www/{myPath}/.cache/composer/vcs/git-github.com-laravel-nova.git/'                                                                                                                                              
                                                                                                                                                        
Cloning into bare repository '/var/www/{myPath}/.cache/composer/vcs/git-github.com-laravel-nova.git'...                                     
ERROR: Repository not found.                                                                                                                          
fatal: Could not read from remote repository.                                                                                                         
                                                                                                                                                        
Please make sure you have the correct access rights                                                                                                   
and the repository exists.      

How could I solve this problem?

Kings answered 20/8, 2021 at 10:13 Comment(3)
Why do you need to run composer update during a deployment? That can lead to different libraries being installed on different systems, and that's something you should avoid at all timesWarmonger
Also, /var/www/{myPath} does not exist and could not be created sounds strange - what have you tried to resolve this? Is that path maybe missing, or is it configured with wrong permissions such that your deployment process cannot write into that path?Warmonger
@NicoHaase : I know what composer updatedoes. The deployment takes place on our public DevServer. {myPath} is just a placeholder for the real path because of privacy reasons. There is nothing wrong with the configuration. It's all about the Laravel Nova resources.Kings
K
4

Deleting the /vendor directory and the composer.lock file and running composer install --optimize-autoloader --no-devsolved the problem.

Kings answered 21/8, 2021 at 8:59 Comment(1)
This is potentially incredibly problematic. The lock file exists for a reason, i.e. to lock versions with known compatibility.Didi
B
1

I had a similar problem and finally figured out the cause and its due to the laravel/nova:3.29. A minor upgrade to 3.30 fixed the issue for me without having to delete the whole composer.lock file as it will update some other packages as well.

Blen answered 18/5, 2022 at 7:51 Comment(2)
And how did you upgrade? You can't just change the composer.lock file, it will need new hash values & download targets and might have dependencies.Didi
composer require "laravel/nova:3.30" It will update the composer.lock but not delete it entirely as @Kings aluded to.Blen
G
1
  1. Create file at root directory with name "auth.json"
  2. copy your nova credentials to it
{
    "http-basic": {
        "nova.laravel.com": {
            "username": "email",
            "password": "passsword"
        }
    }
}
  1. composer update
Guadalupe answered 18/9, 2022 at 7:42 Comment(2)
How can these be kept in the environment instead of the source? Seems like a sketchy place to put creds...Didi
I keep mine in ~/.composer/auth.json locally on MacOS. That way, the auth works for all projects that use Nova. That is locally.Destalinization

© 2022 - 2025 — McMap. All rights reserved.