I am trying to push a Laravel application with the CF CLI. I created a new Laravel application, a manifest.yml and tried to deploy it but got the error "Could not open input file: artisan".
All I did was :
composer create-project --prefer-dist laravel/laravel app
manifest.yml
---
applications:
- name: laravel-test
memory: 512M
buildpacks:
- php_buildpack_v4_6_13
cf push
Here's the result of the command :
Updating with these attributes...
---
applications:
- name: laravel-test
memory: 512M
+ default-route: true
buildpacks:
php_buildpack_v4_6_13
Manifest applied
Packaging files to upload...
Uploading files...
8.72 MiB / 8.72 MiB [==============================================================================================================================================================================] 100.00% 2s
Waiting for API to complete processing files...
Staging app and tracing logs...
Downloading php_buildpack_v4_6_13...
Downloaded php_buildpack_v4_6_13 (509.6M)
Cell 49e76781-b3ee-46da-b80b-b703787a9809 creating container for instance 217c9e0f-9274-4750-91d1-e6342a087455
Security group rules were updated
Cell 49e76781-b3ee-46da-b80b-b703787a9809 successfully created container for instance 217c9e0f-9274-4750-91d1-e6342a087455
Downloading app package...
Downloaded app package (24.5M)
-------> Buildpack version 4.6.13
Installing HTTPD
HTTPD 2.4.58
Downloaded [file:///tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/dependencies/https___buildpacks.cloudfoundry.org_dependencies_httpd_httpd_2.4.58_linux_x64_cflinuxfs4_bed46d20.tgz] to [/tmp]
Installing PHP
PHP 8.2.13
Downloaded [file:///tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/dependencies/https___buildpacks.cloudfoundry.org_dependencies_php_php_8.2.13_linux_x64_cflinuxfs4_300ddf44.tgz] to [/tmp]
Downloaded [file:///tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/dependencies/https___buildpacks.cloudfoundry.org_dependencies_php_php_8.2.13_linux_x64_cflinuxfs4_300ddf44.tgz] to [/tmp]
Downloaded [file:///tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/dependencies/https___buildpacks.cloudfoundry.org_dependencies_composer_composer_2.6.5_linux_noarch_any-stack_9a18e1a3.phar] to [/tmp]
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Package operations: 0 installs, 0 updates, 37 removals
- Removing theseer/tokenizer (1.2.2)
- Removing symfony/yaml (v6.4.0)
- Removing spatie/laravel-ignition (2.3.3)
- Removing spatie/ignition (1.11.3)
- Removing spatie/flare-client-php (1.4.3)
- Removing spatie/backtrace (1.5.3)
- Removing sebastian/version (4.0.1)
- Removing sebastian/type (4.0.0)
- Removing sebastian/recursion-context (5.0.0)
- Removing sebastian/object-reflector (3.0.0)
- Removing sebastian/object-enumerator (5.0.0)
- Removing sebastian/lines-of-code (2.0.2)
- Removing sebastian/global-state (6.0.1)
- Removing sebastian/exporter (5.1.1)
- Removing sebastian/environment (6.0.1)
- Removing sebastian/diff (5.1.0)
- Removing sebastian/complexity (3.2.0)
- Removing sebastian/comparator (5.0.1)
- Removing sebastian/code-unit-reverse-lookup (3.0.0)
- Removing sebastian/code-unit (2.0.0)
- Removing sebastian/cli-parser (2.0.0)
- Removing phpunit/phpunit (10.5.5)
- Removing phpunit/php-timer (6.0.0)
- Removing phpunit/php-text-template (3.0.1)
- Removing phpunit/php-invoker (4.0.0)
- Removing phpunit/php-file-iterator (4.1.0)
- Removing phpunit/php-code-coverage (10.1.11)
- Removing phar-io/version (3.2.1)
- Removing phar-io/manifest (2.0.3)
- Removing nunomaduro/collision (v7.10.0)
- Removing myclabs/deep-copy (1.11.1)
- Removing mockery/mockery (1.6.7)
- Removing laravel/sail (v1.26.3)
- Removing laravel/pint (v1.13.7)
- Removing hamcrest/hamcrest-php (v2.0.1)
- Removing filp/whoops (2.15.4)
- Removing fakerphp/faker (v1.23.0)
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Could not open input file: artisan
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
-----> Composer command failed
Traceback (most recent call last):
File "/tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/scripts/compile.py", line 55, in <module>
.from_build_pack('lib/additional_commands')
File "/tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/lib/build_pack_utils/builder.py", line 212, in extensions
process_extension(path, ctx, 'compile', process, args=[self])
File "/tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/lib/build_pack_utils/utils.py", line 69, in process_extension
success(getattr(extn, to_call)(*args))
File "/tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/extensions/composer/extension.py", line 444, in compile
return composer.compile(install)
File "/tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/lib/extension_helpers.py", line 154, in compile
self._compile(install)
File "/tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/extensions/composer/extension.py", line 196, in _compile
self.run()
File "/tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/extensions/composer/extension.py", line 343, in run
*self._ctx['COMPOSER_INSTALL_OPTIONS'])
File "/tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/extensions/composer/extension.py", line 390, in run
shell=True)
File "/tmp/buildpacks/bf04536342a2b09e39e9b4fc737b7c41/lib/build_pack_utils/runner.py", line 109, in stream_output
raise CalledProcessError(retcode, cmd)
build_pack_utils.runner.CalledProcessError: Command '<open file '<fdopen>', mode 'w' at 0x7fe8a9cb1ae0>' returned non-zero exit status 1
BuildpackCompileFailed - App staging failed in the buildpack compile phase
FAILED
Does anyone have any idea on how to resolve this problem ? I've searched but I didn't find it anywhere else.
Also, I can't try to change the buildpack to run some tests, custom buildpacks are not allowed where I am.
It looks like the error is occurring during the
composerinstall phase when it's trying to run thepost-autoload-dumpevent, specifically the@php artisan package:discover --ansicommand. The error message indicates that it could not open the input file:artisan.The Laravel application expects the artisan script to be present in the root directory. However, in a CF environment, the application is staged in a different directory, and the artisan script might not be accessible.
To resolve this issue, you can try the following steps:
Check Directory Structure
Ensure that the
artisanscript is present in the root directory of your Laravel application. When you create a new Laravel application usingcomposer create-project, theartisanscript should be automatically generated.Modify Composer Scripts:
Update your
composer.jsonfile to include the correct paths. Opencomposer.jsonand look for the "scripts" section. It should have something like this:Ensure that the
@php artisan package:discover --ansicommand is correctly pointing to theartisanscript. If needed, adjust the path to match the Cloud Foundry environment.Adjust Command in manifest.yml
You can optionally update your
manifest.ymlfile to specify the correct start command. Instead of relying on the default command, you can explicitly define the command to run your Laravel application. For example:Redeploy
After making these changes try redeploying and this should be enough.
pardon any kind of syntax errors