Issue2350

classification
Title: Installer errors on ensurepip
Type: Severity: normal
Components: Installer Versions: Jython 2.7
Milestone: Jython 2.7.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: joshfriend, lvjp, zyasoft
Priority: high Keywords:

Created on 2015-05-04.13:45:04 by joshfriend, last changed 2016-02-09.23:49:52 by zyasoft.

Messages
msg10008 (view) Author: Josh Friend (joshfriend) Date: 2015-05-04.13:45:03
I installed from https://repo1.maven.org/maven2/org/python/jython-installer/2.7.0/jython-installer-2.7.0.jar
using the console/silent options (how pyenv installs it):

    $ java -jar jython-installer-2.7.0.jar -s -d jython
    Performing silent installation
     10 %
     20 %
     30 %
     40 %
     50 %
     60 %
     70 %
    Generating start scripts ...
    Installing pip and setuptools
     90 %
    java.io.IOException: Cannot run program "jython/bin/jython" (in directory "jython/bin"): error=20, Not a directory
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
        at org.python.util.install.ChildProcess.run(ChildProcess.java:272)
        at org.python.util.install.JarInstaller.ensurepip(JarInstaller.java:187)
        at org.python.util.install.JarInstaller.inflate(JarInstaller.java:152)
        at org.python.util.install.ConsoleInstaller.install(ConsoleInstaller.java:66)
        at org.python.util.install.Installation.internalMain(Installation.java:389)
        at org.python.util.install.Installation.main(Installation.java:43)
    Caused by: java.io.IOException: error=20, Not a directory
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
        at java.lang.ProcessImpl.start(ProcessImpl.java:134)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        ... 6 more
     100 %
    Congratulations! You successfully installed Jython 2.7.0 to directory /Users/josh/jython.

Using the GUI installer throws a different error:

    Traceback (most recent call last):
      File "/Users/josh/jython/Lib/runpy.py", line 161, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/Users/josh/jython/Lib/runpy.py", line 72, in _run_code
        exec code in run_globals
      File "/Users/josh/jython/Lib/ensurepip/__main__.py", line 4, in <module>
        ensurepip._main()
      File "/Users/josh/jython/Lib/ensurepip/__init__.py", line 220, in _main
        bootstrap(
      File "/Users/josh/jython/Lib/ensurepip/__init__.py", line 123, in bootstrap
        _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
      File "/Users/josh/jython/Lib/ensurepip/__init__.py", line 45, in _run_pip
        import pip
      File "/var/folders/63/g3w008712l1g6k3_5lmt4vl00000gn/T/tmp_NehkC/pip-1.6-py2.py3-none-any.whl/pip/__init__.py", line 10, in <module>
      File "/var/folders/63/g3w008712l1g6k3_5lmt4vl00000gn/T/tmp_NehkC/pip-1.6-py2.py3-none-any.whl/pip/util.py", line 17, in <module>
      File "/var/folders/63/g3w008712l1g6k3_5lmt4vl00000gn/T/tmp_NehkC/pip-1.6-py2.py3-none-any.whl/pip/locations.py", line 109, in <module>
      File "/var/folders/63/g3w008712l1g6k3_5lmt4vl00000gn/T/tmp_NehkC/pip-1.6-py2.py3-none-any.whl/pip/locations.py", line 71, in _get_build_prefix
      File "/var/folders/63/g3w008712l1g6k3_5lmt4vl00000gn/T/tmp_NehkC/pip-1.6-py2.py3-none-any.whl/pip/locations.py", line 66, in __get_username
      File "/Users/josh/jython/Lib/pwd.py", line 60, in getpwuid
        return struct_passwd(entry)
      File "/Users/josh/jython/Lib/pwd.py", line 36, in __new__
        pwd = (newStringOrUnicode(pwd.loginName), newStringOrUnicode(pwd.password), int(pwd.UID),
    NotImplementedError: passwd.pw_passwd unimplemented

Makes me think the cli installer has a race condition somewhere since it fails before the ensurepip module while the GUI installer fails inside ensurepip.

Either way, running `jython -m ensurepip` after the installer has finished works correctly.
msg10009 (view) Author: Jim Baker (zyasoft) Date: 2015-05-04.14:11:32
I can reproduce this problem, but there's an easy workaround: specify the path of the installed directory. So use

java -jar ~/Downloads/jython-installer-2.7.0.jar -s -d ~/jython

instead of

java -jar ~/Downloads/jython-installer-2.7.0.jar -s -d jython

re the GUI installer, I need more details.
msg10010 (view) Author: Josh Friend (joshfriend) Date: 2015-05-04.15:25:21
I am using OSX 10.10.3 with JDK 1.8.0_45

Relevant environment variables:

    $ env | grep -i java
    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
    $ env | grep -i jython
    # nothing...

Installed using the full path to the jar and install dir as you recommended:

    $ java -jar $PWD/jython-installer-2.7.0.jar -s -d $PWD/jython

which throws same error as in the GUI installer now, but pip is still installed.

When I ran the GUI installer (`java -jar $PWD/jython-installer-2.7.0.jar`), I used all default settings.

I also just verified that the issue is not present when I install under ubuntu trusty 64bit.

Happy to provide any other info you need. Thanks!
msg10011 (view) Author: Jim Baker (zyasoft) Date: 2015-05-04.15:39:49
Also on OSX 10.10.3 with JDK 1.8.0_45, no JAVA_* or JYTHON_* env variables set in advance:

jimbaker:~ jbaker$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
jimbaker:~ jbaker$ java -jar ~/Downloads/jython-installer-2.7.0.jar -s -d $PWD/jython
Performing silent installation
 10 %
 20 %
 30 %
 40 %
 50 %
 60 %
 70 %
Generating start scripts ...
Installing pip and setuptools
 90 %
Ignoring indexes: https://pypi.python.org/simple/
Downloading/unpacking setuptools
Downloading/unpacking pip
Installing collected packages: setuptools, pip
Successfully installed setuptools pip
Cleaning up...
 100 %
Congratulations! You successfully installed Jython 2.7.0 to directory /Users/jbaker/jython.
msg10073 (view) Author: Verdoïa Laurent (lvjp) Date: 2015-05-21.15:21:25
We can see that in JarInstaller.java on line 179 that the installer change current directory to path/to/install/bin before execute path/to/install/bin/jython.

If we go under path/to/instal/bin just run directly jyhon is sufficient.

https://hg.python.org/jython/file/77e0e7c87bd1/installer/src/java/org/python/util/install/JarInstaller.java#l179

The source:
String launcher = bindir.resolve("jython").toString();
String command[] = new String[]{ launcher, "-m", "ensurepip"};
ChildProcess childProcess = new ChildProcess(command);
childProcess.setCWD(bindir);
errorCode = childProcess.run();

I suggest to make command like that:
String command[] = new String[] { "jython", "-m", "ensurepip" };
msg10551 (view) Author: Jim Baker (zyasoft) Date: 2015-12-23.20:28:53
Let's get this in 2.7.1!
msg10679 (view) Author: Jim Baker (zyasoft) Date: 2016-02-02.03:38:06
Fixed as of https://hg.python.org/jython/rev/b6735606c13d
msg10682 (view) Author: Jim Baker (zyasoft) Date: 2016-02-02.04:24:14
This fix did cause a regression on Windows, so use absolute paths there. See https://hg.python.org/jython/rev/8e264837ef27

We need to revisit automated testing for the installer, although that also should mean a Windows target!
History
Date User Action Args
2016-02-09 23:49:52zyasoftsetstatus: pending -> closed
2016-02-02 04:24:14zyasoftsetmessages: + msg10682
2016-02-02 03:38:06zyasoftsetstatus: open -> pending
resolution: accepted -> fixed
messages: + msg10679
2015-12-23 20:28:54zyasoftsetpriority: high
messages: + msg10551
2015-05-21 15:21:25lvjpsetnosy: + lvjp
messages: + msg10073
2015-05-04 15:39:49zyasoftsetmessages: + msg10011
2015-05-04 15:25:22joshfriendsetmessages: + msg10010
2015-05-04 14:11:32zyasoftsetresolution: accepted
messages: + msg10009
nosy: + zyasoft
milestone: Jython 2.7.1
2015-05-04 13:45:04joshfriendcreate