Gcenx / WineskinServer

Wineskin
GNU Lesser General Public License v2.1
2.44k stars 167 forks source link

xattr has no `-r` option in macOS 13.2 #351

Closed fatso83 closed 1 year ago

fatso83 commented 1 year ago

EDIT: the problem is really that a Python lib and executable in your path shadows the macOS version. The solution is to just uninstall it.


Seems like the instructions in the README.md do not apply to the latest macOS version.

$ xattr -drs com.apple.quarantine /Users/carlerik/Downloads/Wineskin.Winery.txz 
option -r not recognized

usage: xattr [-slz] file [file ...]
       xattr -p [-slz] attr_name file [file ...]
       xattr -w [-sz] attr_name attr_value file [file ...]
       xattr -d [-s] attr_name file [file ...]
       xattr -c [-s] file [file ...]

The first form lists the names of all xattrs on the given file(s).
The second form (-p) prints the value of the xattr attr_name.
The third form (-w) sets the value of the xattr attr_name to attr_value.
The fourth form (-d) deletes the xattr attr_name.
The fifth form (-c) deletes (clears) all xattrs.

options:
  -h: print this help
  -s: act on symbolic links themselves rather than their targets
  -l: print long format (attr_name: attr_value)
  -z: compress or decompress (if compressed) attribute value in zip format

$ npx envinfo --system

  System:
    OS: macOS 13.2
    CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
    Memory: 116.65 MB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
Gcenx commented 1 year ago

Hu Apple must have changed xattr in 13.2 then as I remember running this command before 13.2 with out complaint.

I’ll need to update the README/wiki later due to this change, strange they’d removed -r

emendelson commented 1 year ago

xattr still uses -r in 13.2:

Screenshot 2023-02-01 at 2 36 13 PM
Gcenx commented 1 year ago

Screenshot 2023-02-01 at 9 34 23 PM

I'm getting the same output as @emendelson and I'm running Terminal under Rosetta2 so this shouldn't be due an issue with the x86_64 slice.

Rmilkmilk commented 1 year ago

Tried this on x86 Mini 2018 and I am not seeing an issue. The command line, in the order specified works for me (I am using Ventura 13.2 on Mini 2018 which is x86). Perhaps trying a different order of the arguments? Try moving the "d" to be the argument immediately before the attribute name: xattr -rsd com.apple.quarantine ......

fatso83 commented 1 year ago

Hi, thank you all for chiming and disproving me. There was another factor that caused this: Homebrew! I only realized this when I saw your responses and promptly checked which executable was being invoked:

$ command -v xattr
/opt/homebrew/bin/xattr

So Homebrew seems to install some xattr command of its own, shadowing the one built-into macOS:

$ find /bin/ /usr/bin -name xattr
/usr/bin/xattr

Hopefully, this might be of use for others coming across this obscurity.

Gcenx commented 1 year ago

@fatso83 if you manage to track down what cask/formula installed xattr please let us known so it can be documented.

Not sure why brew would be even installing it’s own copy of xattr into $PATH that seems rather unbrew like as it usually don’t replace system provided utility’s with its own even when it makes sense to (like bison)

fatso83 commented 1 year ago

I tried all kinds of approaches for figuring out what could have installed it, but no packages gave me any hits, so I kind of landed upon this being one of homebrew's own utilities. This was the same on both my mac's, so it's 95% likely it is either in this list of apps (installed by Homebrew): https://github.com/fatso83/dotfiles/blob/master/per-host-config/mac-work/apps.local

Or in the setup: https://github.com/fatso83/dotfiles/blob/5e7885fb9aa6bdfee49991ec454cd71d3fbe43f4/per-host-config/mac-work/setup.sh#L19-L51

I'll try to investigate a bit.

emendelson commented 1 year ago

brew does not install xattr by default (at least not on an Apple Silicon system). What happens when you enter brew list?

fatso83 commented 1 year ago

I am running both Apple Silicon and Intel macs with the same setup (linked above), so they should be pretty similar (and are in this case wrt xattr). brew list produces this:

``` $ brew list | command cat | sort aom apr apr-util argon2 aspell autoconf automake autossh bdw-gc brotli c-ares ca-certificates cairo ccat chromedriver cloc cmake coreutils cowsay cscope curl direnv docbook docbook-xsl dos2unix exiv2 fontconfig fortune freetds freetype fswatch gd gdbm gettext ghostscript giflib git-credential-manager-core git-extras glib glow gmp gnu-getopt gnupg gnutls graphite2 guile harfbuzz highway htop hub icu4c imagemagick imath jasper jbig2dec jemalloc jpeg jpeg-turbo jpeg-xl jq krb5 libassuan libavif libde265 libev libevent libffi libgcrypt libgpg-error libheif libidn libidn2 libksba liblinear liblqr libnghttp2 libomp libpng libpq libpthread-stubs libraw libsodium libssh libssh2 libtasn1 libtermkey libtiff libtool libunistring libusb libuv libvmaf libvterm libx11 libxau libxcb libxdmcp libxext libxrender libyaml libzip little-cms2 lua lua@5.3 luajit luajit-openresty luv lz4 lzo m4 macvim maven mosh mpdecimal msgpack mutagen ncdu ncurses neovim nettle nghttp2 nmap node npth oniguruma openexr openjdk openjdk@11 openjpeg openldap openssl@1.1 ossp-uuid p11-kit parallel pcre pcre2 php php@7.4 pigz pinentry pixman pkg-config postgresql postgresql@12 postgresql@13 postgresql@14 protobuf pspg pstree python@3.10 python@3.9 readline reattach-to-user-namespace redis rtmpdump shared-mime-info six socat sqlite terraform the_silver_searcher tidy-html5 tmux tree tree-sitter unbound unibilium unison unixodbc unox utf8proc vagrant vagrant-vmware-utility webp wkhtmltopdf x265 xmlto xorgproto xz zlib zopfli zstd ```

I tried both the brew cache (custom command) approach and the brew_find_pkg script in this Stackoverflow thread when trying to figure out what installed this, with no luck.


EDIT I did some inspecting and looked at what the various executables were. The built-in is a binary executable whereas the /opt/homebrew/bin/xattr one is just a minimal script calling out to the Python module:

#!/opt/homebrew/opt/python@3.10/bin/python3.10
# -*- coding: utf-8 -*-
import re
import sys
from xattr.tool import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
hyrulelinks commented 4 months ago

I can use -r option the day before, but the next day there is no option for -r. Then I run command where xattr and found that a package called xattr was installed by pip install into PATH. It was called before the xattr that comes with macOS. After deleting this Python package, everything returned to normal. Wish it can help.

fatso83 commented 4 months ago

I'll add to @hyrulelinks' answer for others that might be struggling with multiple Python installs. This is how you would uninstall correctly:

# Figure out in which python version and location it is installed:
❯   head -1 $(which xattr)
#!/opt/homebrew/opt/python@3.10/bin/python3.10

# Remove it:
❯  PYTHONPATH=/opt/homebrew/opt/python@3.10/site-packages pip3 uninstall xattr
Found existing installation: xattr 0.10.1
Uninstalling xattr-0.10.1:
  Would remove:
    /opt/homebrew/bin/xattr
    /opt/homebrew/lib/python3.10/site-packages/xattr-0.10.1.dist-info/*
    /opt/homebrew/lib/python3.10/site-packages/xattr/*
Proceed (Y/n)? y
  Successfully uninstalled xattr-0.10.1