-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deployer unable to find composer installed recipes #1371
Comments
I think it's a bug |
Can you find and fix it? |
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? |
It's using include path. |
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. |
@jordanbrauer what do u suggest? |
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. |
Hmm, maybe better to fix include path of all repos? :) I'll do it. |
@antonmedv I would handle recipes the same way Symfony handles their single components and autoloading.
Ideally, this would mean ditching the use of |
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. |
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 My point is, is that if a PHP CLI application is installed globally via a |
I think we should keep it simple and do not reinvent the wheel. Use what already in php and composer. |
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 ( |
It's impossible to autoload tasks. In php and composer we can autoload only classes (not even functions, but you can I think something like this will be good: require 'vendor/autoload.php'; // Or move it to deployer and automatically detect
require 'common.php'
require 'slack.php' All recipes have to provide |
Ahh, you are right! My bad. I think that user should be responsible for handling the inclusion of their autoload file. This way they are able to bootstrap however they please, even if they are not using composer. |
From my experience doing The reason is that composer uses spl_autoload_register(..., true, true); The important is the second 'true' param in spl_autoload_register function. Its "prepend" and means the classes searching for this spl_autoload_register will be done before other registered ealier (by composer autoload from deployer in that case). That means that if deployer will want to create symfony console object then it will use class from root project vendors and not from itself vendors (inside phar). That of course can lead to problems if there are different version of symfony console for deployer phar and for root project. The solution I know is to make light loader and register it with spl_autoload_register but without the third "prepend" param set to true. Then if there are the same libraries used in deployer and root project - deployer will use itself library first. The example of such loader which uses information generated by composer itself is in this little library: https://github.com/sourcebroker/deployer-loader I'd be glad to hear for better solution. |
I think it will be cool to have possibility to include recipes like this without worried about autoload: require 'common.php'
require 'slack.php' Deployer already has autoload.php detection https://github.com/deployphp/deployer/blob/master/bin/dep#L52-L56 |
So now, then using phar one think should be done is requiring projects autoload.php |
As another solution: fork all used symfony components and rename namespace. |
@antonmedv |
Yes, it's true. One more solution: when building phar archive create a bootstrap file (with all needed classes) and require it as first line in |
@antonmedv 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. |
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. Yes, this is a solution too. I think I'll try to implement this. |
After lots of thinking, here is what I came up with: Installing with composer
Installing with archive
|
* Added note about current bug with autoload I added a note + temporary workaround for deployphp/deployer#1371 so that users don't have to waste time figuring out why this isn't working currently. This will be reverted hopefully once v7 is released with a fix. I also added better examples to the configurations so that new users would know exactly how to use the commands. * Fixed typo removed extra 'required' which was a typo.
Example remedy:
|
Updating phar on our build server broke our deployment process due to:
These recipes were present in that phar previously? |
What version of dep? |
Well it seems that this problem is somewhere on my side, although I have no idea why this happens.
I also have two other versions in bin:
I only updated the 6.3.0 as two others are version-locked for compatibility. The one used in deployment that went broken is 6.0.5 (dep6). Im wondering if its possible that in bin I had an old phar with this receipt and after update to 6.3 it was removed. My include path during install:
|
include_path looks normal. Try running this script locally. |
Just thought I'd share my experience with php 7.0.32: I finally traced it to the presence of the ioncube_loader extension. Disabled ioncube and everything works normally. |
why not just include the autoloader? #1371 (comment) |
I am having same problem caused by ioncube. |
This is how I "solved" the issue require 'phar:///usr/local/bin/dep/recipe/common.php'; Even though the get_include_path() was |
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 |
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? |
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! |
And the documentation refers to something else that's abandoned. |
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. |
@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 :-) |
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. |
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? |
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. |
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. |
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! |
You are indeed correct, the latest stable version 6.8.0 doesn't have the contrib folder yet. |
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. |
Will work on documentation for sure. Just need to find time) |
I just read every comment in this thread, and I'm still not sure what I'm supposed to do to fix this problem.
I did not see a solution in this thread for getting |
@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. |
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! |
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:
Content of
deploy.php
Worked around the issue thus:
Should that be part of the documtation or is something broken?
The text was updated successfully, but these errors were encountered: