adam.harvie's avatar

Error running queue outside of project root directory

Hi all,

I've got a Lumen project and I'm trying to run the queue via supervisord, but I'm getting an error in the log files:

Could not open input file: artisan

I've checked that the artisan file is executable.

I have the same error if I try to run the queue from anywhere but the Laravel root directory: This works:

[me@server project_dir]$ php artisan queue:listen

This gives me the 'Could not open' error:

[me@server ~]$ php /home/me/project_dir/artisan queue:listen

Some commands work from outside the project directory, others don't. Something is obviously not being initialized properly, because I've found any calls to config() are returning null. It's hard to debug though because Log::debug() calls aren't working either (no error, just no log output).

The env variables appear to be loading. If I add an echo to the artisan file :

$app = require __DIR__.'/bootstrap/app.php';
echo getenv('QUEUE_DRIVER');

I get database, which is what I have in my .env file.

Anybody have an idea where to look to solve this?

Thanks.

0 likes
4 replies
michaeldim's avatar

From within your laravel project directory could run this command from your terminal and make sure it matches the path you already have:

[me@server project_dir]$ pwd

Could you also run this command to see where your php executable is located and try and run the artisan command from that:

[me@server ~]$ which php

Common location might be '/usr/bin/php'. You could then try '/usr/bin/php path/to/your_laravel_root/artisan queue:listen'

adam.harvie's avatar

Hi @michaeldim ,

Thanks. I've tried using absolute paths for both PHP and the artisan file, and I have double-checked using pwd and which php that my paths are correct:

[me@server ~]$ /usr/local/bin/php /home/me/project_root/artisan queue:listen
Could not open input file: artisan

I'm speaking with the host about upgrading supervisord (it's a managed VPS): CentOS 6 includes 2.1.9 by default, but 3.0 and above support a directory config directive to CWD to that directory before executing the command - I'm going to try that and hopefully it will fix the Supervisor problem.

I'd still like to know if there's a reliable way to run Artisan commands outside of the Laravel/Lumen project root though.

adam.harvie's avatar

Quick update in case anybody searches this:

Upgrading supervisord to support the directory config directive solved my problem, though I never figured out a way to run Artisan commands outside of the directory.

1 like
rowan86's avatar

thank you adam.harvie, this change got me to the actual error in my case: "supervisor: couldn't chdir to /home/webuser/public_html/: EACCES"

It seems that the used user had to be changed to root or webuser in order to access artisan.

Please or to participate in this conversation.