Ticket #2199 (accepted defect)

Opened 3 years ago

Last modified 3 years ago

Rainbow changes Python's sys.executable, breaking 0launch's GUI

Reported by: talex5 Owned by: sascha_silbe
Priority: Normal Milestone:
Component: Rainbow Version: Git as of bugdate
Severity: Minor Keywords:
Cc: mstone Distribution/OS:
Bug Status: Needinfo

Description

$ python -c 'import sys; print sys.executable'
/usr/bin/python

$ sudo rainbow-easy bug python -c "import sys; print sys.executable"
SyntaxError: invalid syntax

$ sudo rainbow-easy bug python
>>> import sys; print sys.executable
/home/test/

The Python docs say:

sys.executable

A string giving the name of the executable binary for the Python interpreter, on systems where this makes sense.

This is using the Ubuntu/Lucid universe rainbow package.

$ apt-cache policy rainbow
rainbow:
  Installed: 0.8.6-1
  Candidate: 0.8.6-1
  Version table:
 *** 0.8.6-1 0
        500 http://gb.archive.ubuntu.com/ubuntu/ lucid/universe Packages
        100 /var/lib/dpkg/status

Change History

Changed 3 years ago by alsroot

  • status_field changed from Unconfirmed to Needinfo

Sorry but I can't find sys.executable invocation in 0sugar sources (and history), what particular usecase you mean?

Changed 3 years ago by talex5

(sorry, maybe 0sugar is the wrong component but I couldn't find a better one)

zeroinstall/injector/download.py uses sys.executable to run a new copy of Python. This doesn't work under rainbow, because sys.executable is wrong for some reason.

e.g.

Use rainbow-easy to get a new shell. Run:

0launch --gui http://rox.sourceforge.net/2005/interfaces/Edit

This gives the error "[Errno 13] Permission denied".

Changed 3 years ago by sascha_silbe

  • status changed from new to accepted
  • severity changed from Unspecified to Minor
  • cc mstone added
  • component changed from 0sugar to Rainbow
  • priority changed from Unspecified by Maintainer to Normal
  • version changed from Unspecified to Git as of bugdate
  • milestone Unspecified by Release Team deleted
  • owner changed from alsroot to sascha_silbe
  • distribution Unspecified deleted

What happens is that Rainbow
a) doesn't pass through PATH, but
b) uses execvpe() to look up the executable, passing through argv[0] unresolved.

Python apparently gets confused as it can't find itself using PATH. You can reproduce this without Rainbow:

sascha.silbe@twin:~$ env - python
Python 2.5.2 (r252:60911, Jan 24 2010, 17:44:40) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/home/sascha.silbe/'
>>> 
sascha.silbe@twin:~$ env - PATH="$PATH" python
Python 2.5.2 (r252:60911, Jan 24 2010, 17:44:40) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/usr/bin/python'
>>> 
sascha.silbe@twin:~$ env - /usr/bin/python
Python 2.5.2 (r252:60911, Jan 24 2010, 17:44:40) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/usr/bin/python'
>>> 
sascha.silbe@twin:~$ 

As a workaround you can use an absolute path to call python:

sascha.silbe@twin:~/src/rainbow$ sudo rainbow-easy foo /usr/bin/python
X-ifying isolated uid 10111.
X-ifying envdir /tmp/tmpW-OW3E.
-E XAUTHORITY=/var/spool/rainbow/2/uid_to_home_dir/10111/XAUTHORITY
-E ICEAUTHORITY=/var/spool/rainbow/2/uid_to_home_dir/10111/ICEAUTHORITY
-E USER=10111
-E HOME=/var/spool/rainbow/2/uid_to_home_dir/10111
-E DISPLAY=:0.0
Python 2.5.2 (r252:60911, Jan 24 2010, 17:44:40) 
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/usr/bin/python'
>>> 

I guess the right solution would be to:
a) pass through PATH when using rainbow-easy and
b) look up the executable ourselves, passing the absolute path to both execve() and argv[0].

Michael, what do you think?

Changed 3 years ago by mstone

Passing PATH through rainbow-easy seems like a good solution to Thomas' difficulty. I have therefore implemented this behavior in the 'ms/slo2199' topic branch in [1] and I have updated the (new) 'pu' proposed updates branch accordingly. Testing and review welcome.

As for path lookup... my general feeling is that rainbow-run shouldn't be guessing about what path the user meant. In this world, rainbow-run should call execve everywhere and rainbow-easy should pass an appropriate path to rainbow-run, e.g., by delegating the lookup to "which". A topic branch containing patches to this effect would be most welcome.

[1]:  http://git.sugarlabs.org/projects/rainbow/repos/mainline

Note: See TracTickets for help on using tickets.