Sage 9 based theme causing server to 500

Hi - I hope you can help me debug an strange issue I’m having. I have a site I’ve been developing locally with sage 9 without a problem. Today it came to where I wanted to put the site on a staging server to show the client my progress. Server is DO on latest ubuntu and deploy has gone ok. If I go through the setup of wordpress though the browser - add site-name and admin and password etc. everything works. if I select any theme it works and if I activate all the plugins it works.

If I try to upload my dev database (where sage 9 based theme is active) everything front and backend starts to 500 error. Likewise if on my ‘vanilla’ install I select the sage 9 based theme everything 500’s front end and admin.

I suspect therefor ethat this is a php error somewhere in my theme (?) but:

  • why does this work locally?
  • how can I debug the php on the staging server if it is only showing 500 error.

I I have updated trellis/roles/php/defaults/main.yml to:

memcached_sessions: false

php_error_reporting: 'E_ALL & ~E_DEPRECATED & ~E_STRICT'
php_display_errors: 'On'
php_display_startup_errors: 'On'
php_max_execution_time: 120
php_max_input_time: 300
php_max_input_vars: 1000
php_memory_limit: 96M
php_mysqlnd_collect_memory_statistics: 'Off'
php_post_max_size: 25M
php_sendmail_path: /usr/sbin/ssmtp -t
php_session_save_path: /tmp
php_upload_max_filesize: 25M
php_track_errors: 'On'
php_default_timezone: '{{ default_timezone }}'

php_opcache_enable: 1
php_opcache_enable_cli: 1
php_opcache_fast_shutdown: 1
php_opcache_interned_strings_buffer: 8
php_opcache_max_accelerated_files: 4000
php_opcache_memory_consumption: 128
php_opcache_revalidate_freq: 60

php_xdebug_remote_enable: "false"
php_xdebug_remote_connect_back: "false"
php_xdebug_remote_host: localhost
php_xdebug_remote_port: "9000"
php_xdebug_remote_log: /tmp/xdebug.log
php_xdebug_idekey: XDEBUG
php_max_nesting_level: 200

but can’t locate any error logs on the server…

I appreciate any help!

So /srv/www/<SITE_NAME_IN_YOUR_CONFIG>/logs is empty?

Did you reprovision after updating that file?

Yes - just checking for the logs in the location cfx suggested…

Also…

Likewise if on my ‘vanilla’ install I select the sage 9 based theme everything 500’s front end and admin.

What’s a “vanilla” install? Do you mean your local vm?

Hey - no, ‘Vanilla’ being not uploading my database, but going though site setup via the browser.

Found the logs! :blush: -

I’m getting a fatal error:

988#988: *78 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Class 'Roots\Sage\Assets\JsonManifest' not found ..../sage9/src/helpers.php:25```

this is line 25 of that file:

isset($manifest) || $manifest = new JsonManifest(get_template_directory() . '/' . Asset::$dist . '/assets.json');

I’ve just checked in the theme folder and there is no dist folder there. Does the npm run build:production need to be run manually before deploy perhaps?

I’m just taking a guess here, but have you ran composer install (sage), npm install and copied your sage/dist files during deploy?

Sorry this could be a case of ‘read the manual’ If I ssh onto the DO droplet and run npm install I get an UNMET PEER DEPENDENCY node-sass@^3.4.2 error.

To clarify what I should be doing -

  1. ssh to theme folder on DO droplet
  2. run npm install
  3. run npm run build:production

all on the droplet?

Thanks - apologies for my misunderstanding of the process.

Have a look at the roots-example-project : https://github.com/roots/roots-example-project.com/blob/master/trellis/deploy-hooks/build-before.yml

You can start from there and configure deploy commands for Sage 9 (composer install, npm install, copy local files) so that they are part of your deploy. If I’m not mistaken:

composer install on the droplet
npm install & npm run build:production locally
copy local dist/ files to droplet

2 Likes

Oh of course! - I’ve done this so many times I don’t know how I overlooked that. I am a fool!

Isn’t that part of the deploy task itself?
Because it should be run in the deploy_helper.new_release_path right?

Ah no, it should also be run in the theme folder!

My build-before.yml looks like this:

- name: Install Composer dependencies
  command: composer install --no-ansi --no-dev --no-interaction --no-progress --optimize-autoloader --no-scripts
  args:
    chdir: "{{ deploy_helper.new_release_path }}/web/app/themes/sage9"

- name: Run Build
  command: npm run build:production
  connection: local
  args:
    chdir: "{{ project.local_path }}/web/app/themes/sage9"

- name: Copy project local files
  synchronize:
    src: "{{ project.local_path }}/web/app/themes/sage9/dist"
    dest: "{{ deploy_helper.new_release_path }}/web/app/themes/sage9"
    group: no
    owner: no
    rsync_opts: --chmod=Du=rwx,--chmod=Dg=rx,--chmod=Do=rx,--chmod=Fu=rw,--chmod=Fg=r,--chmod=Fo=r

(There should also be an npm install task in there, but at the time of writing that is causing me some bugs with dependencies and dev-dependencies…)

2 Likes

I’m getting similar issue occasionally.

I’m using Linux install.

Edited for Errors when trying to use Sage theme.

( ! ) Fatal error: Uncaught Error: Class ‘Roots\Sage\Assets\JsonManifest’ not found in /srv/www/example.com/current/web/app/themes/sage/src/helpers.php on line 25

( ! ) Error: Class ‘Roots\Sage\Assets\JsonManifest’ not found in /srv/www/example.com/current/web/app/themes/sage/src/helpers.php on line 25

I’ve run composer install on my stage, and included /dist/ in the repo. However, during deploy I get stuck at Update WP theme paths

TASK [deploy : Update WP theme paths] ******************************************
System info:
  Ansible 2.1.1.0; Darwin
  Trellis at "Fix #639 - WP 4.6 compatibility: update WP-CLI to 0.24.1"
---------------------------------------------------

PHP Fatal error:  Uncaught Error: Class 'Roots\Sage\Assets\JsonManifest' not
found in /srv/www/mysite.com/releases/20160926232838/web/app/themes/sage/src/help
ers.php:27
Stack trace:
#0 /srv/www/mysite.com/releases/20160926232838/web/app/themes/sage/src/setup.php(
67): App\asset_path('styles/main.css')
#1 /srv/www/mysite.com/releases/20160926232838/web/wp/wp-
includes/plugin.php(524): App\{closure}('')
#2 /srv/www/mysite.com/releases/20160926232838/web/wp/wp-settings.php(395):
do_action('after_setup_the...')
#3 phar:///usr/bin/wp/php/WP_CLI/Runner.php(960):
require('/srv/www/mysite.com...')
#4 phar:///usr/bin/wp/php/commands/eval.php(29):
WP_CLI\Runner->load_wordpress()
#5 [internal function]: Eval_Command->__invoke(Array, Array)
#6 phar:///usr/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php(67):
call_user_func(Array, Array, Array)
#7 [internal function]:
WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#8 phar:///usr/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php(372):
call_user_func(Object(Closure), Array, Array)
#9 phar:// in
/srv/www/mysite.com/releases/20160926232838/web/app/themes/sage/src/helpers.php
on line 27
Fatal error: Uncaught Error: Class 'Roots\Sage\Assets\JsonManifest' not found
in /srv/www/mysite.com/releases/20160926232838/web/app/themes/sage/src/helpers.ph
p:27
Stack trace:
#0 /srv/www/mysite.com/releases/20160926232838/web/app/themes/sage/src/setup.php(
67): App\asset_path('styles/main.css')
#1 /srv/www/mysite.com/releases/20160926232838/web/wp/wp-
includes/plugin.php(524): App\{closure}('')
#2 /srv/www/mysite.com/releases/20160926232838/web/wp/wp-settings.php(395):
do_action('after_setup_the...')
#3 phar:///usr/bin/wp/php/WP_CLI/Runner.php(960):
require('/srv/www/mysite.com...')
#4 phar:///usr/bin/wp/php/commands/eval.php(29):
WP_CLI\Runner->load_wordpress()
#5 [internal function]: Eval_Command->__invoke(Array, Array)
#6 phar:///usr/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php(67):
call_user_func(Array, Array, Array)
#7 [internal function]:
WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#8 phar:///usr/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php(372):
call_user_func(Object(Closure), Array, Array)
#9 phar:// in
/srv/www/mysite.com/releases/20160926232838/web/app/themes/sage/src/helpers.php
on line 27
fatal: [52.10.153.137]: FAILED! => {"changed": true, "cmd": ["wp", "eval", "wp_clean_themes_cache(); switch_theme(get_stylesheet());"], "delta": "0:00:07.946651", "end": "2016-09-26 23:32:02.143120", "failed": true, "rc": 255, "start": "2016-09-26 23:31:54.196469", "stderr": "PHP Fatal error:  Uncaught Error: Class 'Roots\\Sage\\Assets\\JsonManifest' not found in /srv/www/mysite.com/releases/20160926232838/web/app/themes/sage/src/helpers.php:27\nStack trace:\n#0 /srv/www/mysite.com/releases/20160926232838/web/app/themes/sage/src/setup.php(67): App\\asset_path('styles/main.css')\n#1 /srv/www/mysite.com/releases/20160926232838/web/wp/wp-includes/plugin.php(524): App\\{closure}('')\n#2 /srv/www/mysite.com/releases/20160926232838/web/wp/wp-settings.php(395): do_action('after_setup_the...')\n#3 phar:///usr/bin/wp/php/WP_CLI/Runner.php(960): require('/srv/www/mysite.com...')\n#4 phar:///usr/bin/wp/php/commands/eval.php(29): WP_CLI\\Runner->load_wordpress()\n#5 [internal function]: Eval_Command->__invoke(Array, Array)\n#6 phar:///usr/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php(67): call_user_func(Array, Array, Array)\n#7 [internal function]: WP_CLI\\Dispatcher\\CommandFactory::WP_CLI\\Dispatcher\\{closure}(Array, Array)\n#8 phar:///usr/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php(372): call_user_func(Object(Closure), Array, Array)\n#9 phar:// in /srv/www/mysite.com/releases/20160926232838/web/app/themes/sage/src/helpers.php on line 27\nFatal error: Uncaught Error: Class 'Roots\\Sage\\Assets\\JsonManifest' not found in /srv/www/mysite.com/releases/20160926232838/web/app/themes/sage/src/helpers.php:27\nStack trace:\n#0 /srv/www/mysite.com/releases/20160926232838/web/app/themes/sage/src/setup.php(67): App\\asset_path('styles/main.css')\n#1 /srv/www/mysite.com/releases/20160926232838/web/wp/wp-includes/plugin.php(524): App\\{closure}('')\n#2 /srv/www/mysite.com/releases/20160926232838/web/wp/wp-settings.php(395): do_action('after_setup_the...')\n#3 phar:///usr/bin/wp/php/WP_CLI/Runner.php(960): require('/srv/www/mysite.com...')\n#4 phar:///usr/bin/wp/php/commands/eval.php(29): WP_CLI\\Runner->load_wordpress()\n#5 [internal function]: Eval_Command->__invoke(Array, Array)\n#6 phar:///usr/bin/wp/php/WP_CLI/Dispatcher/CommandFactory.php(67): call_user_func(Array, Array, Array)\n#7 [internal function]: WP_CLI\\Dispatcher\\CommandFactory::WP_CLI\\Dispatcher\\{closure}(Array, Array)\n#8 phar:///usr/bin/wp/php/WP_CLI/Dispatcher/Subcommand.php(372): call_user_func(Object(Closure), Array, Array)\n#9 phar:// in /srv/www/mysite.com/releases/20160926232838/web/app/themes/sage/src/helpers.php on line 27", "stdout": "", "stdout_lines": [], "warnings": []}

Line 27 in helpers.php is:
isset($manifest) || $manifest = new JsonManifest(get_template_directory() . '/' . Asset::$dist . '/assets.json');

dist folder is present on the server, I ssh’d in and checked just to make sure.
Also, when running composer install I struck with permission errors, so I ran it again, with sudo, and then ran sudo chown -R web:www-data vendor.

I’m on an AWS server with ubuntu as user, if that makes any difference.

Based on this and my reading, is using composer now a 100% requirement to use Sage?

Hi @jdcauley, yes - it is listed in the requirements: https://github.com/roots/sage