jenv: jenv add "ln No such file or directory"

MacOS 10.12.4

I used Homebrew to install java with

brew update
brew cast install java

and I checked the version of it as following.

xxxx-MacBook-Pro:Home reapor.yurnero$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

Then I tried jenv add jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home but it shows ln: /Users/reapor.yurnero/.jenv/versions/oracle64-1.8.0.121: No such file or directory So I’m confused which procedure am I wrong.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 77
  • Comments: 21

Most upvoted comments

Do you have add eval $(jenv init -) in you shell init (bashrc, zshrc) ? And close/reopen a shell ?

I am running into the same error. The issue is that there is no ~/.jenv/versions folder. As a workaround, I added the folder structure, and then jenv add works fine after that.

Confirming this issue. Approriate line is added to profile but jenv doctor states not running in shell even after restart. mkdir ~/.jenv/versions resolves.

Ah, yes, it should be like so in my .bashrc:


export JENV_ROOT="/usr/local/Cellar/jenv/"

if which jenv > /dev/null; 
	then eval "$(jenv init -)"; 
fi

Then doing jenv add works!

jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/
oracle64-1.8.0.201 added
1.8.0.201 added
1.8 added

Had the same Issue. mkdir -p ~/.jenv/versions did the trick. I’m using zsh and didn’t need to add some PATH.

Best Regards

I was getting a similar issue-- after attempting to add java 11 with jenv and use it, I would get an error like:

/Users/charlie/.jenv/shims/java: line 21: /usr/local/Cellar/jenv/0.5.4/libexec/libexec/jenv: No such file or directory

The other solutions posted here were not sufficient for my issue. It could be reproduced by just typing java --version in the terminal.

How I solved it:

When I looked in /usr/local/Cellar/jenv/, I found that there was indeed no directory 0.5.4, but there was one titled 0.5.5_2. I opened up /Users/charlie/.jenv/shims/java with a text editor, replaced 0.5.4 with 0.5.5_2, and the problem was solved. I am now able to use java 11.

Hope this helps in case anyone else runs into the same thing.

I meat the same problem. And I have solved it. Here is the website of Jenv. After you installed the Jenv, you need to init the $(jenv init -). How to init it has written at website. As for me, I use macOS with zsh. So I init that with the following commands: $ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc $ echo 'eval "$(jenv init -)"' >> ~/.zshrc After initiation, restart your zsh/shell or open a new window of zsh/shell. Now you can add java successfully.

On OSX Big Sur v11.2.3 I have had to > mkdir ~/.jenv then > mkdir ~/.jenv/versions as neither directory had been created.

Same error happened to me after upgrading from 0.5.5_2 to 0.5.6 with brew. I fixed it by manually editing the path in ~/.jenv/shims/java.

Just had the issue with the directory structure, 2022, had to mkdir ~/.jenv/versions I guess I missed these:

$ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
$ echo 'eval "$(jenv init -)"' >> ~/.zshrc

I was getting a similar issue-- after attempting to add java 11 with jenv and use it, I would get an error like:

/Users/charlie/.jenv/shims/java: line 21: /usr/local/Cellar/jenv/0.5.4/libexec/libexec/jenv: No such file or directory

Thanks, this fixed it for me too, it originated after running brew upgrade to update everything

@Dshosev this trick mkdir -p ~/.jenv/versions worked for me on Fedora Linux as well with bash.

I was getting a similar issue-- after attempting to add java 11 with jenv and use it, I would get an error like:

/Users/charlie/.jenv/shims/java: line 21: /usr/local/Cellar/jenv/0.5.4/libexec/libexec/jenv: No such file or directory

this worked for me

jenv rehash

Actually, I run into the same issue and the solution by @jschavey is not working. I’ve added the initiation lines to my .bashrc file:

if which jenv > /dev/null; 
	then eval "$(jenv init -)"; 
fi

export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home"
export PATH="$JAVA_HOME/bin:$PATH"
export JENV_ROOT="/usr/local/bin/jenv"

This throws this error:

source .bash_profile
mkdir: /usr/local/bin/jenv/shims: Not a directory
mkdir: /usr/local/bin/jenv/plugins: Not a directory
mkdir: /usr/local/bin/jenv/versions: Not a directory

Checking out the directory shows this:

ls -lh /usr/local/bin/jenv
lrwxr-xr-x  1 swvanderlaan  admin    29B Jan 16 11:41 /usr/local/bin/jenv -> ../Cellar/jenv/0.4.4/bin/jenv

Hence, since we installed jenv via brew things are stored there. I suspect the re-direct should be to that folder or am I wrong?

For me adding JENV_ROOT=/usr/local/opt/jenv into ~/.zshrc fixed the issue

I meat the same problem. And I have solved it. Here is the website of Jenv. After you installed the Jenv, you need to init the $(jenv init -). How to init it has written at website. As for me, I use macOS with zsh. So I init that with the following commands: $ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc $ echo 'eval "$(jenv init -)"' >> ~/.zshrc After initiation, restart your zsh/shell or open a new window of zsh/shell. Now you can add java successfully.

This worked perfectly. Thank you.