deployer icon indicating copy to clipboard operation
deployer copied to clipboard

Deployer unable to find composer installed recipes

Open jamieburchell opened this issue 9 years ago • 56 comments

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', '[email protected]: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?

jamieburchell avatar Sep 22 '17 22:09 jamieburchell

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?

jamieburchell avatar Jun 01 '20 16:06 jamieburchell

A little late, but for future reference: some recipes are in the contrib directory, some are in the recipe directory. Example for your case:

require 'contrib/cachetool.php';

Other example:

require 'recipe/laravel.php';

So check in which of the two directories the recipe resides, then include the correct one!

memen45 avatar Feb 19 '21 21:02 memen45

A little late, but for future reference: some recipes are in the contrib directory, some are in the recipe directory.

And the documentation refers to something else that's abandoned.

https://deployer.org/recipes.html

jamieburchell avatar Feb 19 '21 21:02 jamieburchell

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.

memen45 avatar Feb 19 '21 21:02 memen45

@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 :-)

Schrank avatar Feb 19 '21 22:02 Schrank

@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.

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.

jamieburchell avatar Feb 19 '21 23:02 jamieburchell

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?

Schrank avatar Feb 19 '21 23:02 Schrank

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 avatar Feb 19 '21 23:02 jamieburchell

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.

jamieburchell avatar Feb 20 '21 08:02 jamieburchell

@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.

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:

  • Use versions in the documentation
  • Mark incomplete sections in the documentation (e.g. 'This section is incomplete', 'This section requires examples' etc). This way users are aware that it isn't complete, and at the same time potential contributors know how to contribute.
  • Provide some steps for contributors to contribute properly (i.e. how to build and test the project locally on your pc). I noticed a pull request #2267 where the contributor doesn't know how to make a test. And for me, I know some php and the code base seems to be very clearly written, but I have no idea how to modify and then build the source code again. Adding a small guide (if possible just provide links to existing guides and make remarks for the changes) could really help to make contributing easier.

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 avatar Feb 20 '21 11:02 memen45

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.

You are indeed correct, the latest stable version 6.8.0 doesn't have the contrib folder yet.

memen45 avatar Feb 20 '21 11:02 memen45

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.

jamieburchell avatar Feb 20 '21 11:02 jamieburchell

Will work on documentation for sure. Just need to find time)

antonmedv avatar Mar 07 '21 10:03 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.

  • Installed phar globally following installation instructions in documentation.
  • require succeeds for present recipe folder.
  • require fails for non-existent contrib folder.

I did not see a solution in this thread for getting contrib files to work. Did I miss it?

trip-somers avatar Aug 02 '21 22:08 trip-somers

@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.

memen45 avatar Aug 03 '21 22:08 memen45

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!

vajda-media avatar Sep 29 '22 21:09 vajda-media