-
Notifications
You must be signed in to change notification settings - Fork 391
Add custom postgres installation support #797
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
base: master
Are you sure you want to change the base?
Add custom postgres installation support #797
Conversation
I'm not a huge fan of this implementation. It mixes paths and display names in the menu. Maybe we should have a text field labelled "Binaries" under the popup, wich shows the path. If you select a bundled version it is disabled (informative only), if you select "custom" it becomes editable. |
* Restart from base * Add a "Custom…" option to bottom of available binaries * Add "Binaries" text field which shows the binPath of selected version and is only enabled/editable if "Custom…" is selected * Update launchers to include a LC_ALL environment variable as many custom installs will have `--enable-nls` installed
11cdda1
to
9eef7aa
Compare
@jakob That's a good idea and makes the implementation much cleaner. I've force pushed over the top with these changes. Attached some screenshots. Only other thing is that postgres requires a LC_ALL environment variable if it's been compiled with ![]() ![]() |
Oh, that is annoying. I wonder if we can find a start command that works for all PostgreSQL versions. The next issue is probably the initdb command. But people can just use initdb from the command line instead. Another potential gotcha is that Postgres.app always runs PostgreSQL using the current user. I think this matches Homebrew, but EnterpriseDB uses a separate user account. So if people try to use Postgres.app to control the EnterpriseDB server, that might lead to unexpected results. I don't think any of these are deal breakers, but we should think about these issues before merging this feature. |
Another potential issue that I see is that the Homebrew path seems to contain the minor version of PostgreSQL. So after an update the binaries path would need to be changed? Right now there is no way to change the binary path in the UI, you would need to remove and re-add the server to change it. Another issue: Postgres.app has some logic to fix incorrect binary paths that can happen when you move the app (eg. if you create a server when the app is launched from the disk image). We need to make sure that logic doesn't attempt to "fix" custom paths. |
@jakob I think the feature should be aimed at "use the binaries at Y" but let "Postgres.app" manage it like it would manage it's bundled in versions. My particular use case is just using Homebrew binaries to get access to pgxnclient and custom extensions. If we wanted to go beyond this would probably need to allow configuring servers in preferences with a full list of options like binary path, users, environment flags, arguments etc… |
Hmm yea those are some more interesting issues I didn't consider. Particularly I'm not sure what Homebrew does on minor version upgrade (and it doesn't appear easy to simulate that!). I guess tricky because there is no way to "remedy" it by editing the added server, you have to delete and re-create. |
This is what I meant with discussion before implementation :) There are several issues that need to be ruled out to decide if and how we can deal with external binaries, not just the layout of the user interface. Some that come to mind:
I'm not against the idea, it's something that advanced users could certainly benefit from. But it is difficult to find a way that both satisfies these needs and maintains the simplicity of Postgres.App for the average user. We usually try hard to hide complexity. |
If this is the main motivation, maybe we should try to tackle this directly? Custom extensions can be built against our binaries and |
Hi, folks, I'm author of a book on SQL who also teaches a lot of beginners how to get started with PostgreSQL. In my book, for Mac users, I recommend PostgresApp. I've been following this discussion and think I have a sense of what you're trying to do. One small thought: One of the best things about PostgresApp is that, like a lot of things in the macOS world, it "just works" and is so simple to get going. I hope that even if you implement these changes, you'll keep the current setup experience as streamlined as it is. Thanks for offering such a great product. IMO the best way to experience PostgreSQL setup! |
I am pretty sure we could find reasonable answers for all the questions that @tbussmann brought up, but we really have to figure out if this use case is important enough. I use Postgres.app with custom binaries myself, so I can see the appeal of this feature. To use custom binaries, I just manually change the user defaults with Prefs Editor. Maybe we should just add a link to that app in the Postgres.app documentation? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed the code changes. (This does not mean we'll merge it, whether this feature should be merged is a separate discussion)
@@ -60,7 +79,16 @@ class AddServerViewController: NSViewController, MainWindowModelConsumer { | |||
|
|||
@IBAction func createServer(_ sender: AnyObject?) { | |||
guard self.view.window!.makeFirstResponder(nil) else { NSSound.beep(); return } | |||
guard availableBinaries.indices.contains(selectedVersionIdx) else { | |||
|
|||
let isValid = if availableBinaries.indices.contains(selectedVersionIdx) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check isn't necessary anymore, since the array is no longer accessed in this function.
|
||
let isValid = if availableBinaries.indices.contains(selectedVersionIdx) { | ||
true | ||
} else if FileManager().fileExists(atPath: binPath.appending("/postgres")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is a good idea, but we should probably present an error message instead of beeping.
Previously, the only way to trigger this error was if you made a debug build without binaries, and the beep was to avoid a crash. Now the error is much more likely to occur if you mistype the binary path, so we should let the user know that the problem is that no binaries were found at the path.
varPath = FileManager().applicationSupportDirectoryPath().appending("/var-\(availableBinaries[selectedVersionIdx].version)") | ||
} else { | ||
binPath = customBinPath |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think setting this to the home directory makes sense. I'd just leave it at the last value instead
@@ -13,17 +13,29 @@ class AddServerViewController: NSViewController, MainWindowModelConsumer { | |||
@objc dynamic var mainWindowModel: MainWindowModel! | |||
@objc dynamic var name: String = "New Server" | |||
@objc dynamic var port: UInt = 5432 | |||
@objc dynamic var binPath: String = "" | |||
@objc dynamic var binPathEditable: Bool = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternative might be to hide the "Binaries" field instead of disabling it when a built-in version is selected. That would reduce the complexity of the form for 99% of users who don't care where their binaries are.
Just to add another perspective to the discussion: There seems to be an application specifically designed for managing 'foreign' PostgreSQL binaries on macOS: PostgresPrefs It hasn't received a lot of maintenance recently but maybe worth a look? |
Code wise the AppKit bindings to
versions
needed to move to an object that could track a display name as well as additional info about the version once selected.I'm not overly happy about the in-place modification after choosing a custom path but it works and keeps the change set smaller.