feat: notify user their version of dbc is out of date#266
feat: notify user their version of dbc is out of date#266
Conversation
|
@zeroshade what sets the |
|
I think this should probably just fail silently if it can't fetch the latest available dbc version. Telling the user that it didn't succeed is not really helpful or actionable. |
|
@amoeba any clever ideas about how to make this less annoying for users who are making the conscious choice not to upgrade (at least not right now)? |
Cloudfront function on the distribution for downloading dbc (we use it for the install scripts). It maps |
That's currently the case. It fails silently if it fails. Notice in |
eitsupi
left a comment
There was a problem hiding this comment.
I haven't looked into how existing software implements such functionality, but I wonder if there are cases where distribution channels might want to disable such functionality?
I imagine there might be a need to be able to disable this functionality at build time.
20e74a7 to
3645a7d
Compare
|
I've added a build tag that can be used to disable the "latest version" notification. Is that sufficient / what we were all thinking? Or are we thinking the inverse (a build tag that enables the latest version notification)? |
|
Based on a discussion with @amoeba today, let's rethink how to do this. As a user, it's frustrating to get a message that says you should update but doesn't say how to update. Because we provide so many install methods, there's not one simple how. To the greatest extent possible, we should give instructions for upgrading that match how the user installed. For example, if the user installed with |
|
That's where the idea of having a build that disables the message can come in? i.e. the binary on the cdn can have the out of data update message built into it, but other install methods can just rely on their own management? |
|
The build-time flag is good. That's what What do we think about having a subcommand to let dbc update itself? I don't like how this PR currently just notifies the user to upgrade. Examples of CLIs with different approaches to do this are,
The command would exist in all distributions but would error for non-direct methods and tell the user. It's implementation would also error on Windows since that's one platform where we can't replace a binary while it's running. The usual ways Windows programs deal with this is to ship a separate updater program but I think we can save that for another day. |
|
Which dbc installation methods make it impossible for us to know exactly how the user installed dbc? I think |
|
I'll double check but I think Edit: yeah, those are both just unpacking our wheels |
|
Our current distribution channels are,
Only (1) and (2) would get built with update notifications and the ability to self update. For the others, we have enough control over the dbc build to use the build flags approach to disable update notifications. |
|
One thing I forgot to add to the above: It was mentioned that users might want to stay on a particular version, so adding a way to opt-out would be good. Could we do that with an env var or maybe just an empty file (which would be easier)? |
|
It's hard to do a self-update if they installed via any package manager (uv, homebrew, via deb/rpm package, etc) because we wouldn't be updating the package manager's understanding of what version was installed. The only one that we could reliably have a self upgrade subcommand would be if they did the curl install (or otherwise pulled it from the cdn or GitHub release...) |
|
Right. Self update would only be for free-standing installs (curl, github). Are you saying maybe we don't want a self update command since it won't even work on some/most of our distribution platforms? I can get behind that. I'm curious if others like or dislike the idea of a self update command. If we didn't have it, I think I'd make a few changes to the PR:
|
|
@amoeba since we'd need to have a separate name_template for the archives with the build tags, could we instead use the currently running executable path to determine whether or not to show the update message? I've pushed an update here that uses the currently running path to skip displaying the notification for homebrew/venv/conda/pip installs etc. What do you think? Alternately, I can switch back to your original attempt and just add a proper name_template for the notify vs not notify builds. |
amoeba
left a comment
There was a problem hiding this comment.
Thanks for taking a crack at this. The idea made sense but it's a bit harder than I thought to get all the path detection perfect. I added some comments.
| // Directory for dbc credentials. This dir is distinct from GetUserConfigPath | ||
| // except for on macOS where it's the same | ||
| func GetCredentialPath() (string, error) { | ||
| func GetDbcConfigPath() (string, error) { |
There was a problem hiding this comment.
Doesn't this change the location of .no-update to $HOME/.local/share on Linux? I was thinking we wanted it in XDG_CONFIG_HOME since it's not a credential and the user would probably want the file to roam.
It it helps to rename these funcs, I think paths.go just needs two functions:
- Return the XDG_CONFIG_HOME equivalent (for config)
- Return the XDG_DATA_HOME equivalent (for credentials)
There was a problem hiding this comment.
good point, this was my mistake. I undid this change and just have notifyLatest call internal.GetUserConfigPath() which uses os.UserConfigDir() which will use XDG_CONFIG_HOME etc.
| // this is the case where we want to notify about updates | ||
| } | ||
|
|
||
| if runtime.GOOS == "windows" && strings.HasSuffix(filepath.Dir(exe), "\\Scripts") { |
There was a problem hiding this comment.
Do we need a check for the MSI installer too? It would cover manual MSI installation and also winget.
| return true | ||
| } | ||
|
|
||
| if strings.Contains(exe, "conda") || strings.Contains(exe, "venv") { |
There was a problem hiding this comment.
hrm, this is harder than I thought. When I install dbc into a conda env on macOS, I get a path of:
/opt/homebrew/Caskroom/miniforge/base/envs/test/bin/dbc
In a root Docker container: /root/miniforge3/bin/dbc
In a non-root Docker container: /home/test/miniforge3/envs/test/bin/dbc
Should we expand this check to include 'envs' so it at least covers a non-root miniforge3 setup? What are the conda-based setup where "conda" is part of the path? I wonder if we shouldn't change how the venv/conda check works to be more like brew. We could check env vars for being in a conda prefix or venv and compare the exe path with it.
On Windows I get C:\Users\Bryce\miniforge3\Scripts\dbc.exe so the windows check looks fine.
There was a problem hiding this comment.
That's because you're using miniforge/mamba instead of conda 😄 if you use conda directly you get conda in the path
There was a problem hiding this comment.
I figured, but I'll point out that miniforge is one of the three main ways conda recommends installing conda.
|
Two features that I think we can easily add here are,
|
Co-authored-by: Bryce Mecum <petridish@gmail.com>
Co-authored-by: Bryce Mecum <petridish@gmail.com>
|
closes #259