subo
subo copied to clipboard
Detect how subo was installed
Detect how subo was installed (Homebrew or not) so subo can provide appropriate update instructions (if an update is available).
@denopink, brew list <formula> will exit with exit code 1 if no formula for the specified package is found. We can use exec to execute this and detect if subo was installed using Homebrew.
I would like to work on this!!
Also, we would want to use this logic in check.go file that has not been merged with the main repo or in the version.go file?
Thx @DevChoganwala! Sounds reasonable to me 🙂 Based on @jagger27 feedback, it'll be added to CheckForLatestVersion()'s message. So let's throw it in check.go.
@denopink,
brew list <formula>will exit with exit code 1 if no formula for the specified package is found. We can useexecto execute this and detect if subo was installed using Homebrew. I would like to work on this!! Also, we would want to use this logic incheck.gofile that has not been merged with the main repo or in theversion.gofile?
That's clever. I like that!
Let's put any logic that checks for Homebrew in its own file. Make sure it fails gracefully on Linux hosts please!
Just so I am clear about this, there appear to be three main ways to get subo:
- Through Homebrew (can be updated using
brew upgrade subo) - Cloning this repository (can be updated using
git pull) - Downloading source code manually (can be updated by going to https://github.com/suborbital/subo/releases)
We'll put logic for checking this in a separate file and use this in check.go
Just so I am clear about this, there appear to be three main ways to get subo:
1. Through Homebrew (can be updated using `brew upgrade subo`) 2. Cloning this repository (can be updated using `git pull`) 3. Downloading source code manually (can be updated by going to https://github.com/suborbital/subo/releases)We'll put logic for checking this in a separate file and use this in
check.go
Yes, Homebrew and building from source are options, and we also provide binary builds. The key will be detecting if Subo was built from git HEAD or some tagged release.
Just so I am clear about this, there appear to be three main ways to get subo:
1. Through Homebrew (can be updated using `brew upgrade subo`) 2. Cloning this repository (can be updated using `git pull`) 3. Downloading source code manually (can be updated by going to https://github.com/suborbital/subo/releases)We'll put logic for checking this in a separate file and use this in
check.goYes, Homebrew and building from source are options, and we also provide binary builds. The key will be detecting if Subo was built from git HEAD or some tagged release.
I tried checking for origin remote of the local repository and if it matches with this repository, they can just pull new changes otherwise checking for brew or tagged release. One problem I notice is that I had to change checkVersionTimeout from 500 ms to 2500 ms for it to not timeout. I'll try to think of a better solution for this.
@DevChoganwala good stuff, but do we want to add all this IO to subo?
@jagger27 Would it suffice just to print out two messages? One for brew/mac users and one for "other users"?
If (installed with brew)
return "Run: brew upgrade subo"
else
return "Check out our install/upgrade instructions at ..."
We can always expand the messaging once we support other package managers.
I agree with @denopink. Instead of having instructions printed to the terminal, direct the user to a webpage where instructions would be listed in an efficient manner.
Currently we could just point them to https://github.com/suborbital/subo#install-from-source-requires-go.
Also, someone who installed subo with git or by downloading source code from release will have some experience with the ecosystem and would know exactly how to update. It seems unnecessary to print instructions further.
@denopink @Mithil467, your suggestions seem reasonable, I will update the code accordingly. One more matter that can be concerning is that users can have outdated repositories on their local machines since they may download new builds or clone the repository again. Are we looking to do something about this issue?
Once the user runs make subo, subo is installed in GOPATH. After that, the original directory from which it was installed has no significance and subo is globally available for use.
There might not be a way to find out the original directory. The user may not even have the source code or git repo on his drive anymore. We should not be concerned about these issues, and simply point the user to a webpage with further instructions based on if subo was installed with homebrew or not.
I also doubt the current implementation in PR #150 will work. As you are getting the current working directory which very well might be any directory and not necessarily the source code or git repo directory.
Documenting the outcome of #150, i.e.: we're going with @jagger27 's suggestion https://github.com/suborbital/subo/pull/150#issuecomment-994971486 instead of brew list and os check.
@DevChoganwala Let me know if you need any help with this 🙂 Happy New Years btw! 🍻