Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XDG_CONFIG_HOME causes server to crash #3068

Closed
paulhtremblay opened this issue May 16, 2014 · 7 comments
Closed

XDG_CONFIG_HOME causes server to crash #3068

paulhtremblay opened this issue May 16, 2014 · 7 comments
Labels
status: needs clarification Issues that need more information to resolve.

Comments

@paulhtremblay
Copy link

I am using matplotlib on a server to produce graphs. Ther server sets my HOME varialbe to /home/username. But the server does not create a home directory. When I try to import matplot lib, the server crashes because it tries to find a home directory. THe partial traceback is below.

File "/apollo/env/Ssdf/lib/python2.7/site-packages/matplotlib/__init__.py", line 597, in _get_configdir
    return _get_config_or_cache_dir(_get_xdg_config_dir())
  File "/apollo/env/Ssdf/lib/python2.7/site-packages/matplotlib/__init__.py", line 534, in _get_xdg_config_dir
    return os.environ.get('XDG_CONFIG_HOME', os.path.join(get_home(), '.config'))
  File "/apollo/env/Ssdf/bin/../../../package/local_1/Linux-2.6c2.5-x86_64/Python27/Python27-487.0-0/lib/python2.7/posixpath.py", line 77, in join
    elif path == '' or path.endswith('/'):
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'endswith'

[TAC edited to make backtrace readable]

@tacaswell
Copy link
Member

What version of mpl are you using? This should be working on master.

@paulhtremblay
Copy link
Author

On 5/17/14 9:30 AM, Thomas A Caswell wrote:

What version of mpl are you using? This should be working on master.


Reply to this email directly or view it on GitHub
#3068 (comment).

1.3.1

@tacaswell
Copy link
Member

It looks like on the master branch all calls to get_home() are validated to be not None. I am going to close this as already fixed, but if you can test with master branch and find it is still a problem please ask to have this re-opened.

@paulhtremblay
Copy link
Author

If I am understanding the code correctly, the crash is caused by this line:

return os.environ.get('XDG_CONFIG_HOME', os.path.join(get_home(), '.config'))

if XDG_CONFIG_HOME does not exist, then get_home is called, and then joined to 'config.' The problem with my configuration is that HOME in fact exists:

echo $HOME
>>/home/user

But there is no directory /home/user. Hence, the crash.
I just verified that this error exists on the master branch on my Mac OS system:

pip install matplotlib

>> success

python
>>import os
>>os.environ['HOME'] = 'bogus_dir_does_not_exist'
>>import matplotlib
File "/Library/Python/2.7/site-packages/matplotlib/__init__.py", line 534, in _get_xdg_config_dir
    return os.environ.get('XDG_CONFIG_HOME', os.path.join(get_home(), '.config'))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 68, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'

Setting os.environ['MPLCONFIGDIR'] = '/tmp'

does not help

os.environ['XDG_CONFIG_HOME'] = '/tmp'

Also does not help.

@tacaswell tacaswell reopened this May 18, 2014
@tacaswell
Copy link
Member

can you do a matplotlib.__version__? It should return u'1.4.x' if you are on master. I would expect pip to install 1.3.1, not the master branch. See https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/__init__.py#L537 for the current code.

(py2k-clean)tcaswell@eowyn:~$ python
Python 2.7.5+ (default, Feb 27 2014, 19:37:08) 
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>  import os
>>> os.environ['HOME'] = 'bogus_dir_does_not_exist'
>>> import matplotlib
>>> matplotlib.__version__
u'1.4.x'
>>> 

As a side note, wrapping code blocks in triple back quotes ('```') makes them format better.

@paulhtremblay
Copy link
Author

On 5/17/14 9:27 PM, Thomas A Caswell wrote:

can you do a |matplotlib.version|? It should return |u'1.4.x'| if
you are on master. I would expect pip to install 1.3.1, not the master
branch. See
https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/__init__.py#L537
for the current code.

|(py2k-clean)tcaswell@eowyn:~$ python
Python 2.7.5+ (default, Feb 27 2014, 19:37:08)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import os
os.environ['HOME'] = 'bogus_dir_does_not_exist'
import matplotlib
matplotlib.version
u'1.4.x'

|
|

As a side note, wrapping code blocks in triple back quotes ('```')
makes them format better.


Reply to this email directly or view it on GitHub
#3068 (comment).

I misunderstood what you mean by "master." Indeed, I am using 1.3.1, and
I see that development has fixed the problem. When is 1.4 expected to be
released? If it will be a while, I might try to patch 1.3.1 for my work.

Conversely, I guess I can always do:

if os.environ.get('HOME') and not os.path.isdir(os.environ['HOME']:
true_home = os.environ['HOME']
del(os.environ['HOME'])
import matplotlib
os.environ['HOME'] = true_home

Thanks for your help

P.

@tacaswell
Copy link
Member

The goal is to have a release candidate by the end of the month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs clarification Issues that need more information to resolve.
Projects
None yet
Development

No branches or pull requests

2 participants