deployer: Deployer unable to find composer installed recipes
Q | A |
---|---|
Issue Type | Question |
Deployer Version | 6.0.3 |
Local Machine OS | WSL |
Remote Machine OS | CentOS 7 |
Description
Deployer fails to find and require recipes installed via the method included in the third party recipe instructions
Steps to reproduce
Install recipes:
composer require deployer/recipes --dev
Add a recipe as per docs:
require 'recipe/cachetool.php';
Run deployment:
dep deploy production
OR
php deployer.phar deploy production
Result:
PHP Warning: require(recipe/cachetool.php): failed to open stream: No such file or directory in /mnt/d/web/deploy.php on line 3
PHP Fatal error: require(): Failed opening required 'recipe/cachetool.php' (include_path='phar:///mnt/d/web/deployer.phar/bin/../:.:/usr/share/php') in /mnt/d/web/blog.ib3.uk/deploy.php on line 3
Content of deploy.php
<?php
namespace Deployer;
require 'recipe/composer.php';
require 'recipe/cachetool.php';
// Project name
set('application', 'Example');
// Project repository
set('repository', 'git@bitbucket.org:foo');
// Hosts
host('xxx')
->stage('production')
->user('deploy')
->set('deploy_path', '/var/www')
->set('cachetool', '127.0.0.1:9000');
// Shared files/dirs between deploys
add('shared_dirs', [
'web/app/upgrade',
'web/app/uploads',
'web/app/wfcache',
'web/app/wflogs'
]);
// Copy config
task('enable_prod_config', function() {
run('cp "{{release_path}}/.env.prod" "{{release_path}}/.env"');
})->onStage('production');
after('deploy:update_code', 'enable_prod_config');
// Clear opcache
after('deploy:symlink', 'cachetool:clear:opcache');
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
Worked around the issue thus:
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . 'vendor/deployer/recipes');
Should that be part of the documtation or is something broken?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 6
- Comments: 56 (43 by maintainers)
Commits related to this issue
- Added note about current bug with autoload I added a note + temporary workaround for https://github.com/deployphp/deployer/issues/1371 so that users don't have to waste time figuring out why this isn... — committed to XanderLuciano/recipes by XanderLuciano 6 years ago
- Added note about current bug with autoload (#178) * Added note about current bug with autoload I added a note + temporary workaround for https://github.com/deployphp/deployer/issues/1371 so that u... — committed to deployphp/recipes by XanderLuciano 6 years ago
- Fix for yarn dep https://github.com/deployphp/deployer/issues/1371 — committed to othyn/emilyraisin.com by othyn 5 years ago
- fixes path to npm.php https://github.com/deployphp/deployer/issues/1371 — committed to yawik/yavue-nuxt by cbleek 5 years ago
Example remedy:
What’s the status of this please? I just noticed deployer/recipes is abandoned but including recipe/cachetool.php without them doesn’t work for me and the composer and CodeIgniter recipes I use in older projects are missing it seems?
Was the recipe repo prematurely archived and abandoned before v7 of Deployer was released?
I build a docker image for
CI/DEPLOYER
there withdeployer/recipes
installed globally anddeployer
is install withphar
then in my
deployer.php
of projectIt Just works well
@antonmedv
I just read every comment in this thread, and I’m still not sure what I’m supposed to do to fix this problem.
require
succeeds for presentrecipe
folder.require
fails for non-existentcontrib
folder.I did not see a solution in this thread for getting
contrib
files to work. Did I miss it?Really appreciate the efforts made by the contributors of course! Just wanted to help out here. With regards to the documentation, I have seen many projects where this is lacking. And that is not a problem at all. I think the following could help a lot:
Those are just some things that I noticed as I started diving in only weeks ago. Apart from this, I really like the Deployer software and the functionality it brings, so thanks a lot for that!
@antonmedv IMO there will be never problem with adding
require 'vendor/autoload.php'
to deploy.php when you install deployer withcomposer require deployer/deployer
as at this level developer already needs to solve the potential conflicts.Problem will only occur ONLY when we use phar based deployer. For that case there is simple solution however. Deployer needs to detect if there is vendors/autoload.php from root project and if yes they it should require that file BEFORE require autoload from phar. This way the deployer classes will have precedence over that one from root vendors.
At a minimum update the documentation to show that the include path needs to include the deployer recipes directory. As it stands all the examples and documents suggest it “just works” without, when it doesn’t.
I think that’s where the confusion has come from - between the deployer/recipes composer package being archived/deprecated but not able to find the recipes in the current stable version and of course the confusing documentation when faced with the above. By the way, I love Deployer and use it on all my work projects.
Indeed, documentation is wildly incomplete and contradicting itself. I do not know what the idea is of the maintainer(s), as the website looks very nice, but the information is very limited.
Well. This one is over. Almost 3 years since opening. Now recipes gonna live in deployer repo: https://github.com/deployphp/deployer/tree/master/contrib
After lots of thinking, here is what I came up with:
Installing with composer
autoload.php
file (local or global) and require it.vendor
dir forcomposer.json
files and fetch stuff like this:include_path
toset_include_path
— this allows to simple recipe requirement:Installing with archive
deployer.phar
orbin/dep
.vendor
step as on composer installation.autoload.php
file required, you need to manually add it to yourdeploy.php
file if needed.dep
it will check existing next files in project:deployer.phar
bin/dep
vendor/bin/dep