Sdkman-cli: In ZSH show zsh: command not found: sdk

Created on 7 Nov 2017  ·  18Comments  ·  Source: sdkman/sdkman-cli

In my Macbook pro, on zsh type "sdk" show zsh: command not found: sdk

then i enter :curl -s "https://get.sdkman.io" | bash it will work again.

but when i close this terminal and start a new one , it's show command not found: sdk again.

how to solve this ?

Most helpful comment

For bash, sdkman appends the following to your ~/.bashrc
`

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

export SDKMAN_DIR="/home/USER/.sdkman"
[[ -s "/home/USER/.sdkman/bin/sdkman-init.sh" ]] && source "/home/USER/.sdkman/bin/sdkman-init.sh"
`
(where USER is your username)

Just copy this on to the end of the ~/.zshrc and it should work just fine.

All 18 comments

For bash, sdkman appends the following to your ~/.bashrc
`

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

export SDKMAN_DIR="/home/USER/.sdkman"
[[ -s "/home/USER/.sdkman/bin/sdkman-init.sh" ]] && source "/home/USER/.sdkman/bin/sdkman-init.sh"
`
(where USER is your username)

Just copy this on to the end of the ~/.zshrc and it should work just fine.

Can you confirm that you have this snippet? This should have been appended automatically to the .zshrc file when you installed sdkman.

@marc0der it happens quite often with oh-my-zsh that an update is reverting that file to some old backup, and those lines need to be manually added back.

Ah no, I copied it manually since I also had the same problem. (Although I had installed sdkman before zsh)

I also use oh-my-zsh but have never had it reverting my changes to .zshrc.
Let me know if you see this happening again.

On Thu, 23 Nov 2017, 14:09 meltzerpete, notifications@github.com wrote:

Ah no, I copied it manually since I also had the same problem.


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/sdkman/sdkman-cli/issues/613#issuecomment-346628035,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAI0BtItCOBFg6dIfCJcIixO_AQyLNsQks5s5Xy2gaJpZM4QUZBX
.

jiiiiiin@jiiiiiins-MacBook-Pro  ~/.oh-my-zsh/custom/plugins   master  source ~/.zshrc
/Users/jiiiiiin/.zshrc:120: parse error near `[['
jiiiiiin@jiiiiiins-MacBook-Pro  ~/.oh-my-zsh/custom/plugins   master 

why?

.zshrc add:

SDKMAN_DIR="/home/jiiiiiin/.sdkman" [[ -s "/home/jiiiiiin/.sdkman/bin/sdkman-init.sh" ]] && source "/home/jiiiiiin/.sdkman/bin/sdkman-init.sh"

jiiiiiin is my mac username

What happens when you source the ~/.sdkman/bin/sdkman-init.sh?

Another experiment, what happens when you manually source your .zshrc?

For some reason, I was having the same problem on my MacBook Pro when doing a clean install of sdkman.

I ended up manually adding the snippet that @meltzerpete posted at the end of both my .bashrc and .bash_profile files.

That took care of it 🍻

This does not work for me despite following suggestions. See below:

screen shot 2017-12-20 at 11 55 01 am

Full .zshrc below:

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

[ -s "/Users/charper/.jabba/jabba.sh" ] && source "/Users/charper/.jabba/jabba.sh"

#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/Users/charper/.sdkman"
[[ -s "/Users/charper/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/charper/.sdkman/bin/sdkman-init.sh"

The clue is in the title bar of your shell: it's a bash shell, not zsh. On
Linux we use the chsh command to permanently switch to a different shell.
Not sure if the same is true for OSX.

On Wed, 20 Dec 2017, 16:56 Connor, notifications@github.com wrote:

This does not work for me despite following suggestions. See below:

[image: screen shot 2017-12-20 at 11 55 01 am]
https://user-images.githubusercontent.com/9372848/34218638-b724a8ee-e57c-11e7-93b6-55cc643746e2.png

Full .zshrc below:

Add RVM to PATH for scripting. Make sure this is the last PATH variable change.

export PATH="$PATH:$HOME/.rvm/bin"

[ -s "/Users/charper/.jabba/jabba.sh" ] && source "/Users/charper/.jabba/jabba.sh"

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

export SDKMAN_DIR="/Users/charper/.sdkman"
[[ -s "/Users/charper/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/charper/.sdkman/bin/sdkman-init.sh"


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/sdkman/sdkman-cli/issues/613#issuecomment-353119806,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAI0BmaS0fsxMc1kCIUHfKajSV7r205Iks5tCTwzgaJpZM4QUZBX
.

I needed to include this in my .bash_profile - looks like it's working good now

Excellent news! Closing this issue.

Just copy this on to the end of the ~/.zshrc and it should work just fine.

Added some improvements:

#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! export SDKMAN_DIR="$HOME/.sdkman" [[ -s "$SDKMAN_DIR/bin/sdkman-init.sh" ]] && source "$SDKMAN_DIR/bin/sdkman-init.sh"

i belive that you was using sdk on bash, you just have to copy the line in the .bash_profile , that export sdk , and past on the .zshrc, and refresh

Just execute this line: works fine for me Ubuntu 19.04

echo 'source "$HOME/.sdkman/bin/sdkman-init.sh"' >> ~/.zshrc

Very simple pour MAC

step 1:

vim ~/.zshrc

step 2:(Add at the end of the file)

source ~/.bash_profile;

step 3:(Execution shell)

> source ~/.bash_profile

You can use sdkman :
➜ sdk

We periodically need to update the local cache. Please run:

$ sdk update

==== BROADCAST =================================================================

  • 2020-09-21: jbang 0.47.1 now available for download.
  • 2020-09-20: jbang 0.46.1 @jbangdev https://git.io/JUEb5

* 2020-09-20: jbang 0.46.0 @jbangdev https://git.io/JUEHD

Usage: sdk [candidate] [version]
sdk offline

commands:
install or i [version] [local-path]
uninstall or rm
list or ls [candidate]
use or u
default or d [version]
home or h
env or e [init]
current or c [candidate]
upgrade or ug [candidate]
version or v
broadcast or b
help
offline [enable|disable]
selfupdate [force]
update
flush

candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc.
use list command for comprehensive list of candidates
eg: $ sdk list
version : where optional, defaults to latest stable if not provided
eg: $ sdk install groovy
local-path : optional path to an existing local installation
eg: $ sdk install groovy 2.4.13-local /opt/groovy-2.4.13

@xadimousalih I really wouldn't recommend sourcing your bash profile from your zsh profile. Rather just add the following snippet to the end of .zshrc:

# SDKMAN!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"

Make sure this is at the very end.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scuba10steve picture scuba10steve  ·  7Comments

cmoulliard picture cmoulliard  ·  4Comments

OmidTahouri picture OmidTahouri  ·  7Comments

Omnipresent picture Omnipresent  ·  6Comments

andvgal picture andvgal  ·  7Comments