1

I don't know what happened, but it seems my xattr is broken.

% which xattr
/usr/bin/xattr


% xattr -h
Traceback (most recent call last):
  File "/usr/bin/xattr-2.7", line 7, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

I found out, that module pkg_resources is part of setuptools. So I installed setuptools via pip3, but it is already there.

%  pip3 install setuptools
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (41.2.0)

xattr-2.7 is just a simple code

#!/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
import sys
sys.argv[0] = sys.argv[0].replace('-2.7', '')
# EASY-INSTALL-ENTRY-SCRIPT: 'xattr==0.6.4','console_scripts','xattr'
__requires__ = 'xattr==0.6.4'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('xattr==0.6.4', 'console_scripts', 'xattr')()
    )

/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python does exist and can not be altered in anyway. How can I fix this? I'm on macOS Mojave.

Nomis101
  • 31
  • 1
  • 4
  • Try `type xattr` rather than `which xattr` It should say `xattr is hashed (/usr/bin/xattr)` – Mark Setchell Sep 25 '19 at 18:59
  • `% type xattr xattr is /usr/bin/xattr` – Nomis101 Sep 25 '19 at 19:46
  • Ok, try `/usr/bin/xattr -h` – Mark Setchell Sep 25 '19 at 19:48
  • Its the same like above. `% /usr/bin/xattr -h Traceback (most recent call last): File "/usr/bin/xattr-2.7", line 7, in from pkg_resources import load_entry_point ImportError: No module named pkg_resources` – Nomis101 Sep 26 '19 at 19:30
  • Ok, last question. What do you get with `file /usr/bin/xattr` – Mark Setchell Sep 26 '19 at 19:37
  • `file /usr/bin/xattr /usr/bin/xattr: Python script text executable, ASCII text` – Nomis101 Sep 27 '19 at 15:06
  • Ok, so you have somehow overwritten the Apple-supplied `/usr/bin/xattr` command that comes with macOS, with a Python script. You'll need to either restore the Apple-supplied `xattr` from a backup, or copy one from another Mac. – Mark Setchell Sep 27 '19 at 15:40
  • Overwritten the Apple-supplied `/usr/bin/xattr` ? How can this happen? It might be a bit tricky to restore `/usr/bin/xattr`, because `/usr/bin` is a restricted directory. There is no legal way to write or delete in that directory. So I wonder how it happened, that I have overwritten a file in that directory. Would it help to reinstall macOS Mojave? – Nomis101 Sep 28 '19 at 16:16
  • To answer my own question, yes, it does help to reinstall macOS Mojave. Thanks for the hint and your assistance. – Nomis101 Sep 28 '19 at 17:49

0 Answers0