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

Executable not found in path #53

Closed
aprasadh opened this issue Aug 13, 2018 · 28 comments
Closed

Executable not found in path #53

aprasadh opened this issue Aug 13, 2018 · 28 comments

Comments

@aprasadh
Copy link

I tried running mkcert version 1.1.0 in windows. I got the following error.

$ mkcert-v1.1.0-windows-amd64.exe example.org
Using the local CA at "C:\Users\XXXXX\AppData\Local\mkcert"
ERROR: failed to execute "keytool -list": exec: "": executable file not found in %PATH%

@ajsb85
Copy link

ajsb85 commented Aug 13, 2018

mkcert-v1.1.0-windows-amd64.exe -install
Using the local CA at "C:\Users\XXXXX\AppData\Local\mkcert" ✨
The local CA is now installed in the system trust store! ⚡️
Note: Firefox support is not available on your platform. ℹ️
ERROR: failed to execute "keytool -list": exec: "": executable file not found in %PATH%

keytool -list
keytool error: java.lang.Exception: Keystore file does not exist: C:\Users\alexa\.keystore

@daniellockard
Copy link

That means you don't have java's keytool installed. Might want to install it.

@aprasadh
Copy link
Author

I ran keytool -list and I got this

keytool error: java.lang.Exception: Keystore file does not exist: C:\Users\XXXXX\.keystore

@nickkaczmarek
Copy link

I'm having the same issue and getting the same response as @aprasadh from "%JAVA_HOME%\bin\keytool.exe" -list as well as keytool -list. This isn't something I recall having to do for mkcert on macos or ubuntu.

@nickkaczmarek
Copy link

@cretz Is this something you encountered in your local instance of mkcert? Seems to be looking for a java tool to created a keystore.

@cretz
Copy link
Contributor

cretz commented Aug 13, 2018

@nickkaczmarek - No it is not, and I use the JVM frequently. I didn't even know that added the root in my Java keystore, heh. This appears to be a new thing @adamdecaf added in #38. There appear to be some things wrong such as in its java check it calls keytool even if hasKeytool is false. Also, it assumes it's a JDK and not a JRE by its cert path lookup.

It's going to happen on all Windows OS's, because it looks for bin/keytool instead of bin/keytool.exe (Windows support was just merged after that). So someone needs to Windows-ify it, change the checkJava to stop assuming the keytool is there, and change the cert path lookup to respect JREs instead of just JDKs.

@nickkaczmarek
Copy link

I saw that jre path also and thought it looked fishy. I ended up removing Java from my machine to get past it but fixing the project is probably a more sustainable route.

@adamdecaf
Copy link
Contributor

Yep. I missed that before, sorry. I don't have a windows machine to test with, but could y'all try this patch?

#54

@nickkaczmarek
Copy link

@adamdecaf that might work, but I think the jre path might be problematic as well. I can take a look tomorrow if no one else does.

@adamdecaf
Copy link
Contributor

Ah okay. If the install path for java (or the extracted file structure) is different for windows we can probably work around the differences.

@cretz
Copy link
Contributor

cretz commented Aug 13, 2018

If the install path for java (or the extracted file structure) is different for windows

It's not. The difference is JRE vs JDK.

@adamdecaf
Copy link
Contributor

That makes sense. Do you know if the structure is the same across OS's? We could just check for both paths.

@cretz
Copy link
Contributor

cretz commented Aug 13, 2018

I believe so, yes

@Suleman-Elahi
Copy link

image

same here

@zanjs
Copy link

zanjs commented Aug 14, 2018

ERROR: failed to execute "keytool -list": exec: "": executable file not found in %PATH%

me too

@nickkaczmarek
Copy link

So @cretz, it looks like when you implemented the windows functionality, the java change was unnecessary for a CA to be created in windows. Is it worth allowing an opt out of using java? I'm not sure how the keystore works, but it seems to be unnecessary. @adamdecaf or @FiloSottile, what do you think about a java opt out? I really don't know how this works, but I'd prefer to have mkcert not use java even if it's installed on my machine.

@adamdecaf
Copy link
Contributor

Why would we opt out of java? It's been useful at a previous employer to add the company CA into the truststore.

@nickkaczmarek
Copy link

nickkaczmarek commented Aug 14, 2018

I was referring to having the option to choose to not use it when generating a CA or certificate. My knowledge is really lacking around what mkcert really does so forgive me if I'm super off base and my specific use case is to generate certificates for local development. I'm simply saying that this worked without using Java when @cretz added windows support so in theory it should work without using Java and therefore possible to pass an option to not use Java when installing a CA or creating certificates.

Edit:
So for instance, allow a user to pass an option to use the native truststore rather than the java one, even if the JAVA_HOME environment variable is set. I'm looking into how this can be done because I have to have java installed on my work machine, but I'd rather use the native truststore to handle this action.

@FiloSottile
Copy link
Owner

To be clear, when JAVA_HOME is set, both the Java and the system trust stores have the certificate installed. Would you still want to selectively disable that, even if this issue was fixed? If so, please open a separate issue for that feature request.

@nickkaczmarek
Copy link

In that case, no. I got around this pre @adamdecaf suggested fix by removing JAVA_HOME and some other path specific stuff so this could give me an opportunity to see what a fresh install of java installs and sets so I could contribute to what @adamdecaf is working on in #54. I'm not sure having the option to selectively disable the java truststore step is necessary if it works because my impression is these truststore files are OS specific and the only reason to have the opt-out capability would be for this particular use case.

@nickkaczmarek
Copy link

In any case, I have this working on my mac at home and windows pc at work and I'm so glad there is such a simple tool to do this. I've seen there are others, but this piques my interest especially since it's written in go.

@nickkaczmarek
Copy link

@FiloSottile @adamdecaf I don't know if this is the correct way of doing it, but as a stop gap for the people experiencing this issue until @adamdecaf has #54 finished and accepted, the temporary solution seems to be delete or rename JAVA_HOME and run mkcert -install and mkcert hostname again.

@FiloSottile
Copy link
Owner

Thanks everyone, let me know if v1.1.1 fixes this.

@wikijm
Copy link

wikijm commented Aug 23, 2018

For Windows installation, you can use those commands:

REM Define %JAVA_HOME% variable
    for /d %%i in ("\Program Files\Java\jdk*") do set JAVA_HOME=%%i

REM Add %JAVA_HOME% VARIABLE to %PATH% variable
    setx PATH "%JAVA_HOME%\bin";"%PATH%" -m

@OwenMelbz
Copy link

I had the same issue today on Mojave.

I ended up manually running keytool to kick it into action by doing keytool -genkeypair which fixed the keytool error: java.lang.Exception: Keystore file does not exist error.

However then still had the odd JAVA_HOME issue - I used a pretty dodgy workaround and added an bash alias of alias mkcert="unset JAVA_HOME && mkcert"

So just for that terminal session it would unset it - and it seems to then work!

@noway
Copy link

noway commented Apr 7, 2022

unset JAVA_HOME did the trick for me

@pedrovgs
Copy link

pedrovgs commented Jul 6, 2022

I just deleted JAVA_HOME env var and it just worked like a charm. Thanks!

@Herz3h
Copy link

Herz3h commented Nov 17, 2023

ty @pedrovgs

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