"Error: [MissingTableException] Table users for model User..." right after installation

Checklist
[x] I have read intro post: hxxps://community.passbolt.com/t/about-the-installation-issues-category/12 [link removed since you have a minor sane 2-links-per-post limit]
[y] I have read the tutorials, help and searched for similar issues
[z] I provide relevant information about my server (component names and versions, etc.)
[a] I provide a copy of my logs and healthcheck
[b] I describe the steps I have taken to trouble shoot the problem
[c] I describe the steps on how to reproduce the issue

I’m coming from https://github.com/passbolt/passbolt_api/issues/218 with an almost unchanged problem. Changes since that report: I re-ran app/Console/cake install without the recommended --no-admin (see https://www.passbolt.com/help/tech/install#toc_install), which seemed to work, I now can see a new user entry in passbolt.users.

The healthcheck passes except for

 Database

 [FAIL] No table found
  [HELP] Run the install script to install the database tables
  [HELP] sudo su -s /bin/bash -c "/var/www/passbolt/app/Console/cake install" www-data
 [FAIL] No default content found
  [HELP] Run the install script to set the default content such as roles and permission types
  [HELP] sudo su -s /bin/bash -c "/var/www/passbolt/app/Console/cake install" www-data

while the suggestions are misleading in my eyes because the installation already finished (with no visible errors). Also, I can login and execute queries with the copy-pasted data from app/Config/database.php.

The frontend returns 500 for any action, app/tmp/logs/error.log shows

2018-01-15 22:58:36 Error: [MissingTableException] Table users for model User was not found in datasource default.
Exception Attributes: array (
  'table' => 'users',
  'class' => 'User',
  'ds' => 'default',
)
Request URL: /auth/login
Stack Trace:
#0 /var/www/passbolt/lib/Cake/Model/Model.php(3667): Model->setSource('users')
#1 /var/www/passbolt/lib/Cake/Model/Model.php(3038): Model->getDataSource()
#2 /var/www/passbolt/lib/Cake/Model/Model.php(3010): Model->_readDataSource('first', Array)
#3 /var/www/passbolt/app/Model/User.php(402): Model->find('first', Array)
#4 /var/www/passbolt/app/Model/User.php(360): User::setActive('anonymous@passb...')
#5 /var/www/passbolt/app/Model/ControllerLog.php(176): User::get()
#6 /var/www/passbolt/app/Controller/AuthController.php(45): ControllerLog::write('error', Object(CakeRequest), 'login_failure', '')
#7 [internal function]: AuthController->login()
#8 /var/www/passbolt/lib/Cake/Controller/Controller.php(491): ReflectionMethod->invokeArgs(Object(AuthController), Array)
#9 /var/www/passbolt/lib/Cake/Routing/Dispatcher.php(193): Controller->invokeAction(Object(CakeRequest))
#10 /var/www/passbolt/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke(Object(AuthController), Object(CakeRequest))
#11 /var/www/passbolt/app/webroot/index.php(110): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#12 {main}

which seems to be the same issue for all three of a) register user (github/218) b) healthcheck “table/data not found” c) frontend /auth/login doesn’t find its user table.

How do you fix this?

Hi @dafeer, can you show us the database config you use? Also which version of mysql are you using? Which operating system do you use and package did you install (maybe it’s an issue with the pdo drivers).

Hi, thanks for your help. All the requested information can be found in the linked github bug (that’s me!).

Again, for the record:

# lsb_release -d
Description:	Debian GNU/Linux 9.3 (stretch)
# dpkg -l *mysql* *mariadb* | awk '/^ii/{print($2,$3)}' | column -t
mariadb-client-10.1       10.1.26-0+deb9u1
mariadb-client-core-10.1  10.1.26-0+deb9u1
mariadb-common            10.1.26-0+deb9u1
mariadb-server            10.1.26-0+deb9u1
mariadb-server-10.1       10.1.26-0+deb9u1
mariadb-server-core-10.1  10.1.26-0+deb9u1
mysql-common              5.8+1.0.2
php7.0-mysql              7.0.27-0+deb9u1

I did not alter any mysql configuration since there was no hint of recommendations. So this runs with the debian defaults, which can be found on https://sources.debian.org/src/mariadb-10.1/10.1.26-0+deb9u1/debian/additions/ (for this very version).

In the meantime, I have even tested the mysql connection using both mysqli and PDO, since the passbolt code is that much convoluted that I couldn’t even figure out which database mode is used. Here is my test code:

# cat /var/www/passbolt/app/webroot/mysqltest.php
<?php
echo "<pre>{";
include '../Config/database.php';
$config = new DATABASE_CONFIG();

$conn_mysqli = new mysqli($config->default['host'], $config->default['login'], $config->default['password'], $config->default['database']);
var_dump($conn_mysqli->query('select count(1) from roles;')->fetch_assoc());

$conn_pdo = new PDO('mysql:host='.$config->default['host'].';dbname='.$config->default['database'], $config->default['login'], $config->default['password']);
$statement = $conn_pdo->prepare('select count(1) from roles;');
$statement->execute();
var_dump($statement->fetchAll(\PDO::FETCH_ASSOC));

echo "}</pre>";

Output from browser:

{array(1) {
  ["count(1)"]=>
  string(1) "4"
}
array(1) {
  [0]=>
  array(1) {
    ["count(1)"]=>
    string(1) "4"
  }
}
}

Well, I cannot see an error here. Thus I assume that the mysql config is correct – or that the passbolt code is indeed buggy or uses another method that my simple test above didn’t cover.

I just setup a Debian 9.3 and tried to reproduce your issue, in vain.
It looks like an alien issue, what let me think that it could be related to the CakePHP cache.
Can you try to flush manually the cache by removing the files in the app/tmp/cache folder and its subfolders.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.

Hi @dafeer

It is a weird issue indeed. To understand what’s going on in your db, ie what is there and not there, could you execute the following SQL command and let us know the output:

SELECT table_schema, table_name, column_name, character_set_name, collation_name 
FROM information_schema.columns WHERE table_schema='passbolt' 
ORDER BY table_schema, table_name,ordinal_position;

Alternatively, you could try to switch to passbolt v2.0.0-rc1 and see if the problem is still there.

Keep us posted.

Hi all,

I didn’t touch the system for a few days, so sorry for the delay. The suggestion by @cedric nailed it, after running find /var/www/passbolt/app/tmp/cache/ -type f -delete the interface did work properly and I do not see any errors logged. Thank you!

@kevin, sorry to probably have wasted your time, but thank you also. The query output doesn’t look strange in any way to me. Which makes sense, since the cache flush seems to have resolved my problem.

The Database FAILs from the healthcheck output are also gone, btw.

Alright. no issues, we were wondering what it could be. Good to know that this behavior can be triggered due to a cache issue.
Cheers,

Hello @kevin,

Actually I’m getting same error and this is a issue i guess. Here is my db query output. Could you check please?

MariaDB [(none)]> SELECT table_schema, table_name, column_name, character_set_name, collation_name 
    -> FROM information_schema.columns WHERE table_schema='passbolt' 
    -> ORDER BY table_schema, table_name,ordinal_position;
+--------------+-----------------------------+-----------------+--------------------+-------------------+
| table_schema | table_name                  | column_name     | character_set_name | collation_name    |
+--------------+-----------------------------+-----------------+--------------------+-------------------+
| passbolt     | authentication_tokens       | id              | utf8               | utf8_unicode_ci   |
| passbolt     | authentication_tokens       | token           | utf8               | utf8_unicode_ci   |
| passbolt     | authentication_tokens       | user_id         | utf8               | utf8_unicode_ci   |
| passbolt     | authentication_tokens       | active          | NULL               | NULL              |
| passbolt     | authentication_tokens       | created         | NULL               | NULL              |
| passbolt     | authentication_tokens       | modified        | NULL               | NULL              |
| passbolt     | authentication_tokens       | created_by      | utf8               | utf8_unicode_ci   |
| passbolt     | authentication_tokens       | modified_by     | utf8               | utf8_unicode_ci   |
| passbolt     | cake_sessions               | id              | utf8               | utf8_unicode_ci   |
| passbolt     | cake_sessions               | data            | utf8               | utf8_unicode_ci   |
| passbolt     | cake_sessions               | expires         | NULL               | NULL              |
| passbolt     | comments                    | id              | utf8               | utf8_unicode_ci   |
| passbolt     | comments                    | parent_id       | utf8               | utf8_unicode_ci   |
| passbolt     | comments                    | foreign_id      | utf8               | utf8_unicode_ci   |
| passbolt     | comments                    | foreign_model   | utf8               | utf8_unicode_ci   |
| passbolt     | comments                    | content         | utf8               | utf8_unicode_ci   |
| passbolt     | comments                    | created         | NULL               | NULL              |
| passbolt     | comments                    | modified        | NULL               | NULL              |
| passbolt     | comments                    | created_by      | utf8               | utf8_unicode_ci   |
| passbolt     | comments                    | modified_by     | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | id              | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | user_id         | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | role_id         | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | level           | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | method          | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | controller      | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | action          | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | user_agent_id   | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | ip              | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | request_data    | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | message         | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | scope           | utf8               | utf8_unicode_ci   |
| passbolt     | controller_logs             | created         | NULL               | NULL              |
| passbolt     | email_queue                 | id              | ascii              | ascii_general_ci  |
| passbolt     | email_queue                 | to              | utf8               | utf8_general_ci   |
| passbolt     | email_queue                 | from_name       | utf8               | utf8_general_ci   |
| passbolt     | email_queue                 | from_email      | utf8               | utf8_general_ci   |
| passbolt     | email_queue                 | subject         | utf8               | utf8_general_ci   |
| passbolt     | email_queue                 | config          | utf8               | utf8_general_ci   |
| passbolt     | email_queue                 | template        | utf8               | utf8_general_ci   |
| passbolt     | email_queue                 | layout          | utf8               | utf8_general_ci   |
| passbolt     | email_queue                 | format          | utf8               | utf8_general_ci   |
| passbolt     | email_queue                 | template_vars   | utf8               | utf8_general_ci   |
| passbolt     | email_queue                 | headers         | utf8               | utf8_general_ci   |
| passbolt     | email_queue                 | sent            | NULL               | NULL              |
| passbolt     | email_queue                 | locked          | NULL               | NULL              |
| passbolt     | email_queue                 | send_tries      | NULL               | NULL              |
| passbolt     | email_queue                 | send_at         | NULL               | NULL              |
| passbolt     | email_queue                 | created         | NULL               | NULL              |
| passbolt     | email_queue                 | modified        | NULL               | NULL              |
| passbolt     | favorites                   | id              | utf8               | utf8_unicode_ci   |
| passbolt     | favorites                   | user_id         | utf8               | utf8_unicode_ci   |
| passbolt     | favorites                   | foreign_id      | utf8               | utf8_unicode_ci   |
| passbolt     | favorites                   | foreign_model   | utf8               | utf8_unicode_ci   |
| passbolt     | favorites                   | created         | NULL               | NULL              |
| passbolt     | file_storage                | id              | latin1             | latin1_swedish_ci |
| passbolt     | file_storage                | user_id         | latin1             | latin1_swedish_ci |
| passbolt     | file_storage                | foreign_key     | latin1             | latin1_swedish_ci |
| passbolt     | file_storage                | model           | latin1             | latin1_swedish_ci |
| passbolt     | file_storage                | filename        | latin1             | latin1_swedish_ci |
| passbolt     | file_storage                | filesize        | NULL               | NULL              |
| passbolt     | file_storage                | mime_type       | latin1             | latin1_swedish_ci |
| passbolt     | file_storage                | extension       | latin1             | latin1_swedish_ci |
| passbolt     | file_storage                | hash            | latin1             | latin1_swedish_ci |
| passbolt     | file_storage                | path            | latin1             | latin1_swedish_ci |
| passbolt     | file_storage                | adapter         | latin1             | latin1_swedish_ci |
| passbolt     | file_storage                | created         | NULL               | NULL              |
| passbolt     | file_storage                | modified        | NULL               | NULL              |
| passbolt     | gpgkeys                     | id              | utf8               | utf8_unicode_ci   |
| passbolt     | gpgkeys                     | user_id         | utf8               | utf8_unicode_ci   |
| passbolt     | gpgkeys                     | key             | utf8               | utf8_unicode_ci   |
| passbolt     | gpgkeys                     | bits            | NULL               | NULL              |
| passbolt     | gpgkeys                     | uid             | utf8               | utf8_unicode_ci   |
| passbolt     | gpgkeys                     | key_id          | utf8               | utf8_unicode_ci   |
| passbolt     | gpgkeys                     | fingerprint     | utf8               | utf8_unicode_ci   |
| passbolt     | gpgkeys                     | type            | utf8               | utf8_unicode_ci   |
| passbolt     | gpgkeys                     | expires         | NULL               | NULL              |
| passbolt     | gpgkeys                     | key_created     | NULL               | NULL              |
| passbolt     | gpgkeys                     | deleted         | NULL               | NULL              |
| passbolt     | gpgkeys                     | created         | NULL               | NULL              |
| passbolt     | gpgkeys                     | modified        | NULL               | NULL              |
| passbolt     | gpgkeys                     | created_by      | utf8               | utf8_unicode_ci   |
| passbolt     | gpgkeys                     | modified_by     | utf8               | utf8_unicode_ci   |
| passbolt     | groups                      | id              | utf8               | utf8_unicode_ci   |
| passbolt     | groups                      | name            | utf8               | utf8_unicode_ci   |
| passbolt     | groups                      | deleted         | NULL               | NULL              |
| passbolt     | groups                      | created         | NULL               | NULL              |
| passbolt     | groups                      | modified        | NULL               | NULL              |
| passbolt     | groups                      | created_by      | utf8               | utf8_unicode_ci   |
| passbolt     | groups                      | modified_by     | utf8               | utf8_unicode_ci   |
| passbolt     | groups_users                | id              | utf8               | utf8_unicode_ci   |
| passbolt     | groups_users                | group_id        | utf8               | utf8_unicode_ci   |
| passbolt     | groups_users                | user_id         | utf8               | utf8_unicode_ci   |
| passbolt     | groups_users                | is_admin        | NULL               | NULL              |
| passbolt     | groups_users                | created         | NULL               | NULL              |
| passbolt     | groups_users                | created_by      | utf8               | utf8_unicode_ci   |
| passbolt     | permissions                 | id              | utf8               | utf8_unicode_ci   |
| passbolt     | permissions                 | aco             | utf8               | utf8_unicode_ci   |
| passbolt     | permissions                 | aco_foreign_key | utf8               | utf8_unicode_ci   |
| passbolt     | permissions                 | aro             | utf8               | utf8_unicode_ci   |
| passbolt     | permissions                 | aro_foreign_key | utf8               | utf8_unicode_ci   |
| passbolt     | permissions                 | type            | NULL               | NULL              |
| passbolt     | permissions                 | created         | NULL               | NULL              |
| passbolt     | permissions                 | modified        | NULL               | NULL              |
| passbolt     | permissions                 | created_by      | utf8               | utf8_unicode_ci   |
| passbolt     | permissions                 | modified_by     | utf8               | utf8_unicode_ci   |
| passbolt     | permissions_types           | id              | utf8               | utf8_unicode_ci   |
| passbolt     | permissions_types           | serial          | utf8               | utf8_unicode_ci   |
| passbolt     | permissions_types           | name            | utf8               | utf8_unicode_ci   |
| passbolt     | permissions_types           | description     | utf8               | utf8_unicode_ci   |
| passbolt     | permissions_types           | active          | NULL               | NULL              |
| passbolt     | profiles                    | id              | utf8               | utf8_unicode_ci   |
| passbolt     | profiles                    | user_id         | utf8               | utf8_unicode_ci   |
| passbolt     | profiles                    | gender          | utf8               | utf8_unicode_ci   |
| passbolt     | profiles                    | date_of_birth   | NULL               | NULL              |
| passbolt     | profiles                    | title           | utf8               | utf8_unicode_ci   |
| passbolt     | profiles                    | first_name      | utf8               | utf8_unicode_ci   |
| passbolt     | profiles                    | last_name       | utf8               | utf8_unicode_ci   |
| passbolt     | profiles                    | timezone        | utf8               | utf8_unicode_ci   |
| passbolt     | profiles                    | locale          | utf8               | utf8_unicode_ci   |
| passbolt     | profiles                    | created         | NULL               | NULL              |
| passbolt     | profiles                    | modified        | NULL               | NULL              |
| passbolt     | resources                   | id              | utf8               | utf8_unicode_ci   |
| passbolt     | resources                   | name            | utf8               | utf8_unicode_ci   |
| passbolt     | resources                   | username        | utf8               | utf8_unicode_ci   |
| passbolt     | resources                   | expiry_date     | NULL               | NULL              |
| passbolt     | resources                   | uri             | utf8               | utf8_unicode_ci   |
| passbolt     | resources                   | description     | utf8               | utf8_unicode_ci   |
| passbolt     | resources                   | deleted         | NULL               | NULL              |
| passbolt     | resources                   | created         | NULL               | NULL              |
| passbolt     | resources                   | modified        | NULL               | NULL              |
| passbolt     | resources                   | created_by      | utf8               | utf8_unicode_ci   |
| passbolt     | resources                   | modified_by     | utf8               | utf8_unicode_ci   |
| passbolt     | roles                       | id              | utf8               | utf8_unicode_ci   |
| passbolt     | roles                       | name            | utf8               | utf8_unicode_ci   |
| passbolt     | roles                       | description     | utf8               | utf8_unicode_ci   |
| passbolt     | roles                       | created         | NULL               | NULL              |
| passbolt     | roles                       | modified        | NULL               | NULL              |
| passbolt     | schema_migrations           | id              | NULL               | NULL              |
| passbolt     | schema_migrations           | class           | utf8               | utf8_unicode_ci   |
| passbolt     | schema_migrations           | type            | utf8               | utf8_unicode_ci   |
| passbolt     | schema_migrations           | created         | NULL               | NULL              |
| passbolt     | secrets                     | id              | utf8               | utf8_unicode_ci   |
| passbolt     | secrets                     | user_id         | utf8               | utf8_unicode_ci   |
| passbolt     | secrets                     | resource_id     | utf8               | utf8_unicode_ci   |
| passbolt     | secrets                     | data            | utf8               | utf8_unicode_ci   |
| passbolt     | secrets                     | created         | NULL               | NULL              |
| passbolt     | secrets                     | modified        | NULL               | NULL              |
| passbolt     | secrets                     | created_by      | utf8               | utf8_unicode_ci   |
| passbolt     | secrets                     | modified_by     | utf8               | utf8_unicode_ci   |
| passbolt     | users                       | id              | utf8               | utf8_unicode_ci   |
| passbolt     | users                       | role_id         | utf8               | utf8_unicode_ci   |
| passbolt     | users                       | username        | utf8               | utf8_unicode_ci   |
| passbolt     | users                       | active          | NULL               | NULL              |
| passbolt     | users                       | deleted         | NULL               | NULL              |
| passbolt     | users                       | created         | NULL               | NULL              |
| passbolt     | users                       | modified        | NULL               | NULL              |
| passbolt     | users                       | created_by      | utf8               | utf8_unicode_ci   |
| passbolt     | users                       | modified_by     | utf8               | utf8_unicode_ci   |
| passbolt     | users_resources_permissions | user_id         | utf8               | utf8_unicode_ci   |
| passbolt     | users_resources_permissions | resource_id     | utf8               | utf8_unicode_ci   |
| passbolt     | users_resources_permissions | permission_id   | utf8               | utf8_unicode_ci   |
| passbolt     | users_resources_permissions | permission_type | NULL               | NULL              |
| passbolt     | user_agents                 | id              | utf8               | utf8_unicode_ci   |
| passbolt     | user_agents                 | name            | utf8               | utf8_unicode_ci   |
+--------------+-----------------------------+-----------------+--------------------+-------------------+
165 rows in set (0.02 sec) 

Greetings!


Here is the solution, I found it after I asked to @kevin lol.

Please delete all filer under app/tmp/cache and app/tmp/cache/models and /app/tmp/cache/persistent and please refresh your other tab in your browser or open a new tab and try to visit your passbolt installation url.

Voila!
Ed

1 Like