V8-archive: Unable to run bin/directus or reach the page

Created on 29 Jun 2018  路  8Comments  路  Source: directus/v8-archive

Describe the bug
I am deploying the Directus v7.0.0-alpha.9 via the chef deploy_revision resource.

I receive the following error when attempting to run bin/directus:

root@ip-10-10-1-184:/mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331# bin/directus
PHP Fatal error:  Uncaught Error: Class 'Directus\Console\Cli' not found in /mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331/bin/directus:8
Stack trace:
#0 {main}
  thrown in /mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331/bin/directus on line 8

I see similiar behavior in the logs when attempting to hit the site via http:

[Fri Jun 29 01:04:27.917496 2018] [:error] [pid 9036] [client 10.10.6.182:3110] PHP Fatal error:  Uncaught Error: Call to undefined function Directus\\get_api_env_from_request() in /mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331/src/web.php:16\nStack trace:\n#0 /mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331/public/index.php(3): require()\n#1 {main}\n  thrown in /mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331/src/web.php on line 16

To Reproduce
Steps to reproduce the behavior:

Deploy directus with the following chef resource:

deploy_revision 'DirectUS' do
  repo 'https://github.com/directus/api.git'

  purge_before_symlink(['logs', 'api/logs'])
  symlink_before_migrate ({
    'logs' => 'logs',
    'config.php' => 'config/api.php',
    'composer.json' => 'composer.json'
  })
  migrate true
  revision node['directus']['deploy_version']
  deploy_to '/mnt/directus'
  migration_command "composer install"
end

web_app 'DirectUS' do
  template 'web_app.conf.erb'
  server_name 'localhost'
  server_alias ['*']
  server_port 8080
  allow_override 'All'
  logdir '/var/log/handrails'
  docroot '/mnt/directus/current/public'
end

Desktop (please complete the following information):

  • OS: Ubuntu 14.04
  • Browser: Chrome
  • PHP: 7.0.30
question

Most helpful comment

All 8 comments

Hey @jdblack! I don't know if the CLI tool is done already 馃

@WellingGuzman ?

Hey @jdblack, is the composer autoloader loading the directus files?

Is the $basePath variable in bin/directus (/mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331/bin/directus) correctly pointing to your root directory?

Is there a Cli.php file in /mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331/src/core/Directus/Console directory?

https://github.com/directus/api/blob/master/bin/directus#L4-L6

It seems to be in the right place to me, but I might be wrong.

The directory structure looks like this:

drwxr-xr-x 4 www-data www-data 4096 Jun 29 00:46 .
drwxr-xr-x 3 root     root     4096 Jun 29 00:45 ..
lrwxrwxrwx 1 root     root       63 Jun 29 00:46 current -> /mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331
drwxr-xr-x 3 root     root     4096 Jun 29 00:46 releases
drwxr-xr-x 6 www-data www-data 4096 Jun 29 16:19 shared

If I cd into /mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331/public, I see that index.php includes ../src/web.php. web.php is loadable, which we can confirm from the stack trace.

web.php starts off with:

$basePath =  realpath(__DIR__ . '/../');
$configPath = $basePath . '/config';
$configFilePath = $configPath . '/api.php';

require $basePath . '/vendor/autoload.php';

// Creates a simple endpoint to test the server rewriting
// If the server responds "pong" it means the rewriting works
if (!file_exists($configFilePath)) {
    return \Directus\create_default_app($basePath);
}

// Get Environment name
$env = \Directus\get_api_env_from_request();

Adding a few prints to web.php shows that basePath, configPath and configFilePath are being defined as:
/mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331
/mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331/config
/mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331/config/api.php

It seems that get_api_env_from_request is defined in src/helpers/all.php. How does web.php normally include this? I see where it includes the vendored stuff (which seems to work), but I don't see how the rest of the tree gets required?

Does indeed exist

/mnt/directus/releases/af42562810888714009dc2f0d4395bc354c17331/src/core/Directus/Console/Cli.php

Is there a community slack or irc channel tout there that I could reach out to as well?

E_USER. I was using the v2.0.0-v.9 branch, which lacks a composer.json. Using the master branch and the provided compser.json works as expected!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ybelenko picture ybelenko  路  31Comments

wellingguzman picture wellingguzman  路  25Comments

pikzelz picture pikzelz  路  32Comments

rijkvanzanten picture rijkvanzanten  路  55Comments

shartley76 picture shartley76  路  40Comments