Generated path to assets incorrect after running wp acorn optimize

When deploying a Sage based theme to a remote development site, I’m getting the following PHP fatal error after running wp acorn optimize on the remote host:

 PHP Fatal error:  Uncaught Roots\Acorn\Assets\Exceptions\ManifestNotFoundException: The asset manifest [/home/redacted/sites/redacted.com/www/wp-content/themes/redacted/public/manifest.json] cannot be found. in /www/wp-content/themes/redacted/vendor/roots/acorn/src/Roots/Acorn/Assets/Manager.php:122
Stack trace:
#0 /www/wp-content/themes/redacted/vendor/roots/acorn/src/Roots/Acorn/Assets/Manager.php(94): Roots\Acorn\Assets\Manager->getJsonManifest()
#1 /www/wp-content/themes/redacted/vendor/roots/acorn/src/Roots/Acorn/Assets/Manager.php(71): Roots\Acorn\Assets\Manager->resolve()
#2 /www/wp-content/themes/redacted/vendor/roots/acorn/src/Roots/Acorn/Assets/AssetsServiceProvider.php(24): Roots\Acorn\Assets\Manager->manifest()
#3 /www/wp-content/themes/redacted/vendor/illuminate/container/Container.php(908): Roots\Acorn\Assets\AssetsServiceProvider->Roots\Acorn\Assets\{closure}()
#4 /www/wp-content/themes/redacted/vendor/illuminate/container/Container.php(795): Illuminate\Container\Container->build()
#5 /www/wp-content/themes/redacted/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(957): Illuminate\Container\Container->resolve()
#6 /www/wp-content/themes/redacted/vendor/illuminate/container/Container.php(731): Illuminate\Foundation\Application->resolve()
#7 /www/wp-content/themes/redacted/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(942): Illuminate\Container\Container->make()
#8 /www/wp-content/themes/redacted/vendor/roots/acorn/src/Illuminate/Foundation/helpers.php(120): Illuminate\Foundation\Application->make()
#9 /www/wp-content/themes/redacted/vendor/roots/acorn/src/Roots/helpers.php(29): app()
#10 /www/wp-content/themes/redacted/app/setup.php(27): Roots\bundle()
#11 /www/wp-includes/class-wp-hook.php(324): App\{closure}()
#12 /www/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#13 /www/wp-includes/plugin.php(517): WP_Hook->do_action()
#14 /www/wp-includes/class-wp-customize-widgets.php(897): do_action()
#15 /www/wp-includes/class-wp-hook.php(324): WP_Customize_Widgets->enqueue_scripts()
#16 /www/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
#17 /www/wp-includes/plugin.php(517): WP_Hook->do_action()
#18 /www/wp-admin/customize.php(127): do_action()
#19 {main}
  thrown in /www/wp-content/themes/redacted/vendor/roots/acorn/src/Roots/Acorn/Assets/Manager.php on line 122

It seems that the generated config.php file in sites/redacted/www/wp-content/cache/acorn/framework/cache/config.php have absolute URLs:

'assets' =>
  array (
    'default' => 'theme',
    'manifests' =>
    array (
      'theme' =>
      array (
        'path' => '/home/redacted/sites/redacted.com/www/wp-content/themes/redacted/public',
        'url' => 'https://redacted.com/wp-content/themes/redacted/public',
        'assets' => '/home/redacted/sites/redacted.com/www/wp-content/themes/redacted/public/manifest.json',
        'bundles' => '/home/redacted/sites/redacted.com/www/wp-content/themes/redacted/public/entrypoints.json',
      ),
    ),
  ),

However this causes a PHP fatal error in my hosting environment since the paths are different inside of the PHP container.

Looking at the docs it seems like I can define a custom ACORN_BASEPATH but not sure if this is correct, it doesn’t seem to work:

if ( ! defined( 'ACORN_BASEPATH' ) ) {
  define( 'ACORN_BASEPATH', __DIR__ . '/wp-content/cache' );
}

My current composer.json file:

{
  "name": "roots/sage",
  "type": "wordpress-theme",
  "license": "MIT",
  "description": "WordPress starter theme with a modern development workflow",
  "homepage": "https://roots.io/sage/",
  "authors": [
    {
      "name": "Ben Word",
      "email": "ben@benword.com",
      "homepage": "https://github.com/retlehs"
    },
    {
      "name": "Scott Walkinshaw",
      "email": "scott.walkinshaw@gmail.com",
      "homepage": "https://github.com/swalkinshaw"
    },
    {
      "name": "QWp6t",
      "email": "hi@qwp6t.me",
      "homepage": "https://github.com/qwp6t"
    },
    {
      "name": "Brandon Nifong",
      "email": "brandon@tendency.me",
      "homepage": "https://github.com/log1x"
    }
  ],
  "keywords": [
    "wordpress"
  ],
  "support": {
    "issues": "https://github.com/roots/sage/issues",
    "forum": "https://discourse.roots.io/"
  },
  "autoload": {
    "psr-4": {
      "App\\": "app/"
    }
  },
  "require": {
    "php": ">=8.1",
    "log1x/navi": "^3.1",
    "log1x/sage-directives": "^2.0",
    "log1x/sage-svg": "^2.0",
    "roots/acorn": "^4.3",
    "supermundano/sage-the-events-calendar": "^1.0"
  },
  "require-dev": {
    "laravel/pint": "^1.13"
  },
  "suggest": {
    "log1x/sage-directives": "A collection of useful Blade directives for WordPress and Sage (^1.0)."
  },
  "config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "extra": {
    "acorn": {
      "providers": [
        "App\\Providers\\ThemeServiceProvider"
      ]
    }
  },
  "scripts": {
    "post-autoload-dump": [
      "Roots\\Acorn\\ComposerScripts::postAutoloadDump"
    ]
  }
}

Any insights that you could provide would be appreciated!

However this causes a PHP fatal error in my hosting environment since the paths are different inside of the PHP container.

Are you not running wp acorn:optimize on your hosting environment/container?

Yeah running wp acorn:optimize in the hosting environment. Running the command generates the config file and paths that cause the error.