CodeIgniter Forums
No such file or directory when running seeder from CLI - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: No such file or directory when running seeder from CLI (/showthread.php?tid=75161)



No such file or directory when running seeder from CLI - includebeer - 01-02-2020

I'm trying to load some test data with a seeder file and it gives the error "No such file or directory". It looks like it's when it tries to connect to  MySQL but I can't find what file it's looking for. The application works fine in the browser, so the database config is good. I looked at the code in MySQLi/Connection.php and I can't find where this exception comes from.

Any idea what file it's looking for and can't find?


Code:
$ php spark db:seed BlogSeeder


CodeIgniter CLI Tool - Version 4.0.0-rc.3 - Server-Time: 2020-01-02 12:23:01pm


No such file or directory
/Applications/MAMP/htdocs/xxxxxx/system/Database/MySQLi/Connection.php - 225



RE: No such file or directory when running seeder from CLI - MGatner - 01-07-2020

That's the try...catch block for making the actual connection with MySQLi. Is it possible you don't have MySQLi extensions available? Or the database itself? Also try removing and re-installing the framework portion (vendor, or system) in case of permissions issues.


RE: No such file or directory when running seeder from CLI - includebeer - 01-07-2020

All those things are already working when I test the app in the browser. I can create and edit new blog post. So I can confirm MySQLi is available, the database is up and running, the credentials are good. I just can't understand why from the command line it give this error. I will search the string 'No such file or directory' in all CI files to try and find where it's coming from.


RE: No such file or directory when running seeder from CLI - MGatner - 01-11-2020

Your CLI version of PHP doesn’t necessarily have the same extensions installed. Run php -m and make sure MySQL extension is enabled.


RE: No such file or directory when running seeder from CLI - includebeer - 01-12-2020

(01-11-2020, 06:05 AM)MGatner Wrote: Your CLI version of PHP doesn’t necessarily have the same extensions installed. Run php -m and make sure MySQL extension is enabled.

Ha! I didn't think about that.
The CLI version was not the same version of PHP. Now it work when I call the same version. 
Thank you!
Code:
/Applications/MAMP/bin/php/php7.3.8/bin/php spark db:seed BlogSeeder



RE: No such file or directory when running seeder from CLI - Martin_Salas - 05-14-2020

(01-12-2020, 08:08 AM)includebeer Wrote:
(01-11-2020, 06:05 AM)MGatner Wrote: Your CLI version of PHP doesn’t necessarily have the same extensions installed. Run php -m and make sure MySQL extension is enabled.

Ha! I didn't think about that.
The CLI version was not the same version of PHP. Now it work when I call the same version. 
Thank you!
Code:
/Applications/MAMP/bin/php/php7.3.8/bin/php spark db:seed BlogSeeder

in my case I have UBUNTU and execute: 
Code:
sudo apt-get install php7.3-sqlite3