Install java 8 fails on cygwin in some cases #520

Open
jbuhacoff opened this Issue Jan 7, 2017 · 8 comments

Projects

None yet

4 participants

@jbuhacoff

On Cygwin, tried sdk install java and got following output:

$ sdk install java

Oracle requires that you agree with the Oracle Binary Code License Agreement
prior to installation. The license agreement can be found at:

  http://www.oracle.com/technetwork/java/javase/terms/license/index.html

Do you agree to the terms of this agreement? (Y/n): Y


Downloading: java 8u111

In progress...

######################################################################## 100.0%

Repackaging java 8u111...
-bash: /home/Jonathan/.sdkman/tmp/mbgywYdNTdwToa040cg3Azu3oUSUBGsp.bin: Device or resource busy
mv: cannot stat '/cygdrive/c/temp/jdk': No such file or directory

zip error: Nothing to do! (try: zip -qr /home/Jonathan/.sdkman/tmp/mbgywYdNTdwToa040cg3Azu3oUSUBGsp.zip . -i .)

Done repackaging...
mv: cannot stat '/home/Jonathan/.sdkman/tmp/mbgywYdNTdwToa040cg3Azu3oUSUBGsp.zip': No such file or directory
unzip:  cannot find or open /home/Jonathan/.sdkman/archives/java-8u111.zip, /home/Jonathan/.sdkman/archives/java-8u111.zip.zip or /home/Jonathan/.sdkman/archives/java-8u111.zip.ZIP.
rm: cannot remove '/home/Jonathan/.sdkman/archives/java-8u111.zip': No such file or directory

Stop! The archive was corrupt and has been removed! Please try installing again.

To check device or resource busy, I ran handle command for windows:

C:\>handle mbgywYdNTdwToa040cg3Azu3oUSUBGsp.bin

Nthandle v4.1 - Handle viewer
Copyright (C) 1997-2016 Mark Russinovich
Sysinternals - www.sysinternals.com

bash.exe           pid: 8008   type: File           3D0: C:\Users\Jonathan\.sdkman\tmp\mbgywYdNTdwToa040cg3Azu3oUSUBGsp.bin

And then I ran ps within Cygwin:

$ ps
      PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
     1948   13268    1948       8008  pty3      197609 19:57:39 /usr/bin/bash
     7532   12708    7532       8256  pty2      197609 02:13:00 /usr/bin/ps
     1044    1164    1044      15392  pty0      197609 19:28:45 /usr/bin/bash
    13268       1   13268      13268  ?         197609 19:57:39 /usr/bin/mintty
    14852       1   14852      14852  ?         197609 19:51:14 /usr/bin/mintty
    12708   14852   12708       4204  pty2      197609 19:51:14 /usr/bin/bash
     1164       1    1164       1164  ?         197609 19:28:45 /usr/bin/mintty
@marc0der
Member
marc0der commented Jan 7, 2017

Thanks for reporting this issue. So far we have had many successful installations of Java on cygwin, so it might only be an anomaly on your environment.

Lets keep this open in case others are also seeing this.

@ecirtap
ecirtap commented Jan 8, 2017

Hello, thanks for leaving this issue opened; I encountered the same problem:

$ sdk install java

Oracle requires that you agree with the Oracle Binary Code License Agreement
prior to installation. The license agreement can be found at:

  http://www.oracle.com/technetwork/java/javase/terms/license/index.html

Do you agree to the terms of this agreement? (Y/n):


Downloading: java 8u111

In progress...

######################################################################## 100,0%

Repackaging java 8u111...
-bash: /home/patri/.sdkman/tmp/eQ6x6SakpNulzdTag1yvfV0HbG7DrldS.bin: Permission denied
mv: impossible d'évaluer '/cygdrive/c/temp/jdk': No such file or directory

zip error: Nothing to do! (try: zip -qr /home/patri/.sdkman/tmp/eQ6x6SakpNulzdTag1yvfV0HbG7DrldS.zip . -i .)

Done repackaging...
mv: impossible d'évaluer '/home/patri/.sdkman/tmp/eQ6x6SakpNulzdTag1yvfV0HbG7DrldS.zip': No such file or directory
unzip:  cannot find or open /home/patri/.sdkman/archives/java-8u111.zip, /home/patri/.sdkman/archives/java-8u111.zip.zip or /home/patri/.sdkman/archives/java-8u111.zip.ZIP.
rm: impossible de supprimer '/home/patri/.sdkman/archives/java-8u111.zip': No such file or directory

Stop! The archive was corrupt and has been removed! Please try installing again.

Win10 pro, cygwin64, SDKMAN 5.5.2+183

@ecirtap
ecirtap commented Jan 8, 2017 edited

I think it is due to UAC (enabled on my box); a 740 error is returned by strace when it is used to run the downloaded binary (more informative than the permission denied error returned by bash).

Workaround I used: run the same command, but in the context of a Cygwin Window opened "as Administrator".

@marc0der
Member
marc0der commented Jan 8, 2017

I'm not a cygwin expert, but won't that mess up the permissions under you sdkman folder?

@ecirtap
ecirtap commented Jan 8, 2017

Neither do I ... who is an expert of something nowadays :-)

I have just checked that all files under .sdkman are mines (find .sdkman \! -user patri returns no result). The same stands for my whole cygwin account.

I also installed other SDKMAN packages after that (ant, maven, groovyserv) using a normal cygwin window, and it worked.

When cygwin is run "As administrator", it happens that the user and group id remain the same, the difference is that some extra groups are changing, apparently sufficiently enough to allow the execution of commands such as the downloaded binary. You can see that by yourself just by typing the id command in both cases (normal user or as administrator).

By the way, if UAC is disabled, you execute silently a ton of commands without being warned anymore that you are using some admin rights to run them successfully. That should be the explanation why it works for some people and not for others.

@ewoudwerkman

It seems to me it has something to do with SDKMAN trying to repackage the downloaded file and trying to move the file to /cygdrive/c/temp/jdk while this folder does not exist (at least not on my machine). Does SDKman use the environment settings to determine the correct temp folder? Under cygwin it is /tmp, not /cygdrive/c/temp.

@ewoudwerkman

Have a look at the java_*_hook.sh script. C:\temp\jdk is hardcoded in there.

@ewoudwerkman

And yes, it seems you need to run this file as Administrator

@marc0der marc0der changed the title from install java 8 failed to Install java 8 fails on cygwin in some cases Jan 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment