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

jenv add "ln No such file or directory" #167

Closed
Reapor-Yurnero opened this issue Apr 7, 2017 · 22 comments
Closed

jenv add "ln No such file or directory" #167

Reapor-Yurnero opened this issue Apr 7, 2017 · 22 comments

Comments

@Reapor-Yurnero
Copy link

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.

@gcuisinier
Copy link
Collaborator

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

@bjenning04
Copy link

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.

@jschavey
Copy link

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

@Reapor-Yurnero
Copy link
Author

Thanks for your help!

@swvanderlaan
Copy link

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?

@swvanderlaan
Copy link

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

@MarschildX
Copy link

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.

@Dshosev
Copy link

Dshosev commented May 12, 2020

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

@ghost
Copy link

ghost commented May 15, 2020

@Dshosev
Thank you so much.
It also worked for me.

@gcuisinier
Maybe it would be a good idea to add this command directly into the homebrew jenv installer : mkdir -p ~/.jenv/versions
Also this command :
echo 'eval "$(jenv init -)"' >> ~/.zshrc
And this one too :
echo 'eval "$(jenv init -)"' >> ~/.bashrc
I'm on macOS Catalina 10.15.4

Best regards

@tamimsyed700
Copy link

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

@stephen-murby
Copy link

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

@chrisdoberman
Copy link

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.

@Sleepful
Copy link

Sleepful commented Jun 16, 2022

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

@learnnrepeat
Copy link

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

@cajubelt
Copy link

cajubelt commented Sep 7, 2022

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.

@danielsotopino
Copy link

@cajubelt thank you ! i had the same problem...

@ben-gooding-sky
Copy link

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

@neolikotsi
Copy link

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

@gravelld
Copy link

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

Normally you'd do mkdir -p ~/.jenv/versions to create parent folders as needed. This worked for me.

@mickaeltr
Copy link

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.

@Jonathan0wh
Copy link

I think in the official website https://www.jenv.be/, it should be changed to "Step 1", "Step 2", rather than two section "Installation".

@krisstern
Copy link

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.

I had the exact same issue and solution for upgrading from 0.5.6 to 0.5.7 too with brew.

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

No branches or pull requests