acorn icon indicating copy to clipboard operation
acorn copied to clipboard

open_basedir php warning restriction with shared hostings due to "closest" method

Open SergiArias opened this issue 1 year ago • 6 comments

Version

4.2.2

What did you expect to happen?

No php warning in shared hosting

What actually happens?

Warning: is_readable(): open_basedir restriction in effect.
File(/home) is not within the allowed path(s)

Origin: https://discourse.roots.io/t/open-basedir-restriction-in-effect-tried-everything/27183/10

The problem is the closest method in /vendor/roots/acorn/src/Roots/Acorn/Filesystem/Filesystem.php

It can be patched in line 32 (this is just a patch, it won't work for specific restrictions in every shared hosting):

        // -- while ($this->isReadable($currentDirectory)) {
        while ($currentDirectory !== '/home' && $this->isReadable($currentDirectory)) {

Steps to reproduce

Upload roots sage to any shared hosting with open_basedir restriction

System info

No response

Log output

No response

Please confirm this isn't a support request.

Yes

SergiArias avatar Jun 08 '24 09:06 SergiArias

Do you have logs from web/app/cache/acorn/logs that might better pinpoint where this issue is specifically happening?

Log1x avatar Jun 08 '24 09:06 Log1x

Of course, here you have. But the problem arises in closest() method in /vendor/roots/acorn/src/Roots/Acorn/Filesystem/Filesystem.php line 32 because it goes folder by folder searching for an env file until it reaches /home.

In my case I am not using bedrock.

[2024-06-07 21:17:03] development.ERROR: is_readable(): open_basedir restriction in effect. File(/home) is not within the allowed path(s): (/home/aestivum:/home2/aestivum:/usr/local/wepanel/filemanager:/usr/lib/php:/usr/local/lib/php:/tmp:/usr/local/bin/wp:/usr/local/bin/composer:/opt/alt/php82) {"userId":1,"exception":"[object] (ErrorException(code: 0): is_readable(): open_basedir restriction in effect. File(/home) is not within the allowed path(s): (/home/aestivum:/home2/aestivum:/usr/local/wepanel/filemanager:/usr/lib/php:/usr/local/lib/php:/tmp:/usr/local/bin/wp:/usr/local/bin/composer:/opt/alt/php82) at /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/illuminate/filesystem/Filesystem.php:523)
[stacktrace]
#0 /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/HandleExceptions.php(49): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 [internal function]: Roots\\Acorn\\Bootstrap\\HandleExceptions->handleError()
#2 /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/illuminate/filesystem/Filesystem.php(523): is_readable()
#3 /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/roots/acorn/src/Roots/Acorn/Filesystem/Filesystem.php(32): Illuminate\\Filesystem\\Filesystem->isReadable()
#4 /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(382): Roots\\Acorn\\Filesystem\\Filesystem->closest()
#5 /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(326): Roots\\Acorn\\Bootloader->environmentPath()
#6 /home/aestivum/public_html/domain/wp-content/themes/sage-theme/vendor/roots/acorn/src/Roots/helpers.php(46): Roots\\Acorn\\Bootloader->getApplication()
#7 /home/aestivum/public_html/domain/wp-includes/class-wp-hook.php(324): Roots\\{closure}()
#8 /home/aestivum/public_html/domain/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#9 /home/aestivum/public_html/domain/wp-includes/plugin.php(517): WP_Hook->do_action()
#10 /home/aestivum/public_html/domain/wp-settings.php(673): do_action()
#11 /home/aestivum/public_html/domain/wp-config.php(98): require_once('/home/aestivum/...')
#12 /home/aestivum/public_html/domain/wp-load.php(50): require_once('/home/aestivum/...')
#13 /home/aestivum/public_html/domain/wp-admin/admin-ajax.php(22): require_once('/home/aestivum/...')
#14 {main}
"} 

SergiArias avatar Jun 08 '24 15:06 SergiArias

Having the exact same issue here. After deploying on shared hosting environment, this error comes up. Of course, it's only really an issue with WP_DEBUG enabled.

I resolved it now by creating an empty .env file in my WP root directory to prevent this warning from showing up. Why's Acorn looking for this file in the directory tree and where should it actually sit? And what kind of environment data is supposed to be written in it?

And here's my acorn log:

[2024-08-03 21:50:36] development.ERROR: is_readable(): open_basedir restriction in effect. File(/root_folder) is not within the allowed path(s): (/root_folder/htdocs/:/root_folder/apps/:/root_folder/priv/:/root_folder/tmp/:/root_folder/.cache/:/usr/share/pear/:/usr/share/php/:/tmp/:/usr/bin/:/dev/urandom:/usr/local/php/:/opt/php-5.6/:/opt/php-7.2/:/opt/php-7.3/:/opt/php-7.4/:/opt/php-8.0/:/opt/php-8.1/:/opt/php-8.2/:/opt/php-8.3/) {"userId":1,"exception":"[object] (ErrorException(code: 0): is_readable(): open_basedir restriction in effect. File(/root_folder) is not within the allowed path(s): (/root_folder/htdocs/:/root_folder/apps/:/root_folder/priv/:/root_folder/tmp/:/root_folder/.cache/:/usr/share/pear/:/usr/share/php/:/tmp/:/usr/bin/:/dev/urandom:/usr/local/php/:/opt/php-5.6/:/opt/php-7.2/:/opt/php-7.3/:/opt/php-7.4/:/opt/php-8.0/:/opt/php-8.1/:/opt/php-8.2/:/opt/php-8.3/) at /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/illuminate/filesystem/Filesystem.php:523)
[stacktrace]
#0 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/HandleExceptions.php(49): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'is_readable(): ...', '/var/www/hst359...', 523, Array)
#1 [internal function]: Roots\\Acorn\\Bootstrap\\HandleExceptions->handleError(2, 'is_readable(): ...', '/var/www/hst359...', 523)
#2 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/illuminate/filesystem/Filesystem.php(523): is_readable('/var/www/hst359...')
#3 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Filesystem/Filesystem.php(33): Illuminate\\Filesystem\\Filesystem->isReadable('/var/www/hst359...')
#4 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(382): Roots\\Acorn\\Filesystem\\Filesystem->closest('/var/www/hst359...', '.env')
#5 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(326): Roots\\Acorn\\Bootloader->environmentPath()
#6 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/helpers.php(46): Roots\\Acorn\\Bootloader->getApplication()
#7 /root_folder/htdocs/public_html.dev/wp-includes/class-wp-hook.php(324): Roots\\{closure}('')
#8 /root_folder/htdocs/public_html.dev/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#9 /root_folder/htdocs/public_html.dev/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#10 /root_folder/htdocs/public_html.dev/wp-settings.php(678): do_action('after_setup_the...')
#11 /root_folder/htdocs/public_html.dev/wp-config.php(96): require_once('/var/www/hst359...')
#12 /root_folder/htdocs/public_html.dev/wp-load.php(50): require_once('/var/www/hst359...')
#13 /root_folder/htdocs/public_html.dev/wp-admin/admin.php(34): require_once('/var/www/hst359...')
#14 {main}
"} 
[2024-08-03 21:50:36] development.ERROR: Uncaught Error: Call to undefined function Symfony\Component\ErrorHandler\ErrorRenderer\highlight_file() in /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:251
Stack trace:
#0 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/trace.html.php(36): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->fileExcerpt('/var/www/hst359...', 251, 5)
#1 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#2 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/traces.html.php(48): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->include('views/trace.htm...', Array)
#3 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#4 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/exception.html.php(54): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->include('views/traces.ht...', Array)
#5 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#6 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/exception_full.html.php(35): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->include('views/exception...', Array)
#7 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#8 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(138): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->include('views/exception...', Array)
#9 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(70): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->renderException(Object(Symfony\Component\ErrorHandler\Exception\FlattenException))
#10 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(708): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->render(Object(Symfony\Component\ErrorHandler\Exception\FlattenException))
#11 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(682): Illuminate\Foundation\Exceptions\Handler->renderExceptionWithSymfony(Object(Error), true)
#12 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(663): Illuminate\Foundation\Exceptions\Handler->renderExceptionContent(Object(Error))
#13 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(642): Illuminate\Foundation\Exceptions\Handler->convertExceptionToResponse(Object(ErrorException))
#14 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Exceptions/Handler.php(27): Illuminate\Foundation\Exceptions\Handler->prepareResponse(Object(Illuminate\Http\Request), Object(ErrorException))
#15 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(218): Roots\Acorn\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ErrorException))
#16 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/HandleExceptions.php(91): Illuminate\Foundation\Bootstrap\HandleExceptions->renderHttpResponse(Object(ErrorException))
#17 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(195): Roots\Acorn\Bootstrap\HandleExceptions->renderHttpResponse(Object(ErrorException))
#18 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(ErrorException))
#19 {main}
  thrown {"userId":1,"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Uncaught Error: Call to undefined function Symfony\\Component\\ErrorHandler\\ErrorRenderer\\highlight_file() in /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:251
Stack trace:
#0 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/trace.html.php(36): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->fileExcerpt('/var/www/hst359...', 251, 5)
#1 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#2 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/traces.html.php(48): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->include('views/trace.htm...', Array)
#3 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#4 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/exception.html.php(54): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->include('views/traces.ht...', Array)
#5 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#6 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/exception_full.html.php(35): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->include('views/exception...', Array)
#7 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#8 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(138): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->include('views/exception...', Array)
#9 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(70): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->renderException(Object(Symfony\\Component\\ErrorHandler\\Exception\\FlattenException))
#10 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(708): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->render(Object(Symfony\\Component\\ErrorHandler\\Exception\\FlattenException))
#11 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(682): Illuminate\\Foundation\\Exceptions\\Handler->renderExceptionWithSymfony(Object(Error), true)
#12 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(663): Illuminate\\Foundation\\Exceptions\\Handler->renderExceptionContent(Object(Error))
#13 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(642): Illuminate\\Foundation\\Exceptions\\Handler->convertExceptionToResponse(Object(ErrorException))
#14 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Exceptions/Handler.php(27): Illuminate\\Foundation\\Exceptions\\Handler->prepareResponse(Object(Illuminate\\Http\\Request), Object(ErrorException))
#15 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(218): Roots\\Acorn\\Exceptions\\Handler->render(Object(Illuminate\\Http\\Request), Object(ErrorException))
#16 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/HandleExceptions.php(91): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->renderHttpResponse(Object(ErrorException))
#17 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(195): Roots\\Acorn\\Bootstrap\\HandleExceptions->renderHttpResponse(Object(ErrorException))
#18 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleException(Object(ErrorException))
#19 {main}
  thrown at /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:251)
[stacktrace]
#0 {main}
"} 
[2024-08-03 21:50:36] development.ERROR: is_readable(): open_basedir restriction in effect. File(/root_folder) is not within the allowed path(s): (/root_folder/htdocs/:/root_folder/apps/:/root_folder/priv/:/root_folder/tmp/:/root_folder/.cache/:/usr/share/pear/:/usr/share/php/:/tmp/:/usr/bin/:/dev/urandom:/usr/local/php/:/opt/php-5.6/:/opt/php-7.2/:/opt/php-7.3/:/opt/php-7.4/:/opt/php-8.0/:/opt/php-8.1/:/opt/php-8.2/:/opt/php-8.3/) {"userId":1,"exception":"[object] (ErrorException(code: 0): is_readable(): open_basedir restriction in effect. File(/root_folder) is not within the allowed path(s): (/root_folder/htdocs/:/root_folder/apps/:/root_folder/priv/:/root_folder/tmp/:/root_folder/.cache/:/usr/share/pear/:/usr/share/php/:/tmp/:/usr/bin/:/dev/urandom:/usr/local/php/:/opt/php-5.6/:/opt/php-7.2/:/opt/php-7.3/:/opt/php-7.4/:/opt/php-8.0/:/opt/php-8.1/:/opt/php-8.2/:/opt/php-8.3/) at /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/illuminate/filesystem/Filesystem.php:523)
[stacktrace]
#0 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/HandleExceptions.php(49): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'is_readable(): ...', '/var/www/hst359...', 523, Array)
#1 [internal function]: Roots\\Acorn\\Bootstrap\\HandleExceptions->handleError(2, 'is_readable(): ...', '/var/www/hst359...', 523)
#2 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/illuminate/filesystem/Filesystem.php(523): is_readable('/var/www/hst359...')
#3 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Filesystem/Filesystem.php(33): Illuminate\\Filesystem\\Filesystem->isReadable('/var/www/hst359...')
#4 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(382): Roots\\Acorn\\Filesystem\\Filesystem->closest('/var/www/hst359...', '.env')
#5 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(326): Roots\\Acorn\\Bootloader->environmentPath()
#6 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/helpers.php(46): Roots\\Acorn\\Bootloader->getApplication()
#7 /root_folder/htdocs/public_html.dev/wp-includes/class-wp-hook.php(324): Roots\\{closure}('')
#8 /root_folder/htdocs/public_html.dev/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#9 /root_folder/htdocs/public_html.dev/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#10 /root_folder/htdocs/public_html.dev/wp-settings.php(678): do_action('after_setup_the...')
#11 /root_folder/htdocs/public_html.dev/wp-config.php(96): require_once('/var/www/hst359...')
#12 /root_folder/htdocs/public_html.dev/wp-load.php(50): require_once('/var/www/hst359...')
#13 /root_folder/htdocs/public_html.dev/wp-blog-header.php(13): require_once('/var/www/hst359...')
#14 /root_folder/htdocs/public_html.dev/index.php(17): require('/var/www/hst359...')
#15 {main}
"} 
[2024-08-03 21:50:36] development.ERROR: Uncaught Error: Call to undefined function Symfony\Component\ErrorHandler\ErrorRenderer\highlight_file() in /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:251
Stack trace:
#0 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/trace.html.php(36): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->fileExcerpt('/var/www/hst359...', 251, 5)
#1 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#2 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/traces.html.php(48): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->include('views/trace.htm...', Array)
#3 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#4 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/exception.html.php(54): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->include('views/traces.ht...', Array)
#5 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#6 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/exception_full.html.php(35): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->include('views/exception...', Array)
#7 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#8 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(138): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->include('views/exception...', Array)
#9 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(70): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->renderException(Object(Symfony\Component\ErrorHandler\Exception\FlattenException))
#10 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(708): Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer->render(Object(Symfony\Component\ErrorHandler\Exception\FlattenException))
#11 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(682): Illuminate\Foundation\Exceptions\Handler->renderExceptionWithSymfony(Object(Error), true)
#12 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(663): Illuminate\Foundation\Exceptions\Handler->renderExceptionContent(Object(Error))
#13 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(642): Illuminate\Foundation\Exceptions\Handler->convertExceptionToResponse(Object(ErrorException))
#14 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Exceptions/Handler.php(27): Illuminate\Foundation\Exceptions\Handler->prepareResponse(Object(Illuminate\Http\Request), Object(ErrorException))
#15 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(218): Roots\Acorn\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ErrorException))
#16 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/HandleExceptions.php(91): Illuminate\Foundation\Bootstrap\HandleExceptions->renderHttpResponse(Object(ErrorException))
#17 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(195): Roots\Acorn\Bootstrap\HandleExceptions->renderHttpResponse(Object(ErrorException))
#18 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(ErrorException))
#19 {main}
  thrown {"userId":1,"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Uncaught Error: Call to undefined function Symfony\\Component\\ErrorHandler\\ErrorRenderer\\highlight_file() in /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:251
Stack trace:
#0 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/trace.html.php(36): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->fileExcerpt('/var/www/hst359...', 251, 5)
#1 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#2 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/traces.html.php(48): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->include('views/trace.htm...', Array)
#3 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#4 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/exception.html.php(54): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->include('views/traces.ht...', Array)
#5 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#6 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/Resources/views/exception_full.html.php(35): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->include('views/exception...', Array)
#7 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(339): include('/var/www/hst359...')
#8 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(138): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->include('views/exception...', Array)
#9 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php(70): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->renderException(Object(Symfony\\Component\\ErrorHandler\\Exception\\FlattenException))
#10 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(708): Symfony\\Component\\ErrorHandler\\ErrorRenderer\\HtmlErrorRenderer->render(Object(Symfony\\Component\\ErrorHandler\\Exception\\FlattenException))
#11 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(682): Illuminate\\Foundation\\Exceptions\\Handler->renderExceptionWithSymfony(Object(Error), true)
#12 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(663): Illuminate\\Foundation\\Exceptions\\Handler->renderExceptionContent(Object(Error))
#13 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Exceptions/Handler.php(642): Illuminate\\Foundation\\Exceptions\\Handler->convertExceptionToResponse(Object(ErrorException))
#14 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Exceptions/Handler.php(27): Illuminate\\Foundation\\Exceptions\\Handler->prepareResponse(Object(Illuminate\\Http\\Request), Object(ErrorException))
#15 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(218): Roots\\Acorn\\Exceptions\\Handler->render(Object(Illuminate\\Http\\Request), Object(ErrorException))
#16 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/HandleExceptions.php(91): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->renderHttpResponse(Object(ErrorException))
#17 /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/roots/acorn/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(195): Roots\\Acorn\\Bootstrap\\HandleExceptions->renderHttpResponse(Object(ErrorException))
#18 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleException(Object(ErrorException))
#19 {main}
  thrown at /root_folder/htdocs/public_html.dev/wp-content/themes/sage/vendor/symfony/error-handler/ErrorRenderer/HtmlErrorRenderer.php:251)
[stacktrace]
#0 {main}
"} 

m0n0mind avatar Aug 03 '24 22:08 m0n0mind

Will look into getting a fix for this. In the mean time, you can create an empty .env file at the root of your web application and it should resolve any errors related to this.

Log1x avatar Aug 03 '24 22:08 Log1x

Oops! Very sorry, I missed your message above the stack trace saying you had already done that. .env usually contains environment-specific configuration for your application. You can see it in-use in a WordPress setting with Bedrock - Acorn in this context is attempting to load the environment configuration when booting Laravel. Laravel uses .env it's self for configuration in multiple areas which are then read from in config files - but it in no way should be required for Acorn in particular as all values have sane defaults and is indeed a bug.

Log1x avatar Aug 03 '24 22:08 Log1x

Oops! Very sorry, I missed your message above the stack trace saying you had already done that. .env usually contains environment-specific configuration for your application. You can see it in-use in a WordPress setting with Bedrock - Acorn in this context is attempting to load the environment configuration when booting Laravel. Laravel uses .env it's self for configuration in multiple areas which are then read from in config files - but it in no way should be required for Acorn in particular as all values have sane defaults and is indeed a bug.

Thanks for your explanation and for looking into this. :) Yeah, given that Acorn can be used outside the usual but optional Roots environment this file should not be mandatory in such a scenario.

m0n0mind avatar Aug 04 '24 07:08 m0n0mind

@Log1x was a fix ever released for this? I'm running into this issue and adding an empty .env file is not ideal, thanks!

chester-af avatar Nov 03 '25 15:11 chester-af

This is fairly trivial to write in theory, but then you have to consider testing (not simple to set open_basedir on the fly during tests), symlinks, and path normalization.

Here's a starting point, though:

    protected function isWithinOpenBasedir($path)
    {
        $allowedPaths = explode(PATH_SEPARATOR, ini_get('open_basedir'));
        if (empty($allowedPaths)) {
            return true;
        }
        return array_reduce($allowedPaths, fn ($allowed, $allowedPath) => $allowed || strpos($path, $allowedPath) === 0, false);
    }

I'll give it a think and try to come up with a solution over the weekend.

QWp6t avatar Nov 13 '25 20:11 QWp6t