I did a symfony 4.3 app, and would like to put it on my OVH server. I Saved my app on github, and ignored .env file, plus all files and folders already ignored in .gitignore. Then, in SSH, in my OVH server, I did a git clone to get my app on it. Then I did a composer update to get all the files and folders missing (var, vendor, .env). This gave me the error :
Executing script cache:clear [KO]
[KO]
script cache:clear returned with error 255
!!
script @auto-scripts was called via post-update-cmd
And vendor was present on my server, but neither var nor .env. So I manually transfered .env in FTP via filezilla, I changed it with APP_ENV=prod, then I created manually (still with filezilla) a var folder, with cache and log folders in it (I didn't transfered mine so that it's empty, so already cleared). Then I checked : my website was working on the internet (from my server, not in local).
So, problem solved ? ... Yes and no. The website works, but my purpose isn't to post a website on the internet, but to learn (I follow a symfony lesson on udemy). I got to learn how to make automatically deployments with heroku.
So I create a heroku account, linked it to my github account, and to my app. But when I try to deploy manually from heroku (to check it works before doing automatically deployments), I still have a cache clear 255 error (the [modified : some numbers and letters] are things I hidden in the error message because I wondered if this could be sensitive) :
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!! PHP Fatal error: Uncaught Symfony\Component\Dotenv\Exception\PathException: Unable to read the "/tmp/build_[modified : some numbers and letters]/.env" environment file. in /tmp/build_[modified : some numbers and letters]/vendor/symfony/dotenv/Dotenv.php:484
!! Stack trace:
!! #0 /tmp/build_[modified : some numbers and letters]/vendor/symfony/dotenv/Dotenv.php(65): Symfony\Component\Dotenv\Dotenv->doLoad(false, Array)
!! #1 /tmp/build_[modified : some numbers and letters]/vendor/symfony/dotenv/Dotenv.php(85): Symfony\Component\Dotenv\Dotenv->load('/tmp/build_a7cc...')
!! #2 /tmp/build_[modified : some numbers and letters]/config/bootstrap.php(15): Symfony\Component\Dotenv\Dotenv->loadEnv('/tmp/build_a7cc...')
!! #3 /tmp/build_[modified : some numbers and letters]/bin/console(30): require('/tmp/build_a7cc...')
!! #4 {main}
!! thrown in /tmp/build_[modified : some numbers and letters]/vendor/symfony/dotenv/Dotenv.php on line 484
!!
Script @auto-scripts was called via post-install-cmd
! ERROR: Dependency installation failed!
!
! The 'composer install' process failed with an error. The cause
! may be the download or installation of packages, or a pre- or
! post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
! in your 'composer.json'.
!
! Typical error cases are out-of-date or missing parts of code,
! timeouts when making external connections, or memory limits.
!
! Check the above error output closely to determine the cause of
! the problem, ensure the code you're pushing is functioning
! properly, and that all local changes are committed correctly.
!
! For more information on builds for PHP on Heroku, refer to
! https://devcenter.heroku.com/articles/php-support
! Push rejected, failed to compile PHP app.
! Push failed
Because of the error message, I looked in my composer.json file, I have this :
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
Is there something wrong with it ? I don't see what I could change in it.
I tried many things I found on the internet :
https://github.com/symfony/flex/issues/406 composer update symfony/flex --no-plugins --no-scripts. composer install
executed in ssh didn't create any errors in itself, but didn't resolved the problem when trying again to deploy on heroku
I also try what the teacher in my lesson proposed in this case :
composer config disable-tls true
composer install
Same : no errors when doing this, but didn't solve the problem when trying to deploy on heroku
And many things since yesterday, I don't remember everything I tried :-/ but nothing worked.