Bug 1306513 - python-virtualenv-1.10.1-2.el7: os.py:157:makedirs:OSError: [Errno 20] Not a directory: 'ansible/lib'
python-virtualenv-1.10.1-2.el7: os.py:157:makedirs:OSError: [Errno 20] Not a ...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: python-virtualenv (Show other bugs)
7.2
All Linux
medium Severity medium
: rc
: ---
Assigned To: Tomas Orsava
David Jež
: Patch
Depends On:
Blocks: 1305230
  Show dependency treegraph
 
Reported: 2016-02-11 01:06 EST by Manish Saxena
Modified: 2016-11-04 00:39 EDT (History)
7 users (show)

See Also:
Fixed In Version: python-virtualenv-1.10.1-3.el7
Doc Type: Enhancement
Doc Text:
Feature: Added an error message when virtual env is passed a FILE that already exists and is not a directory. Reason: It's better to show a custom error message instead of a traceback. Result: Error message is displayed when appropriate.
Story Points: ---
Clone Of:
: 1353200 1353202 1353205 1353206 1353960 1357432 (view as bug list)
Environment:
Last Closed: 2016-11-04 00:39:04 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Polish error message of when file is passed (842 bytes, patch)
2016-03-10 04:09 EST, Robert Kuska
no flags Details | Diff

  None (edit)
Description Manish Saxena 2016-02-11 01:06:37 EST
Description of problem:

[abrt] python-virtualenv-1.10.1-2.el7: os.py:157:makedirs:OSError: [Errno 20] Not a directory: 'ansible/lib'

time:           Wed 27 Jan 2016 01:28:16 PM EST
cmdline:        /usr/bin/python /usr/bin/virtualenv ansible
uid:            13009 (yundtj)
abrt_version:   2.1.11
comment:        I created a virtualenv and installed ansible.
dso_list:       python-libs-2.7.5-34.el7.x86_64
event_log:      
executable:     /usr/bin/virtualenv
kernel:         3.10.0-327.4.5.el7.x86_64
last_occurrence: 1453919296
pid:            15884
pkg_arch:       noarch
pkg_epoch:      0
pkg_name:       python-virtualenv
pkg_release:    2.el7
pkg_version:    1.10.1
runlevel:       N 5
username:       yundtj

sosreport.tar.xz: Binary file, 17901444 bytes

backtrace:
:os.py:157:makedirs:OSError: [Errno 20] Not a directory: 'ansible/lib'
:
:Traceback (most recent call last):
:  File "/usr/bin/virtualenv", line 3, in <module>
:    virtualenv.main()
:  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 821, in main
:    symlink=options.symlink)
:  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 956, in create_environment
:    site_packages=site_packages, clear=clear, symlink=symlink))
:  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 1129, in install_python
:    mkdir(lib_dir)
:  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 441, in mkdir
:    os.makedirs(path)
:  File "/usr/lib64/python2.7/os.py", line 150, in makedirs
:    makedirs(head, mode)
:  File "/usr/lib64/python2.7/os.py", line 157, in makedirs
:    mkdir(name, mode)
:OSError: [Errno 20] Not a directory: 'ansible/lib'
:
:Local variables in innermost frame:
:tail: 'lib'
:head: 'ansible'
:name: 'ansible/lib'
:mode: 511

environ:
:force_s3tc_enable=true
:SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
:GNOME_DESKTOP_SESSION_ID=this-is-deprecated
:GJS_DEBUG_OUTPUT=stderr
:WINDOWPATH=1
:LESSOPEN=||/usr/bin/lesspipe.sh %s
:QT_IM_MODULE=ibus
:LOGNAME=yundtj
:USER=yundtj
:PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/acct.upmchs.net/yundtj/.local/bin:/home/acct.upmchs.net/yundtj/bin
:XDG_VTNR=1
:QTDIR=/usr/lib64/qt-3.3
:GUESTFISH_RESTORE=\e[0m
:GUESTFISH_INIT=\e[1;34m
:XDG_SESSION_DESKTOP=gnome
:LANG=en_US.UTF-8
:QTLIB=/usr/lib64/qt-3.3/lib
:TERM=xterm-256color
:SHELL=/bin/bash
:XAUTHORITY=/run/gdm/auth-for-yundtj-1s0K3t/database
:SESSION_MANAGER=local/unix:@/tmp/.ICE-unix/14677,unix/unix:/tmp/.ICE-unix/14677
:QTINC=/usr/lib64/qt-3.3/include
:HISTSIZE=1000
:WINDOWID=35651591
:QT_PLUGIN_PATH=/usr/lib64/kde4/plugins:/usr/lib/kde4/plugins
:IMSETTINGS_INTEGRATE_DESKTOP=yes
:GPG_AGENT_INFO=/run/user/13009/keyring/gpg:0:1
:HOME=/home/acct.upmchs.net/yundtj
:USERNAME=yundtj
:IMSETTINGS_MODULE=none
:XDG_RUNTIME_DIR=/run/user/13009
:GUESTFISH_PS1=\[\e[1;32m\]><fs>\[\e[0;31m\] 
:SSH_AUTH_SOCK=/run/user/13009/keyring/ssh
:VTE_VERSION=3803
:GDMSESSION=gnome
:XMODIFIERS=@im=ibus
:MAIL=/var/spool/mail/yundtj
:QT_GRAPHICSSYSTEM_CHECKED=1
:XDG_CURRENT_DESKTOP=GNOME
:XDG_SESSION_ID=1
:DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-RW7M3Qul3X,guid=95a90d9c743a1b3e4761880156a7849e
:_=/usr/bin/virtualenv
:KDEDIRS=/usr
:DESKTOP_SESSION=gnome
:JAVA_HOME=/usr/lib/jvm/java-openjdk
:DISPLAY=:0
:GUESTFISH_OUTPUT=\e[0m
:KRB5CCNAME=KEYRING:persistent:13009
:HOSTNAME=etg61tfp
:GDM_LANG=en_US.UTF-8
:HISTCONTROL=ignoredups
:SHLVL=2
:PWD=/home/acct.upmchs.net/yundtj
:XDG_MENU_PREFIX=gnome-
:LS_COLORS=rs=0:di=38;5;27:ln=38;5;51:mh=44;38;5;15:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=05;48;5;232;38;5;15:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;34:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.Z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.axv=38;5;13:*.anx=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.axa=38;5;45:*.oga=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:
:GJS_DEBUG_TOPICS=JS ERROR;JS LOG
:XDG_SEAT=seat0

machineid:
:systemd=3506ae1de2b34f359c35b5477634cd20
:sosreport_uploader-dmidecode=039aaf85bb8014cbf57f9ee4c6367d8678b217f7741c8e4924db220a4e22ab05

reported_to:
:uReport: BTHASH=2167f9e07701bfc3532c4966bf2faaf5b5443e10
:ABRT Server: URL=https://api.access.redhat.com/rs/telemetry/abrt/reports/bthash/2167f9e07701bfc3532c4966bf2faaf5b5443e10

Version-Release number of selected component (if applicable):
RHEL7.2
python-virtualenv-1.10.1-2.el7

How reproducible:
Everytime

Steps to Reproduce:

To create virtual environments, we can use the virtualenv command. Create an environment called "testredhat" successfully.

[root@debug ~]# virtualenv testredhat
New python executable in testredhat/bin/python
Installing Setuptools..............................................................................................................................................................................................................................done.
Installing Pip.....................................................................................................................................................................................................................................................................................................................................done.
[root@debug ~]# cd testredhat/
[root@debug testredhat]# ls
bin  include  lib  lib64
[root@debug testredhat]# 

However if we create a file with similar name which we want to create for virtualenv then it throws an error. 

[root@debug ~]# 
[root@debug ~]# touch ansible
[root@debug ~]# rpm -qa | grep python-libs
python-libs-2.7.5-34.el7.x86_64
[root@debug ~]# virtualenv ansible
Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 3, in <module>
    virtualenv.main()
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 821, in main
    symlink=options.symlink)
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 956, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 1129, in install_python
    mkdir(lib_dir)
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 441, in mkdir
    os.makedirs(path)
  File "/usr/lib64/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib64/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 20] Not a directory: 'ansible/lib'
[root@debug ~]# echo $?
1
[root@debug ~]# 

Actual results:

Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 3, in <module>
    virtualenv.main()
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 821, in main
    symlink=options.symlink)
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 956, in create_environment

Expected results:

No error

Additional info:
Comment 2 Robert Kuska 2016-03-10 04:06:06 EST
The behavior is correct but error message needs polishing.

Does this seem ok to you?

> $ touch ansible
> $ virtualenv scripts
ERROR: File already exists and is not a directory.
Please provide a different path or delete the file.
Comment 3 Robert Kuska 2016-03-10 04:09 EST
Created attachment 1134762 [details]
Polish error message of when file is passed

Attaching patch which fixes the issue.
Comment 11 errata-xmlrpc 2016-11-04 00:39:04 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2360.html

Note You need to log in before you can comment on or make changes to this bug.