fix symlinked /home issue for FreeBSD #1402

Merged
merged 1 commit into from Feb 15, 2012

2 participants

@ivanov
IPython member

this is a one-line fix for ipython's pushd and friends on systems which
symlink /home directories to /usr/home. Here's the error I get on
FreeBSD 9.0 without this PR:

======================================================================
FAIL: Test various directory handling operations.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/home/pi/code/ipython/IPython/core/tests/test_magic.py", line 280, in test_dirops
    nt.assert_equal(curpath(), startdir)
AssertionError: u'/usr/home/pi/.ipython' != u'/usr/home/pi/code/ipython'
- /usr/home/pi/.ipython
?              ^
+ /usr/home/pi/code/ipython
?              ^^^^^

    """Fail immediately, with the given message."""
>>  raise self.failureException(u"u'/usr/home/pi/.ipython' != u'/usr/home/pi/code/ipython'\n- /usr/home/pi/.ipython\n?              ^\n+ /usr/home/pi/code/ipython\n?              ^^^^^\n")

-------------------- >> begin captured stdout << ---------------------
/usr/home/pi/.ipython
/usr/home/pi/code/ipython
/usr/home/pi/.ipython
[Errno 2] No such file or directory: '/usr~/code/ipython'
/usr/home/pi/.ipython
popd -> /usr~/code/ipython

--------------------- >> end captured stdout << ----------------------

The reason for the above is this:

In [1]: pwd
Out[1]: u'/usr/home/pi'

In [2]: !pwd
/home/pi

In [3]: pushd code
/usr/home/pi/code
Out[3]: [u'/usr~']

with this commit:

In [1]: pushd
Out[1]: [u'~']

and the above failing test passes

@ivanov ivanov fix symlinked /home issue for FreeBSD
this is a one-line fix for ipython's pushd and friends on systems which
symlink /home directories to /usr/home. Here's the error I get on
FreeBSD 9.0 without this PR:

======================================================================
FAIL: Test various directory handling operations.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/nose-1.1.2-py2.7.egg/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/home/pi/code/ipython/IPython/core/tests/test_magic.py", line 280, in test_dirops
    nt.assert_equal(curpath(), startdir)
AssertionError: u'/usr/home/pi/.ipython' != u'/usr/home/pi/code/ipython'
- /usr/home/pi/.ipython
?              ^
+ /usr/home/pi/code/ipython
?              ^^^^^

    """Fail immediately, with the given message."""
>>  raise self.failureException(u"u'/usr/home/pi/.ipython' != u'/usr/home/pi/code/ipython'\n- /usr/home/pi/.ipython\n?              ^\n+ /usr/home/pi/code/ipython\n?              ^^^^^\n")

-------------------- >> begin captured stdout << ---------------------
/usr/home/pi/.ipython
/usr/home/pi/code/ipython
/usr/home/pi/.ipython
[Errno 2] No such file or directory: '/usr~/code/ipython'
/usr/home/pi/.ipython
popd -> /usr~/code/ipython

--------------------- >> end captured stdout << ----------------------

The reason for the above is this:

In [1]: pwd
Out[1]: u'/usr/home/pi'

In [2]: !pwd
/home/pi

In [3]: pushd code
/usr/home/pi/code
Out[3]: [u'/usr~']

with this commit:

In [1]: pushd
Out[1]: [u'~']
542170a
@minrk
IPython member

Can you make sure completions on '~/path/to/stuff' still work? I wonder if there might be one or two more places we want to call realpath.

@ivanov
IPython member

~/<tab> still works, and shows the correct completions as the symlinked path - but runing a file or cding to a directory with respect to the symlinked path seems to work fine back in a (symlinked /home) Ubuntu land. Let me confirm on FreeBSD... confirmed

grepping through the source - I only see home_dir being used in core/interactiveshell.py core/logger.py core/magic.py utils/path.py. Logger just uses the name, and gets it from iteractiveshell, which calls the utils/path.py:get_home_dir method I've modified here. magic.py also just uses the interactivelshell's home_dir, so I think that's all the places where it's used, aside from the related tests.

@ivanov
IPython member

confirmed that tab completions still work on ~/path/to/stuff on FreeBSD, this is ready to merge as far as I'm concerned, unless there are other outstanding thing I need to look into

@minrk
IPython member

thanks, I'll go ahead and merge then. Also ,thanks for the confirmation as separate comment, I wouldn't have been notified of the in-place edit.

@minrk minrk merged commit 1dd379d into ipython:master Feb 15, 2012
@minrk
IPython member

This introduced a failure in test_get_home_dir_3 when home is a symlink. I think it's a simple case of needing to call realpath in the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment