# Cake bake all returns error (missing $default in database, but it is in the file)

**URL:** <https://discourse.cakephp.org/t/cake-bake-all-returns-error-missing-default-in-database-but-it-is-in-the-file/6766>\
**Category:** Need Help\
**Created:** [October 15, 2019, 2:43pm UTC](https://discourse.cakephp.org/t/cake-bake-all-returns-error-missing-default-in-database-but-it-is-in-the-file/6766 "2019-10-15T14:43:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![misteryx96](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@misteryx96](https://discourse.cakephp.org/u/misteryx96)\
**Post date:** [October 15, 2019, 2:43pm UTC](https://discourse.cakephp.org/t/cake-bake-all-returns-error-missing-default-in-database-but-it-is-in-the-file/6766/1 "2019-10-15T14:43:42Z")

</div>

I am trying to bake all with cake bake all, but it returns all sorts of errors. It says that default in database.php cannot be found, but in reality it is present in the file, also, few days ago I baked few models etc and it worked fine. Here is the output:

C:\wamp64\www\WarehouseManagementApp\app\Console\>cake bake all

Warning Error: Use of undefined constant TESTS - assumed ‘TESTS’ (this will throw an Error in a future version of PHP) in [C:\wamp64\www\WarehouseManagementApp\lib\Cake\Console\TaskCollection.php, line 94]

## Welcome to CakePHP v2.10.19 Console

## App : Console Path: C:\wamp64\www\WarehouseManagementApp\app\Console\

## Bake All

Warning Error: include\_once(C:\wamp64\www\WarehouseManagementApp\app\Console\Config\database.php): failed to open stream: No such file or directory in [C:\wamp64\www\WarehouseManagementApp\lib\Cake\Model\ConnectionManager.php, line 67]

Warning Error: include\_once(): Failed opening ‘C:\wamp64\www\WarehouseManagementApp\app\Console\Config\database.php’ for inclusion (include\_path=‘C:\wamp64\www\WarehouseManagementApp\lib;.;C:\php\pear’) in [C:\wamp64\www\WarehouseManagementApp\lib\Cake\Model\ConnectionManager.php, line 67]

Error: The datasource configuration “default” was not found in database.php  
#0 C:\wamp64\www\WarehouseManagementApp\lib\Cake\Model\ConnectionManager.php(91): ConnectionManager::\_getConnectionObject(‘default’)  
#1 C:\wamp64\www\WarehouseManagementApp\lib\Cake\Console\Command\Task\ModelTask.php(956): ConnectionManager::getDataSource(‘default’)  
#2 C:\wamp64\www\WarehouseManagementApp\lib\Cake\Console\Command\Task\ModelTask.php(893): ModelTask-\>getAllTables(‘default’)  
#3 C:\wamp64\www\WarehouseManagementApp\lib\Cake\Console\Command\Task\ModelTask.php(983): ModelTask-\>listAll(‘default’)  
#4 C:\wamp64\www\WarehouseManagementApp\lib\Cake\Console\Command\BakeShell.php(150): ModelTask-\>getName(‘default’)  
#5 C:\wamp64\www\WarehouseManagementApp\lib\Cake\Console\Shell.php(459): BakeShell-\>all()  
#6 C:\wamp64\www\WarehouseManagementApp\lib\Cake\Console\ShellDispatcher.php(222): Shell-\>runCommand(‘all’, Array)  
#7 C:\wamp64\www\WarehouseManagementApp\lib\Cake\Console\ShellDispatcher.php(66): ShellDispatcher-\>dispatch()  
#8 C:\wamp64\www\WarehouseManagementApp\app\Console\cake.php(47): ShellDispatcher::run(Array)  
#9 {main}

Also, here is my database.php file:

```
class DATABASE_CONFIG {

public $default = array(
	'datasource' => 'Database/Mysql',
	'persistent' => false,
	'host' => 'localhost',
	'login' => 'root',
	'password' => '',
	'database' => 'modules',
	'prefix' => '',

```

// ‘encoding’ =\> ‘utf8’,  
);

```
public $test = array(
	'datasource' => 'Database/Mysql',
	'persistent' => false,
	'host' => 'localhost',
	'login' => 'user',
	'password' => 'password',
	'database' => 'test_database_name',
	'prefix' => '',
	//'encoding' => 'utf8',
);

```

}

---

<div class="post-metadata">

**Author:** ![Graziel](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Graziel](https://discourse.cakephp.org/u/Graziel)\
**Post date:** [October 15, 2019, 2:51pm UTC](https://discourse.cakephp.org/t/cake-bake-all-returns-error-missing-default-in-database-but-it-is-in-the-file/6766/2 "2019-10-15T14:51:31Z")

</div>

double check if you didnt make any typo cause on top you have

> [@misteryx96](#):
>
> Warning Error: include\_once(C:\wamp64\www\WarehouseManagementApp\app\Console\Config\database.php): failed to open stream: No such file or directory in [C:\wamp64\www\WarehouseManagementApp\lib\Cake\Model\ConnectionManager.php, line 67]

on side note why using old version when new is alive for so long now?

---

<div class="post-metadata">

**Author:** ![misteryx96](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@misteryx96](https://discourse.cakephp.org/u/misteryx96)\
**Post date:** [October 15, 2019, 2:58pm UTC](https://discourse.cakephp.org/t/cake-bake-all-returns-error-missing-default-in-database-but-it-is-in-the-file/6766/3 "2019-10-15T14:58:33Z")

</div>

No typos. I double checked.

Apparently, my mentor demands I use 2.x version, why, I am not really sure.

---

<div class="post-metadata">

**Author:** ![Graziel](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Graziel](https://discourse.cakephp.org/u/Graziel)\
**Post date:** [October 15, 2019, 3:33pm UTC](https://discourse.cakephp.org/t/cake-bake-all-returns-error-missing-default-in-database-but-it-is-in-the-file/6766/4 "2019-10-15T15:33:13Z")

</div>

just to be 100% sure you renamed `database.php.default` to `database.php`? checking cause windows can hide your extension and give you false filename of `database.php` in file explorer

---

<div class="post-metadata">

**Author:** ![misteryx96](https://avatars.discourse-cdn.com/v4/letter/m/3d9bf3/32.png) [@misteryx96](https://discourse.cakephp.org/u/misteryx96)\
**Post date:** [October 16, 2019, 7:49am UTC](https://discourse.cakephp.org/t/cake-bake-all-returns-error-missing-default-in-database-but-it-is-in-the-file/6766/5 "2019-10-16T07:49:31Z")

</div>

Problem is that I need to run command from the app folder, not from the console folder. When I run it from the console it just appends the config/database to a running directory, which of course is the issue.
