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
Detect macOS and brew and use the prefix #261
base: master
Are you sure you want to change the base?
Conversation
For macOS and the Homebrew package manager, get the installation directory from the `brew --prefix jenv` command instead of deriving the path with `abs_dirname()`. This will hopefully address the concerns I raised in: #260
@@ -47,7 +47,20 @@ abs_dirname() { | |||
cd "$cwd" | |||
} | |||
|
|||
root="$(abs_dirname "$0")/.." | |||
set +e | |||
if [ "$( uname -s )" == "Darwin" -a -n "$( which brew )" ]; then |
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.
if [ "$( uname -s )" == "Darwin" -a -n "$( which brew )" ]; then | |
if [ "$(uname -s)" == "Darwin" -a -n "$(which brew)" ]; then |
Consistent code style throughout the file is a little easier on the eyes.
root="$(abs_dirname "$0")/.." | ||
set +e | ||
if [ "$( uname -s )" == "Darwin" -a -n "$( which brew )" ]; then | ||
jenv_prefix="$( brew --prefix jenv )" |
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.
jenv_prefix="$( brew --prefix jenv )" | |
jenv_prefix="$(brew --prefix)/opt/jenv" |
While your invocation is correct, I’d suggest this improvement for performance.
On my 2017 MacBook Pro, this consistently saves over 700 ms:
$ time brew --prefix
/usr/local
real 0m0.038s
user 0m0.016s
sys 0m0.017s
vs.
$ time brew --prefix jenv
/usr/local/opt/jenv
real 0m0.708s
user 0m0.499s
sys 0m0.185s
These savings add up when you open several Terminal windows at once, which Terminal.app
does after e. g. a crash or reboot.
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.
Thank for the proposition.
I am working on it.
I work on another way to enable the homebrew support (see https://github.com/jenv/jenv/tree/feature-homebrew )
In order to enable it, you will pass another parameter in the jenv init
eval (jenv init --homebrew -)
I also add a way to update the plugin, as the symlink are currently also targeting old location in homebrew after an update ( #232 ).
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.
What do you think ? should be ok to add extra parameter to enable homebrew support?
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.
Thanks so much @gcuisinier!
Would you also accept a JENV_INSTALL_DIR
environment variable instead of a --homebrew
switch?
The thing is, Homebrew can’t automatically modify user profiles. We can control the invocation via the existing jenv
shim though. (But only for all of jenv
, not for e. g. jenv init
.)
That would be great because it would allow Homebrew users to get the fix automatically.
How do you feel about that?
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.
Would you also accept a JENV_INSTALL_DIR environment variable instead of a --homebrew switch?
Not sure to understand the point.
But if I well understand, you want to have the fix automatically "used" for anybody using homebrew, without having to modify their .bash_profile from
eval $(jenv init -)
to eval $(jenv init --homebrew -)
?
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.
@gcuisinier Exactly, yes, that’s the point!
Homebrew never modifies a user profile.
But injecting a variable is fine, and we can do it automatically.
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.
Ok, I understand.
But not sure to see what do you mean by "injecting a variables" but without modifiying the user profile.
Today, to install jenv, you have to add this jenv init command. Homebrew itself does not do that.
And if you want to define JENV_INSTALL_DIR before init, you will also need to do it manually no ? And homebrew will not help neither.
So please if you have advice, it will be very welcome :)
For macOS and the Homebrew package manager, get the installation
directory from the
brew --prefix jenv
command instead ofderiving the path with
abs_dirname()
.This will hopefully address the concerns I raised in #260