Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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'~']
  • Loading branch information...
commit 542170a57ab3f83e88d32743b1b464bdaace414d 1 parent 8096bb8
Paul Ivanov authored

Showing 1 changed file with 3 additions and 0 deletions. Show diff stats Hide diff stats

  1. +3 0  IPython/utils/path.py
3  IPython/utils/path.py
@@ -201,6 +201,9 @@ def get_home_dir(require_writable=False):
201 201 return py3compat.cast_unicode(root, fs_encoding)
202 202
203 203 homedir = os.path.expanduser('~')
  204 + # Next line will make things work even when /home/ is a symlink to
  205 + # /usr/home as it is on FreeBSD, for example
  206 + homedir = os.path.realpath(homedir)
204 207
205 208 if not _writable_dir(homedir) and os.name == 'nt':
206 209 # expanduser failed, use the registry to get the 'My Documents' folder.

0 comments on commit 542170a

Please sign in to comment.
Something went wrong with that request. Please try again.