Repository navigation
Closed
Description
| 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?
Reacted by Digital Lion, Colin O'Dell, Hagen Hübel , Florian Kaiser, y2keeper and Nei Santos
Activity
antonmedv commentedon Sep 23, 2017
I think it's a bug
antonmedv commentedon Sep 23, 2017
Can you find and fix it?
jamieburchell commentedon Sep 23, 2017
I can’t see how Deployer was designed to find the composer installed recipes. Presumably, it needs to know where the vendor directory is (read composer.json/assume default?) and to add the path to those recipes to the include path? Or the expectation on the user is to simply provide the full path to the third party recipes. Perhaps, if Deployer is run and installed using the local composer method, it would find the recipes?
antonmedv commentedon Sep 23, 2017
It's using include path.
jordanbrauer commentedon Oct 15, 2017
I am having this problem as well.
Perhaps recipes should be redesigned in how they are implemented? My initial thought would be to do something similar to how Symfony handles extension – simple abstract classes and interfaces.
Deployer already uses Symfony Console, so why not utilize the class autoloading of composer? It will make extension much easier I think.
antonmedv commentedon Oct 16, 2017
@jordanbrauer what do u suggest?
jamieburchell commentedon Oct 16, 2017
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.
antonmedv commentedon Oct 16, 2017
Hmm, maybe better to fix include path of all repos? :) I'll do it.
jordanbrauer commentedon Oct 16, 2017
@antonmedv I would handle recipes the same way Symfony handles their single components and autoloading.
deployerphp/deployerfor the core functionality (common recipe)deployerphp/rsyncIdeally, this would mean ditching the use of
require "recipe/rsync.php";in favour ofuse Deployer\Recipe\Rsync;. Since deployer seems to work off of global functions, usingusewill work fine for importing.jamieburchell commentedon Oct 16, 2017
Would this still work if like me, you've installed the deployer.phar in to the project root and not via composer? That is the first installation method shown on the install page.
jordanbrauer commentedon Oct 16, 2017
Good question – I am sure that there would be a way to make it work yes. As an example, when you add entries to the
"scripts"key of acomposer.jsonfile, Composer will update it's set of commands, adding yours to it (try it by runningcomposer list, and you will see your commands).My point is, is that if a PHP CLI application is installed globally via a
.pharrather than as a local composer binary, the application can still be extended for a local instance only.antonmedv commentedon Oct 16, 2017
I think we should keep it simple and do not reinvent the wheel. Use what already in php and composer.
jordanbrauer commentedon Oct 16, 2017
I am not sure I understand @antonmedv? None of what I mentioned requires reinventing the wheel and uses default composer autoloading with native PHP imports (
use). 😮35 remaining items
memen45 commentedon Feb 19, 2021
A little late, but for future reference: some recipes are in the contrib directory, some are in the recipe directory. Example for your case:
Other example:
So check in which of the two directories the recipe resides, then include the correct one!
jamieburchell commentedon Feb 19, 2021
And the documentation refers to something else that's abandoned.
https://deployer.org/recipes.html
memen45 commentedon Feb 19, 2021
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.
Schrank commentedon Feb 19, 2021
@jamieburchell @memen45 As always in live, playing with the kids, computer or enjoying lunch with your loved ones is more important than correcting documentation or code on a open source project.
That said: we are happy for every hint of wrong stuff. Happy for a pull request, but happy for a note as well. My free time highly differs, I don't know about Anton, but I guess the same. But I love to fix things on my free time :-)
jamieburchell commentedon Feb 19, 2021
Nobody said those things aren't more important.
I'm tired of reading "update the documentation yourself" on open source projects because the whole point usually is that someone has opened a bug report or is asking questions because they've spent a whole lot of time trying to fathom how something is supposed to work, hunting through code and issues and ironically, relying on the documentation.
In this case, we don't know what the intention is of the project - why deployer recipes were deprecated, what the expectation is to make it work or how it is supposed to work. So with no clue or documentation the only thing someone can do is create an issue, like this.
The time seems to be there to deprecate and change stuff and confuse everybody, but not to explain why.
I'd certainly prefer to play with my son than try and second guess, that's for sure.
Schrank commentedon Feb 19, 2021
That is a very good point and I joined the team late, so same for me. Than let's fallback to the first point. You ask questions/tell us what your problems are and we try to improve the doc so the next one finds the answer in the doc, works for you?
jamieburchell commentedon Feb 19, 2021
Hey, no blame here just frustration ;)
The original issue I opened was that following the documentation and including recipes didn't work without adding the location of said recipes to the include path. I don't know if that was ever addressed as all my deploy scripts just set the location of the recipes in the include path now.
Fast forward some time and the deployer/recipes package was archived but I couldn't figure out how to bring in the recipes I was using before such as cache tool because they were missing from the "recipes" directory. During this time the documentation was still (and is still) pointing at how to use the recipes via the archived packages. Today I learnt from a reply here that I should look for some of the recipes in the contrib folder but I have not tried that yet. It may be the missing part of the jigsaw. I still use the archived composer package and ignore the deprecation warning, because I assumed the stuff I used from there wasn't available without it.
jamieburchell commentedon Feb 20, 2021
Yeah so there is no contrib folder because deployer v7 isn't outside of beta yet. So the deployer/recipes is still the only way to get this even though it's archived. And the original purpose of this bug report is tagged as v7 milestone too.
memen45 commentedon Feb 20, 2021
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!
memen45 commentedon Feb 20, 2021
You are indeed correct, the latest stable version 6.8.0 doesn't have the contrib folder yet.
jamieburchell commentedon Feb 20, 2021
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.
antonmedv commentedon Mar 7, 2021
Will work on documentation for sure. Just need to find time)
trip-somers commentedon Aug 2, 2021
I just read every comment in this thread, and I'm still not sure what I'm supposed to do to fix this problem.
requiresucceeds for presentrecipefolder.requirefails for non-existentcontribfolder.I did not see a solution in this thread for getting
contribfiles to work. Did I miss it?memen45 commentedon Aug 3, 2021
@trip-somers Install the beta 7.0.0 instead of 6.8.0 and you will find the contrib directory. There is no workaround as far as I know.
vajda-media commentedon Sep 29, 2022
I have to use the new 8.x-dev version of deployer and sweating like dirty pig to get it run. Please I would really appriciate a v8 documentation as well. Many thanks!