How to change /workspaces root folder as it is breaking deployment?

Hey guys,

I have a Laravel app which is working fine locally but when deploying to App Platform via Github I keep getting this error:

[2024-03-11 00:57:02] │        PHP Warning:  require_once(/workspace/bootstrap/app.php): Failed to open stream: No such file or directory in /workspace/artisan on line 20
[2024-03-11 00:57:02] │        PHP Fatal error:  Uncaught Error: Failed opening required '/workspace/bootstrap/app.php' (include_path='.:') in /workspace/artisan:20
[2024-03-11 00:57:02] │        Stack trace:
[2024-03-11 00:57:02] │        #0 {main}
[2024-03-11 00:57:02] │          thrown in /workspace/artisan on line 20
[2024-03-11 00:57:02] │        Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
[2024-03-11 00:57:02] │  !     WARNING: A post-autoload-dump script terminated with an error
[2024-03-11 00:57:02] │ 
[2024-03-11 00:57:02] │  !     ERROR: Dependency installation failed!
[2024-03-11 00:57:02] │  !     
[2024-03-11 00:57:02] │  !     The 'composer install' process failed with an error. The cause
[2024-03-11 00:57:02] │  !     may be the download or installation of packages, or a pre- or
[2024-03-11 00:57:02] │  !     post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
[2024-03-11 00:57:02] │  !     in your 'composer.json'.
[2024-03-11 00:57:02] │  !     
[2024-03-11 00:57:02] │  !     Typical error cases are out-of-date or missing parts of code,
[2024-03-11 00:57:02] │  !     timeouts when making external connections, or memory limits.
[2024-03-11 00:57:02] │  !     
[2024-03-11 00:57:02] │  !     Check the above error output closely to determine the cause of
[2024-03-11 00:57:02] │  !     the problem, ensure the code you're pushing is functioning
[2024-03-11 00:57:02] │  !     properly, and that all local changes are committed correctly.
[2024-03-11 00:57:02] │  !     
[2024-03-11 00:57:02] │  !     For more information on builds for PHP on Heroku, refer to
[2024-03-11 00:57:02] │  !
[2024-03-11 00:57:02] │  !     
[2024-03-11 00:57:02] │  !     REMINDER: the following warnings were emitted during the build;
[2024-03-11 00:57:02] │  !     check the details above, as they may be related to this error:
[2024-03-11 00:57:02] │  !     - A post-autoload-dump script terminated with an error
[2024-03-11 00:57:02] │ 
[2024-03-11 00:57:02] │ ERROR: failed to build: exit status 1

The line being referenced here is $app = require_once __DIR__.'/bootstrap/app.php';

I’ve tried changing the source_dir to ./, but it didn’t resolve the issue. The deployment log indicates that the workspace root is set to /workspace, which may be causing the problem:

1 01:09:52] │  ✔ cloned repo to /workspace
[2024-03-11 01:09:52] ╰────────────────────────────────────────╼
[2024-03-11 01:09:52] 
[2024-03-11 01:09:52]  › applying source directory ./
[2024-03-11 01:09:52]  ✔ using workspace root /workspace

My Laravel app includes a built-in installer that resides at a sub-URL. Locally, when I run php artisan serve and access the direct URL, it’s also broken until I navigate to the /install subdomain.

I’d greatly appreciate any advice or insight on how to resolve this deployment issue. Thank you!

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
April 6, 2024

Hi there,

The /workspace directory should not really be a problem, I’ve deployed a lot of Laravel apps and never had an issue with the root directory.

The error actually indicates that the ./bootstrap/app.php file is missing, can you verify that the bootstrap directory exists in your GitHub repository and that the app.php file is also committed?

The __DIR__ in the require statement is the part that automatically detects the full path to your project so it should not really matter if the Laravel app runs inside /workspace or any other directory.

If your project is open-source feel free to share a link to your repository here and I will be happy to take a further look.



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel