Skip to content

Deployer unable to find composer installed recipes #1371

Closed

Description

@jamieburchell
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?

Activity

  1. antonmedv commented on Sep 23, 2017

    @antonmedv
    Member

    I think it's a bug

  2. antonmedv commented on Sep 23, 2017

    @antonmedv
    Member

    Can you find and fix it?

  3. jamieburchell commented on Sep 23, 2017

    @jamieburchell
    ContributorAuthor

    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?

  4. antonmedv commented on Sep 23, 2017

    @antonmedv
    Member

    It's using include path.

  5. jordanbrauer commented on Oct 15, 2017

    @jordanbrauer

    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.

  6. antonmedv commented on Oct 16, 2017

    @antonmedv
    Member

    @jordanbrauer what do u suggest?

  7. jamieburchell commented on Oct 16, 2017

    @jamieburchell
    ContributorAuthor

    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.

  8. antonmedv commented on Oct 16, 2017

    @antonmedv
    Member

    Hmm, maybe better to fix include path of all repos? :) I'll do it.

  9. jordanbrauer commented on Oct 16, 2017

    @jordanbrauer

    @antonmedv I would handle recipes the same way Symfony handles their single components and autoloading.

    • Have it so that a user only needs to require deployerphp/deployer for the core functionality (common recipe)
    • Any additional recipes should be required as singletons (again, akin to Symfony single components), e.g., deployerphp/rsync
      • This allows users to select only the recipes they really need for their project
    • To use a recipe, simply require/use the file/namespace in your deployer file (again, see usage of Symfony standalone components if you need an idea of what I mean)

    Ideally, this would mean ditching the use of require "recipe/rsync.php"; in favour of use Deployer\Recipe\Rsync;. Since deployer seems to work off of global functions, using use will work fine for importing.

  10. jamieburchell commented on Oct 16, 2017

    @jamieburchell
    ContributorAuthor

    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.

  11. jordanbrauer commented on Oct 16, 2017

    @jordanbrauer

    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 a composer.json file, Composer will update it's set of commands, adding yours to it (try it by running composer list, and you will see your commands).

    My point is, is that if a PHP CLI application is installed globally via a .phar rather than as a local composer binary, the application can still be extended for a local instance only.

  12. antonmedv commented on Oct 16, 2017

    @antonmedv
    Member

    I think we should keep it simple and do not reinvent the wheel. Use what already in php and composer.

  13. jordanbrauer commented on Oct 16, 2017

    @jordanbrauer

    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). 😮

  14. 35 remaining items

  15. memen45 commented on Feb 19, 2021

    @memen45
    Contributor

    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!

  16. jamieburchell commented on Feb 19, 2021

    @jamieburchell
    ContributorAuthor

    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

  17. memen45 commented on Feb 19, 2021

    @memen45
    Contributor

    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.

  18. Schrank commented on Feb 19, 2021

    @Schrank
    Contributor

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

  19. jamieburchell commented on Feb 19, 2021

    @jamieburchell
    ContributorAuthor

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

  20. Schrank commented on Feb 19, 2021

    @Schrank
    Contributor

    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?

  21. jamieburchell commented on Feb 19, 2021

    @jamieburchell
    ContributorAuthor

    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.

  22. jamieburchell commented on Feb 20, 2021

    @jamieburchell
    ContributorAuthor

    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.

  23. memen45 commented on Feb 20, 2021

    @memen45
    Contributor

    @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 Copy shared files from release #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!

  24. memen45 commented on Feb 20, 2021

    @memen45
    Contributor

    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.

  25. jamieburchell commented on Feb 20, 2021

    @jamieburchell
    ContributorAuthor

    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.

  26. antonmedv commented on Mar 7, 2021

    @antonmedv
    Member

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

  27. trip-somers commented on Aug 2, 2021

    @trip-somers

    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?

  28. memen45 commented on Aug 3, 2021

    @memen45
    Contributor

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

  29. vajda-media commented on Sep 29, 2022

    @vajda-media

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions