Python Strange python3.7 error

Hello,

I wish to try lieer (http://lieer.gaute.vetsj.com/) on a machine running FreeBSD 13.0-RELEASE. It is a mail sync program specifically for Google mail, but like offlineimap or mbsync.

I've used linux and unixes for years, but am new to FreeBSD. This is a relatively new install on a desktop. I'm installing everything using pkg. I also do not yet know python. That said, I've tracked down what seems strange output. The function os.getcwd () in the os library is prepending '/usr' to the current working directory.

Code:
$ pwd
/home/user/mail/gmail
$ python3.7
Python 3.7.10 (default, Apr 15 2021, 01:11:55) 
[Clang 11.0.1 (git@github.com:llvm/llvm-project.git llvmorg-11.0.1-0-g43ff75f2c on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.getcwd ()
'/usr/home/user/mail/gmail'

Note the '/usr' before the /home. I just installed python2 and the same problem occurred.

I have a laptop with the same FreeBSD version installed (using the same USB key) and this does not happen there. It also doesn't happen on a Debian linux desktop. The problem replicates in X or not. It replicates with different shells (sh, zsh, and bash). I assume I've somehow introduced this, but I have no clue how.

Any thoughts about causes and fixes appreciated. Thank you for your time.
 
On FreeBSD home directories typically live in /usr/home. There is a symlink from /home to /usr/home.
It also doesn't happen on a Debian linux desktop.
On Linux it's common to have them in /home. That's why that symlink exists.

This is not a problem or an error, home directories could potentially live anywhere in the filesystem and are set in the user's passwd(5) fields.
 
Thank you, SirDice. I missed '/usr/home' mentioned in the Handbook.
I switched /home and /usr/home, so the symlink is in /usr and now the python scripts work. Take care.
 
One more detail: Above, you show that the pwd command outputs "/home/user/...", while the getcwd() function in Python outputs "/usr/home/user/...". That makes perfect sense. In some shells, pwd is a shell built-in command, which tells you what directory you most recently moved into, using the cd command (which is also a shell built-in). On the other hand, the getcwd function shows you what directory you are in. In the presence of soft links, the two answers might come out different.

And to expand on SirDice's excellent answer: Nothing stops you from configuring your FreeBSD system to have the user's home directories in /home instead of /usr/home, and get rid of that symlink. I do that on my systems, just for less typing, and consistency across many OSes. I even go and remove /usr/home, which is not needed if all users have their home directories in /home instead; that's probably a bit tasteless, but it removes unneeded complexity. However, I see that you have a user called "user". Think whether this is really a good idea, since there are lots of other things called "usr" or "user" in a system already. If this is a single-person system, I like the idea of just using the human's first name.
 
Back
Top