This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: "File exists" error during venv --upgrade
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, larry, orsenthil, python-dev, vdupras, vinay.sajip, vstinner
Priority: release blocker Keywords: 3.4regression, patch

Created on 2014-06-02 18:47 by vdupras, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
venv.patch vstinner, 2014-06-03 13:18 review
Messages (7)
msg219617 - (view) Author: Virgil Dupras (vdupras) (Python triager) Date: 2014-06-02 18:47
There seems to have been a regression in Python 3.4.1 with "pyvenv --upgrade", and this regression seems to be caused by #21197.

It now seems impossible to use the "--upgrade" flag without getting a "File exists" error. Steps to reproduce:

$ pyvenv env
$ pyvenv --upgrade env
Error: [Errno 17] File exists: '/<pwd>/env/lib' -> '/<pwd>/env/lib64'
msg219667 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2014-06-03 07:23
I could not reproduce this in 3.4 / 3.5


[localhost 21643]$ ./python.exe Tools/scripts/pyvenv --upgrade
usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear]
            [--upgrade] [--without-pip]
            ENV_DIR [ENV_DIR ...]
venv: error: the following arguments are required: ENV_DIR
[localhost 21643]$ ./python.exe Tools/scripts/pyvenv --upgrade foo
[localhost 21643]$ hg tip
changeset:   90992:50c9df76bb77
tag:         tip
parent:      90989:f59afe34fe50
parent:      90991:e6dce5611dae
user:        Senthil Kumaran <senthil@uthcode.com>
date:        Mon Jun 02 23:00:43 2014 -0700
---------------------------------------------------------------------

More specific steps to reproduce it from the current codebase?
msg219685 - (view) Author: Virgil Dupras (vdupras) (Python triager) Date: 2014-06-03 12:51
I could reproduce the bug on the v3.4.1 tag, on the 3.4 branch and on the default branch. I think that one of the conditions for the bug to arise is to have the "lib64" symlink created (as described in #21197).

I reproduced the bug on Gentoo and Arch environments.
msg219686 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-06-03 13:18
Full traceback (I modified venv/__main__.py):

haypo@smithers$ /opt/py34/bin/python3 -m venv --upgrade ENV
Error: [Errno 17] File exists: '/home/haypo/ENV/lib' -> '/home/haypo/ENV/lib64'
Traceback (most recent call last):
  File "/opt/py34/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/opt/py34/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/py34/lib/python3.4/venv/__main__.py", line 6, in <module>
    main()
  File "/opt/py34/lib/python3.4/venv/__init__.py", line 438, in main
    builder.create(d)
  File "/opt/py34/lib/python3.4/venv/__init__.py", line 82, in create
    context = self.ensure_directories(env_dir)
  File "/opt/py34/lib/python3.4/venv/__init__.py", line 147, in ensure_directories
    os.symlink(p, link_path)
FileExistsError: [Errno 17] File exists: '/home/haypo/ENV/lib' -> '/home/haypo/ENV/lib64'

It looks like a regression introduced by the issue #21197.

Attached patch should fix it.
msg219687 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-06-03 13:19
Oh, my test lacks a unit test!
msg219688 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-06-03 13:20
Ok, this bug is a regression introduced in Python 3.4.1.
msg219702 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-06-03 15:49
New changeset 27e1b4a9de07 by Vinay Sajip in branch '3.4':
Issue #21643: Updated test and fixed logic bug in lib64 symlink creation.
http://hg.python.org/cpython/rev/27e1b4a9de07

New changeset 71eda9bd8875 by Vinay Sajip in branch 'default':
Closes #21643: Merged fix from 3.4.
http://hg.python.org/cpython/rev/71eda9bd8875
History
Date User Action Args
2022-04-11 14:58:04adminsetgithub: 65842
2014-06-03 15:49:25python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg219702

resolution: fixed
stage: resolved
2014-06-03 13:20:51vstinnersetpriority: normal -> release blocker
nosy: + larry
messages: + msg219688

2014-06-03 13:19:05vstinnersetmessages: + msg219687
2014-06-03 13:18:19vstinnersetfiles: + venv.patch

nosy: + vstinner
messages: + msg219686

keywords: + patch
2014-06-03 12:51:09vduprassetmessages: + msg219685
2014-06-03 07:23:22orsenthilsetnosy: + orsenthil
messages: + msg219667
2014-06-02 19:03:44barrysetnosy: + barry
2014-06-02 18:47:26vduprascreate