Skip to content
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

realpath on mac OS #109

Closed
canalet0 opened this issue Oct 2, 2020 · 9 comments · Fixed by #114
Closed

realpath on mac OS #109

canalet0 opened this issue Oct 2, 2020 · 9 comments · Fixed by #114

Comments

@canalet0
Copy link

canalet0 commented Oct 2, 2020

when i put the script to change JAVA_HOME the console output this:
asdf_update_java_home:5: command not found: realpath

There are some similar issues about the use of realpath on Mac OS, in workaround i have installed coreutils with:
brew install coreutils

@fcrespo82
Copy link
Contributor

Paging @halcyon and @joschi. In another computer running macOS I had the same problem as @canalet0 when trying to installing a java version using the latest version with "java_macos_integration_enable = yes"

I think is a good idea to put coreutils as a dependency for macOS. What do you think?

@joschi
Copy link
Contributor

joschi commented Nov 17, 2020

I think is a good idea to put coreutils as a dependency for macOS. What do you think?

IMHO it would be great if we could keep coreutils as an optional dependency, i. e. use realpath (or grealpath) if it exists and have fallback otherwise.

Maybe this could work:

# DIR="$( cd -P "$( dirname "../../Users/./joschi/.asdf/installs/java/adoptopenjdk-15.0.1+9/bin/java" )" && pwd )"
# echo $DIR
/Users/joschi/.asdf/installs/java/adoptopenjdk-15.0.1+9/bin

@fcrespo82
Copy link
Contributor

Yep, this looks like a better approach. I was not aware of that cd command flag.

Would then realpath or grealpath be of any use? Wouldn't be better to stick with your proposed solution in all cases?

@joschi
Copy link
Contributor

joschi commented Nov 18, 2020

Would then realpath or grealpath be of any use? Wouldn't be better to stick with your proposed solution in all cases?

It should work on macOS, *BSD, and Linux with bash and zsh.
@halcyon Any opinion on which one to prefer?

For completeness:

Syntax 
      cd [-L|-P] [dir]

Key
   -P   Use the physical directory structure instead of following symbolic links
        (see also the -P option to the set builtin command)

   -L   Force symbolic links to be followed

@halcyon
Copy link
Owner

halcyon commented Nov 18, 2020

@joschi I prefer your approach. I like that it helps increase our ability to run on other platforms.

@fcrespo82
Copy link
Contributor

Do you want me to open a PR making those changes?

@halcyon
Copy link
Owner

halcyon commented Nov 18, 2020 via email

@jlurena
Copy link

jlurena commented Nov 29, 2020

Until that is merged, I've updated my zshrc to include

# TODO can be removed once https://github.com/halcyon/asdf-java/pull/114/files is merged
function absolute_dir_path {
    local absolute_path
    absolute_path="$( cd -P "$( dirname "$1" )" && pwd )"
    echo "$absolute_path"
}
alias realpath=absolute_dir_path

@mb-genvis
Copy link

# rest of .zshrc ...

. $HOME/.asdf/asdf.sh
# append completions to fpath
fpath=(${ASDF_DIR}/completions $fpath)

# java/android SDK tools
# . ~/.asdf/plugins/java/set-java-home.zsh
export JAVA_HOME="$( cd -P "$(dirname  $(dirname $(asdf which java) ))" && pwd )"

... rest of compinit etc...

I did this for the moment to get it working, I couldn't get the realpath substitution command to work on zsh/ohmyzsh on catalina via iterm2. This works for me and my flutter/android buildchain is now seeing the JAVA_HOME correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants