-
Notifications
You must be signed in to change notification settings - Fork 372
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
libreadline is not used and command line history is not available #144
Comments
PostgresApp is compiled with libedit, which is a replacement for the GNU readline library. Could you elaborate a bit? Which version of PostgresApp are you using? What OS are you on? What exactly doesn't work? And most important, how do you launch psql? Are you sure you are launching psql included with PostgresApp instead of the system-provided psql (before Mavericks) or another version installed by eg. MacPorts? |
I am using PostgresApp 9.3.0.0 on Mavericks.
My problem is in Ctrl+r which should bring in reverse-search, but it doesn't work. |
It seems that libedit lacks advanced features of libreadline. I don't know why Postgresapp uses libedit instead of libreadline (@mattt might know). I can only assume it is because of licensing issues. I found a lengthy thread on the psql-hackers list related to this topic http://postgresql.1045698.n5.nabble.com/Debian-readline-libedit-breakage-td3380317.html I assume we could just get rid of libedit and link against the system provided libreadline, but I'm not totally sure if that complies with the GPL. |
In the latest version I tried to compile with readline, but for some reason I just couldn't get that to work. It always linked with libedit instead. If anybody finds out how to build postgresql with readline, please let me know. |
Having trouble managing history especially with large queries I've constructed with |
@dpiddy have you discovered a fix or workaround? Has the conversation moved elsewhere? |
The conversation hasn't moved elsewhere. As I stated above, I tried to get PostgreSQL to compile with the version of readline that ships with OS X, but I couldn't get it to work. If someone finds out how to get it to work (perhaps someone on the PostgreSQL mailing lists might be able to help), I'll integrate this in Postgres.app, but right now I unfortunately don't have the time to handle this task myself. |
I use postgresql from homebrew now. |
Could you compile postgresql using homebrew? |
Maybe. But then we'd always lag behind homebrew. (Note: there's nothing stopping you from using the Postgres server from Postgres.app and Also, I think I found out why PostgreSQL won't compile with the OS X provided readline: |
Libedit actually supports Ctrl+R.
|
This is still pretty annoying, especially since @fab1an's workaround above doesn't actually work on my machine. :-/ Can Postgres.app not just statically link to readline at build time instead of using OS X's editline at runtime? |
Did you copy that exact line? And restarted the terminal? |
@fab1an I did copy the exact line. It changed the behaviour of |
While further customizing .editrc, it took me a few minutes to realize that some lines weren't working because the file does not appear to support comment lines starting with |
Nice. If your further customization has to do with psql, can you share it? Sent from my iPhone
|
Just some navigation basics that my fingers still use:
That's • history completion with Ctrl-R |
Any progress or conclusion to this issue? I'm another person who had previously used homebrew's psql and switched to Postgres.App hoping it would make things easier, but found that its |
@wiseman I don't think there's a licensing issue. I assume that Apple doesn't ship libreadline because it is GPLv3, but that shouldn't be an issue for us. Linking with libreadline would require us to build libreadline ourselves and include it with Postgres.app. It would make Postgres.app a bit bigger, but I'd assume that libreadline is small, so that hopefully wouldn't be an issue. However, building Postgres.app already takes an hour, so I'm not particularly thrilled about adding more stuff. But as far as I understand, the issue is just that libedit has different keyboard shortcuts than libreadline? We could fix this by documenting this on the page about command line tools. Or are there other features that libedit does not support? In general, I prefer linking with Apple provided libraries if possible -- but if someone can make a sound argument why we should include libreadline, I'm happy to reconsider. |
@jakob Two of the obvious problems with libedit include:
It seems like the arguments for not using libreadline are only predicated on deference to Apple? The build time of libreadline seems a) likely to be insignificant relative to building Pg and b) not something that effects people daily. |
One pretty annoying issue was that PostgresApp's libedit version of psql silently overwrote my existing libreadline-compatible |
Eh, issue from 2013 still alive. I am not against the libedit, it must just works with multirows queries. Simple example: Workaround is to install simultaneously postgresql.app and posgresql from home-brew. And install postgresql server from GUI, but psql from terminal (in this case launched psql from home-brew in my case). |
I believe macOS (based on BSD-derived Darwin) ships with libedit because that's the BSD-licensed equivalent of libreadline (a GNU library.) Respectively, the libraries use Right now I have both a function history I can access with the up/down arrows that came at no cost or configuration, and vi-mode for line editing etc. (including history search.) I only recently came to appreciate @tsibley's point on long queries being truncated, very frustrating. A brief search turns up a libedit header with I believe this issue can be closed. PostgreSQL mailing list archive, for reference: "Re: psql + libedit command history truncation (was: psql history vs. dearmor (pgcrypto))" |
Hello @jakob, maybe it's possible to use readline instead of libedit by setting: Here are some similar issues that used these two commands to connect to readline: The problem that led me here is that when I'm using PostgresApp, the history gets messed up and ends up like this: I believe this causes the terminal prompt to wrap onto the same line, and when I browse the history with the up and down arrow keys, gaps appear and some text does not appear while other text does not get deleted. When I use the brew installed postgresql, its history files look like this: |
I'd like to make a case for switching to GNU Readline. I spent today investigating the various issues such as linking (I was hoping to rather rudely use Otherwise, I can send a PR on the website documentation to mention the overwrite of In the meantime, I've dusted off my old
One unfortunate consideration: at this point, switching to GNU Readline will mean a loss-of-history for those users already using Postgres.app. |
I'm not sure if you're looking at the One would need another program to read the file using the API of the line editing library, then print it out nicely. I was just wondering about this myself, and it turns out the psql If you want to verify if the history is messed up, or perhaps just print it to a readable format for copy/paste, etc., try: |
Thanks, @richardkmichael! I'll try that! |
Is there a particular reason why libreadline is not used so that all invaluable command line features (like history, reverse search, ...) are not available? psql supports this out of the box and it looks for libreadline in the path (while configuring), or can be configured to look into custom paths.
The text was updated successfully, but these errors were encountered: