The readline library is used by a slew of command line interpreters, including bash, to provide a standardized way for users to write and edit command lines, and maintain histories.
Clauses in PHP's license make it incompatible with the GPL and therefore unable to be linked with the standard readline library, which is GPL-licensed. There is a BSD-licensed library called libedit which is meant to be a replacement for readline, however it is lacking in some functionality.
Due to licensing issues, Debian, Ubuntu, and perhaps other distros do not build their distributed versions of php to link with readline, and instead link it with libedit.
This topic has now come up in two different issues, #437568: Autocomplete awesomeness for drush and #543550: Drush interactive mode, so in order to help keep the discussion of those issues on topic I've created this one.
Comments
Comment #1
intuited commentedJust some info gleaned from the other threads:
A build of php 5.2 against the readline library is said to be available at http://dotdeb.org. This was mentioned in #437568: Autocomplete awesomeness for drush comment #50, and also in the first comment of #437668: Changing the order of fields on node: title on second position?. I haven't tried this myself, and don't know eg if they make available a package for Ubuntu or just Debian.
Comment #2
intuited commentedIf the package at dotdeb.org doesn't work for you, these instructions may be useful. This should help you build a version of php that uses readline instead of libedit, but otherwise work as it normally does as per your distro.
This will replace any version of php on your system that was installed in the standard way through the apt system, eg via aptitude, synaptic, etc.
The dpkg line is sort of a brute-force method in that you end up installing php stuff that you may not need; it's probably better to pick and choose which debs you actually need to install.
You probably won't need to install the php5-dev package but if you do you will have to install the 'shtool' package:
The file debian/README.source mentions that if you install the php5-dbg.deb file, you will probably need to install some other packages first, and that you can get a list of likely suspects by doing
But you should already have those installed if you've already installed that package through aptitude. In general if you have dependency problems when running dpkg, it's because you're installing packages that aren't already installed on your system; maybe try `aptitude search '~n^php' |grep '^i'` to see what's actually installed, and then just run dpkg -i on your locally-built versions of those packages and the php packages they depend on. EG install the core package first and then cli and whatever else you need.
If something goes wrong, or you would like more background info, I found this guide from the Debian website to be a good reference for working with .deb packages. Section 7.14 is particularly relevant.
Hope this helps!
Comment #3
jonhattanfor completeness: densite module has had also issues with readline: #501056: requires readline support in php-cli but debian lenny has no readline support for it's php-cli package
Also to note that debian does not provide php with libedit. Is just ubuntu who provides php with libedit.
I think this issue could be converted to a documentation page in drush code (perhaps an appendix to README.txt) or the drush handbook.
In the general term could be of interest to provide a drush_readline() to unify efforts on distinct commands. Zenophile is also moving to drush (#445608: Add drush commands for sub-theme creation) and they will also need some readline.
Comment #4
Garrett Albright commentedFor the record, Zenophile doesn't need readline. I'm not sure why it would…
Comment #5
jonhattanI mean zenophile, as a command that receives user input interactively, could benefit of readline.
Comment #6
Garrett Albright commentedIt doesn't receive user input interactively, though. It just takes command line arguments like most other Drush commands.
Comment #7
intuited commentedHaving readline available would be helpful to people who are dropping into a php shell, ie read-eval loop of some variety, from within drush. This was my major motivation to get php-readline working, as it's a super convenient way to test code and explore the API. There are a few different shells out there (phpsh, php_shell, etc) that may be pretty easy to just drop into from a drush command; I've written a drush module with basic shell functionality and some completion that seems to be growing into a project in its own right, and ought to be integrated with the 'drush cli' command's code somehow.
Comment #8
izkreny commentedSubscribing.
Comment #9
jennifer.chang commentedsubscribe.
Comment #10
jhr commentedno progress in 2 years... start another thread ...
novice triaged - feel free to reopen
Comment #11
jennifer.chang commentedfixed?
Comment #12
greg.1.anderson commentedNo, won't fix.
Comment #13
owen barton commentedFor anyone curious, the primary issue with libedit was resolved some time ago https://bugs.launchpad.net/ubuntu/+source/php5/+bug/322214