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

fix symlinked /home issue for FreeBSD #1402

Merged
merged 1 commit into from Feb 15, 2012

Conversation

ivanov
Copy link
Member

@ivanov ivanov commented Feb 13, 2012

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

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'~']
@minrk
Copy link
Member

minrk commented Feb 13, 2012

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
Copy link
Member Author

ivanov commented Feb 13, 2012

~/<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
Copy link
Member Author

ivanov commented Feb 15, 2012

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
Copy link
Member

minrk commented Feb 15, 2012

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 added a commit that referenced this pull request Feb 15, 2012
fix symlinked /home issue (e.g. for FreeBSD)

fixes assumption that `~` follows no symlinks in pushd and friends.
@minrk minrk merged commit 1dd379d into ipython:master Feb 15, 2012
@minrk
Copy link
Member

minrk commented Feb 15, 2012

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.

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
fix symlinked /home issue (e.g. for FreeBSD)

fixes assumption that `~` follows no symlinks in pushd and friends.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants