Path might have to be expanded on some operations. It seems that path containing '~' are not. Using os.path.expanduser in appropriate places solves the problem, but this might be required in many other places.