Where is the `sdk` command installed for sdkman
Asked Answered
A

2

8

I just installed sdkman for installing grails on my machine (MacOS). When I run which sdk command I don't get any output. But when I run the sdk help command the shell is able to resolve it and give the right output. I checked all the directories mentioned in $PATH environment variable but I could not find any executable sdk. So my question is how is shell able to resolve the sdk command?

Note: I also checked in Ubuntu and I see the same behavior.

enter image description here enter image description here

Adan answered 8/7, 2017 at 16:18 Comment(2)
which is almost never the right command. Use type insteadSchleswigholstein
Thank you! Apparently its a function defined in a source file.Adan
A
1

OK. So I found it out. As @that-other-guy mentioned in the comment above, I used type -a instead of which, which showed me that it was a function defined.

Adan answered 9/7, 2017 at 2:47 Comment(0)
D
4

As you mentioned correctly "sdk" is not a command, its a declared function created by sdkman-main.sh (in ~/.sdkman/src) once called from ~/.sdkman/bin/sdkman-init.sh

This is the reason why the installation page of sdkman asks for appending the following steps in the .bash_profile which declares this function each time the bash profile is loaded :

#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!

[[ -s "/home/dudette/.sdkman/bin/sdkman-init.sh" ]] && source "/home/dudette/.sdkman/bin/sdkman-init.sh"

This is also the reason "which" command doesn't pick it up as it checks for the installed commands on the linux PATH

Deglutinate answered 13/11, 2018 at 5:6 Comment(1)
Why must it be at the end of the file? Why can't I add other things to PATH after it?Tautologism
A
1

OK. So I found it out. As @that-other-guy mentioned in the comment above, I used type -a instead of which, which showed me that it was a function defined.

Adan answered 9/7, 2017 at 2:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.