Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embedded highlight is always used, but appears to be incompatible #97

Open
EricFromCanada opened this issue Sep 20, 2022 · 0 comments
Open

Comments

@EricFromCanada
Copy link

I've driven myself to distraction in attempting to get this to work on multiple macOS versions. What I've found for v4.1.0:

unstated 10.14+ requirement

Not really surprising given that the Xcode project sets MACOSX_DEPLOYMENT_TARGET = 10.15, but it should probably be mentioned in the README. On earlier versions:

$ qlmanage -p /System/Library/BridgeSupport/include/_BS_bool.h 
Testing Quick Look preview with files:
	/System/Library/BridgeSupport/include/_BS_bool.h
[ERROR] Can't load plug-in at file:///Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/: Error Domain=NSCocoaErrorDomain Code=3588 "dlopen(/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/MacOS/QLColorCode, 262): Symbol not found: _objc_alloc_init
  Referenced from: /Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/MacOS/QLColorCode (which was built for Mac OS X 10.15)
  Expected in: /usr/lib/libobjc.A.dylib

FWIW, I got this working on 10.12 by replacing MacOS/QLColorCode from v2.1.0 into the v4.1.0 package.

embedded highlight throws error on 10.13+

The embedded binary of highlight 3.60, included since v4.0.0 (#73), only seems to work on macOS 10.12.

### 10.12 
$ cat /System/Library/BridgeSupport/include/_BS_bool.h | ~/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/highlight -D ~/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources --syntax=c
<!DOCTYPE html>
<html>
<head>
...
<!--HTML generated by highlight 3.60, http://www.andre-simon.de/-->

### 10.13
$ cat /System/Library/BridgeSupport/include/_BS_bool.h | ~/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/highlight -D ~/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources --syntax=c
Illegal instruction: 4

### 12.x
% cat /System/Library/BridgeSupport/include/_BS_bool.h | ~/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/highlight -D ~/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources --syntax=c
zsh: done                          cat /System/Library/BridgeSupport/include/_BS_bool.h | 
zsh: illegal hardware instruction  ~/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/highlight -D 

embedded highlight is always used even when others are in the PATH

The above issue requires "pathHL" to be set.

### 10.14
$ which highlight
$ qlmanage -p /System/Library/BridgeSupport/include/_BS_bool.h
Testing Quick Look preview with files:
	/System/Library/BridgeSupport/include/_BS_bool.h
/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/colorize.sh:98: permission denied: /System/Library/BridgeSupport/include/_BS_bool.h
2022-09-20 00:39:24.998 qlmanage[88019:8638561] QLColorCode: colorize.sh failed with exit code 101.  Command was ('/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/colorize.sh' '/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources' '/System/Library/BridgeSupport/include/_BS_bool.h' 0).
Segmentation fault: 11
$ '/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/colorize.sh' '/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources' '/System/Library/BridgeSupport/include/_BS_bool.h' 0
/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/colorize.sh:98: permission denied: /System/Library/BridgeSupport/include/_BS_bool.h
go4it:9: command not found: -D
go4it:9: command not found: -D
## ^ caused by $pathHL in colorize.sh being empty

### after installing `highlight` using Homebrew
$ which highlight
/usr/local/bin/highlight
$ cat /System/Library/BridgeSupport/include/_BS_bool.h | /usr/local/bin/highlight -D ~/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources --syntax=c
<!DOCTYPE html>
<html>
<head>
...
<!--HTML generated by highlight 4.2, http://www.andre-simon.de/-->
$ qlmanage -p /System/Library/BridgeSupport/include/_BS_bool.h
Testing Quick Look preview with files:
	/System/Library/BridgeSupport/include/_BS_bool.h
/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/colorize.sh:98: permission denied: /System/Library/BridgeSupport/include/_BS_bool.h
2022-09-20 00:45:15.205 qlmanage[88052:8640054] QLColorCode: colorize.sh failed with exit code 101.  Command was ('/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/colorize.sh' '/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources' '/System/Library/BridgeSupport/include/_BS_bool.h' 0).
Segmentation fault: 11
## and Quick Look in Finder just gives the icon

### after copying `highlight` to /opt/local/bin: same result

### when setting "pathHL" preference
$ defaults read org.n8gray.QLColorCode
2022-09-19 23:43:44.518 defaults[87546:8623530] 
Domain org.n8gray.QLColorCode does not exist
$ defaults write org.n8gray.QLColorCode pathHL /usr/local/bin/highlight
$ qlmanage -p /System/Library/BridgeSupport/include/_BS_bool.h
Testing Quick Look preview with files:
	/System/Library/BridgeSupport/include/_BS_bool.h
/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/colorize.sh:98: permission denied: /System/Library/BridgeSupport/include/_BS_bool.h
Segmentation fault: 11
## although Quick Look in Finder now works

### after replacing embedded `highlight` with Homebrew version
$ defaults delete org.n8gray.QLColorCode
$ otool -L ~/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/highlight
/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/highlight:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
	/usr/local/opt/lua/lib/liblua.dylib (compatibility version 5.4.0, current version 5.4.4)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 902.1.0)
$ qlmanage -p /System/Library/BridgeSupport/include/_BS_bool.h
Testing Quick Look preview with files:
	/System/Library/BridgeSupport/include/_BS_bool.h
/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/colorize.sh:98: permission denied: /System/Library/BridgeSupport/include/_BS_bool.h
Segmentation fault: 11
## and Quick Look in Finder still works

### after removing embedded `highlight`
$ which highlight
/usr/local/bin/highlight
$ qlmanage -p /System/Library/BridgeSupport/include/_BS_bool.h
Testing Quick Look preview with files:
	/System/Library/BridgeSupport/include/_BS_bool.h
/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/colorize.sh:98: permission denied: /System/Library/BridgeSupport/include/_BS_bool.h
go4it:9: no such file or directory: /Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/highlight
go4it:9: no such file or directory: /Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/highlight
2022-09-20 00:49:33.241 qlmanage[88147:8642999] QLColorCode: colorize.sh failed with exit code 101.  Command was ('/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources/colorize.sh' '/Users/serveradmin/Library/QuickLook/QLColorCode.qlgenerator/Contents/Resources' '/System/Library/BridgeSupport/include/_BS_bool.h' 0).
Segmentation fault: 11
## and Quick Look in Finder just gives the icon

### 10.15
## same results as 10.14, except the `qlmanage -p` commands now work despite giving "Unable to create basic Accelerated OpenGL renderer" instead of segfaulting (caused by being run within a VM, most likely)

codesigning and notarization is required on macOS 11+

After setting "pathHL' and whether installing it with brew install --cask qlcolorcode --no-quarantine or removing the quarantine attribute with xattr -cr ~/Library/QuickLook/*.qlgenerator and unblocking in System Preferences > Security & Privacy, the plugin just gives a blank window. Seems fixed with this build (xref #92, #95).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant