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

DistroAV install in /Library instead of ~/Library - symlink workaround create issues after rebranding #200761

Open
6 tasks done
Trouffman opened this issue Feb 6, 2025 · 7 comments

Comments

@Trouffman
Copy link

Verification

Description of issue

Cask for DistroAV (formerly obs-ndi) install in /Library... instead of ~/Library...

There is a workaround in the cask but this does not clean-up / delete / remove the old obs-ndi files, simply unlink them.

This created a surge of Support Request without understanding where it came from for the DistroAV project.

As a maintainer on the DistroAV Project, I would like to find a more reliable way to deploy / update and maintain the Cask for the MacOS users.

Here are the challenges we wish to address:

  1. How can the old versions of the files installed in /Library be removed (along with the symlink) < workaround of the workaround
  2. Find why it install in /Library and not ~/Library
  3. Fix the package to install in the proper ~/Library path

Context:
I am new to homebrew recipes crafting.
This is aimed to be : 1. fixed quickly 2. revised to be simplified long-term.

Any good practice / recommendation would be useful. (already read the cookbook)

Command that failed

brew install distroav

Output of command with --verbose --debug

brew install distroav --verbose --debug                                                                            
==> Downloading https://formulae.brew.sh/api/formula.jws.json
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --user-agent Homebrew/4.4.20\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 15.3\)\ curl/8.7.1 --header Accept-Language:\ en --fail --remote-time --output /Users/trouff/Library/Caches/Homebrew/api/formula.jws.json --location --time-cond /Users/trouff/Library/Caches/Homebrew/api/formula.jws.json --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.4.20\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 15.3\)\ curl/8.7.1 --header Accept-Language:\ en --fail --compressed --speed-limit 100 --speed-time 5 https://formulae.brew.sh/api/formula.jws.json
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::NullLoader): loading distroav
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::NullLoader): loading distroav
==> Downloading https://formulae.brew.sh/api/cask.jws.json
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --user-agent Homebrew/4.4.20\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 15.3\)\ curl/8.7.1 --header Accept-Language:\ en --fail --remote-time --output /Users/trouff/Library/Caches/Homebrew/api/cask.jws.json --location --time-cond /Users/trouff/Library/Caches/Homebrew/api/cask.jws.json --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.4.20\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 15.3\)\ curl/8.7.1 --header Accept-Language:\ en --fail --compressed --speed-limit 100 --speed-time 5 https://formulae.brew.sh/api/cask.jws.json
/opt/homebrew/Library/Homebrew/brew.rb (Cask::CaskLoader::FromAPILoader): loading distroav
==> Cask::Installer#install
==> Printing caveats
==> Cask::Installer#fetch
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.4.20\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 15.3\)\ curl/8.7.1 --header Accept-Language:\ en --retry 3 -V
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.4.20\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 15.3\)\ curl/8.7.1 --header Accept-Language:\ en --retry 3 --fail --location --silent --head https://raw.githubusercontent.com/Homebrew/homebrew-cask/7808610546e9c6f2842532a5236278ddb4fa6c07/Casks/d/distroav.rb
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.4.20\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 15.3\)\ curl/8.7.1 --header Accept-Language:\ en --retry 3 --fail --location --silent --head --request GET --http1.1 https://raw.githubusercontent.com/Homebrew/homebrew-cask/7808610546e9c6f2842532a5236278ddb4fa6c07/Casks/d/distroav.rb
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/7808610546e9c6f2842532a5236278ddb4fa6c07/Casks/d/distroav.rb
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.4.20\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 15.3\)\ curl/8.7.1 --header Accept-Language:\ en --fail --connect-timeout 15 --retry 3 --remote-time --output /Users/trouff/Library/Caches/Homebrew/downloads/01cd0d7f516323c903beedca67e9387f377cca8a70eced2ac8cd77a148f0a06e--distroav.rb.incomplete --location https://raw.githubusercontent.com/Homebrew/homebrew-cask/7808610546e9c6f2842532a5236278ddb4fa6c07/Casks/d/distroav.rb
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1662  100  1662    0     0   127k      0 --:--:-- --:--:-- --:--:--  135k
==> Verifying checksum for '01cd0d7f516323c903beedca67e9387f377cca8a70eced2ac8cd77a148f0a06e--distroav.rb'
==> Downloading https://github.com/DistroAV/DistroAV/releases/download/6.0.0/distroav-6.0.0-macos-universal.pkg
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.4.20\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 15.3\)\ curl/8.7.1 --header Accept-Language:\ en --retry 3 -V
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.4.20\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 15.3\)\ curl/8.7.1 --header Accept-Language:\ en --retry 3 --fail --location --silent --head https://github.com/DistroAV/DistroAV/releases/download/6.0.0/distroav-6.0.0-macos-universal.pkg
Already downloaded: /Users/trouff/Library/Caches/Homebrew/downloads/bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg
==> Checking quarantine support
/usr/bin/env /usr/bin/xattr -h
/usr/bin/env /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -target arm64-apple-macosx15 /opt/homebrew/Library/Homebrew/cask/utils/quarantine.swift
==> Quarantine is available.
==> Verifying Gatekeeper status of /Users/trouff/Library/Caches/Homebrew/downloads/bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg
/usr/bin/env /usr/bin/xattr -p com.apple.quarantine /Users/trouff/Library/Caches/Homebrew/downloads/bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg
==> /Users/trouff/Library/Caches/Homebrew/downloads/bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg is quarantined
==> Verifying checksum for 'bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg'
/opt/homebrew/Library/Homebrew/brew.rb (Cask::CaskLoader::FromAPILoader): loading libndi
/usr/bin/env hdiutil imageinfo -format /Users/trouff/Library/Caches/Homebrew/downloads/bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg
All dependencies satisfied.
==> Installing Cask distroav
==> Cask::Installer#stage
==> Extracting primary container
==> Using container class UnpackStrategy::Pkg for /Users/trouff/Library/Caches/Homebrew/downloads/bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg
cp -p /Users/trouff/Library/Caches/Homebrew/downloads/bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg /opt/homebrew/Caskroom/distroav/6.0.0/distroav-6.0.0-macos-universal.pkg
==> Verifying Gatekeeper status of /Users/trouff/Library/Caches/Homebrew/downloads/bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg
/usr/bin/env /usr/bin/xattr -p com.apple.quarantine /Users/trouff/Library/Caches/Homebrew/downloads/bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg
==> /Users/trouff/Library/Caches/Homebrew/downloads/bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg is quarantined
==> Propagating quarantine from /Users/trouff/Library/Caches/Homebrew/downloads/bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg to /opt/homebrew/Caskroom/distroav/6.0.0
/usr/bin/env /usr/bin/xattr -p com.apple.quarantine /Users/trouff/Library/Caches/Homebrew/downloads/bb8c9c4cadd93737cd6758c04350f54f2c5437d7c7556bf3db0d27db85b0e89b--distroav-6.0.0-macos-universal.pkg
/usr/bin/env /usr/bin/xargs -0 -- /bin/chmod -h u+w
/usr/bin/env /usr/bin/xargs -0 -- /usr/bin/xattr -w com.apple.quarantine 0181\;67a4ea46\;Homebrew\\x20Cask\;AB5E43B0-F7B7-4E04-9951-5C9F0F2FDF72
==> Creating metadata directory: /opt/homebrew/Caskroom/distroav/.metadata/6.0.0/20250206224722.529
==> Creating metadata subdirectory: /opt/homebrew/Caskroom/distroav/.metadata/6.0.0/20250206224722.529/Casks
==> Installing artifacts
==> Installing artifact of class Cask::Artifact::PreflightBlock
==> Installing artifact of class Cask::Artifact::Pkg
==> Running installer for distroav with sudo; the password may be necessary.
/usr/bin/sudo -u root -E LOGNAME=trouff USER=trouff USERNAME=trouff -- /usr/sbin/installer -pkg /opt/homebrew/Caskroom/distroav/6.0.0/distroav-6.0.0-macos-universal.pkg -target / -verboseR
Password:
installer: Package name is distroav
installer: Upgrading at base path /
installer:PHASE:Preparing for installation…
installer:PHASE:Preparing the disk…
installer:PHASE:Preparing distroav…
installer:PHASE:Waiting for other installations to complete…
installer:PHASE:Configuring the installation…
installer:STATUS:
installer:%2.229250
installer:PHASE:Validating packages…
installer:%97.750000
installer:STATUS:Running installer actions…
installer:STATUS:
installer:PHASE:Finishing the Installation…
installer:STATUS:
installer:%100.000000
installer:PHASE:The software was successfully installed.
installer: The upgrade was successful.
==> Installing artifact of class Cask::Artifact::PostflightBlock
Creating distroav symlinks in ~/Library/Application Support/obs-studio/plugins
/opt/homebrew/Library/Homebrew/brew.rb (Cask::CaskLoader::FromAPILoader): loading libndi
🍺  distroav was successfully installed!

Result: ls -lh /Library/Application\ Support/obs-studio/plugins && ls -lh ~/Library/Application\ Support/obs-studio/plugins
total 0
drwxr-xr-x  3 root  wheel    96B 16 Oct 09:46 distroav.plugin
drwxr-xr-x  3 root  wheel    96B 16 Oct 09:46 distroav.plugin.dSYM
total 0
lrwxr-xr-x  1 trouff  staff    63B  6 Feb 17:47 distroav.plugin -> /Library/Application Support/obs-studio/plugins/distroav.plugin
lrwxr-xr-x  1 trouff  staff    68B  6 Feb 17:47 distroav.plugin.dSYM -> /Library/Application Support/obs-studio/plugins/distroav.plugin.dSYM

Output of brew doctor and brew config

NA

Output of brew tap

NA
@yunhao-jiang
Copy link
Contributor

By looking at the cask code, I think the reason why it installs in /Library instead of ~/Library is likely to be specified by your distroav-#{version}-macos-universal.pkg instead of homebrew, as the script only runs the pkg file with default options.

@Trouffman
Copy link
Author

Trouffman commented Feb 6, 2025

By looking at the cask code, I think the reason why it installs in /Library instead of ~/Library is likely to be specified by your distroav-#{version}-macos-universal.pkg instead of homebrew, as the script only runs the pkg file with default options.

That is the understanding, but we could not find out where this is set. Hence checking here.

For example, when the .pkg is manually downloaded & launched the only option is the User's Home.
Image

Which is inline with the settings to restrict to "CurrentUserHomeDirectory"
installer -dominfo -pkg distroav.pkg CurrentUserHomeDirectory

Which also aligns with the Domains restricted in the distribution.in config : https://github.com/DistroAV/DistroAV/blob/2e29a55d513d83d743dcaa5dfcb1dbbe2db5395c/cmake/macos/resources/distribution.in#L8

Looking at it, it seems this is only enforced in the installer-gui.

Which MIGHT make sense as if the package is installed from the command line, it need sudo (I guess brew is similar ?).

The other location where the installation target is set is at : https://github.com/DistroAV/DistroAV/blob/2e29a55d513d83d743dcaa5dfcb1dbbe2db5395c/cmake/macos/defaults.cmake#L36

@yunhao-jiang
Copy link
Contributor

yunhao-jiang commented Feb 7, 2025

I'm purely guessing but maybe it is related to this line?

https://github.com/DistroAV/DistroAV/blob/2e29a55d513d83d743dcaa5dfcb1dbbe2db5395c/cmake/macos/helpers.cmake#L39

Will the $(USER_LIBRARY_DIR) correctly expands to ~/Library?

In the Distribution file of your pkg it also shows

<bundle CFBundleShortVersionString="6.0.0" CFBundleVersion="11366971121" id="org.distroav.distroav" path="Library/Application Support/obs-studio/plugins/distroav.plugin"/>

@Trouffman
Copy link
Author

Thanks for poiting this out. Will investigate.

I found out as well that when installing the pacakge manually via installer command it will work properly if using :
installer -pkg distroav-6.0.0-macos-universal.pkg -target CurrentUserHomeDirectory -verbose
This install in ~/Library...

With sudo this fail ( as no home directory exists i guess
sudo installer -pkg distroav-6.0.0-macos-universal.pkg -target CurrentUserHomeDirectory -verbose
Error returned:

The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance. An unexpected error occurred while moving files to the final destination.

And targeting / does install in /Library (expected but not wanted)
sudo installer -pkg distroav-6.0.0-macos-universal.pkg -target / -verbose

Either we have a settings not set properly (as @yunhao-jiang pointed out above) or something else does not enforce the proper path.

Also, this should jsut fail if trying to install anywhere else than Home library.

@Trouffman
Copy link
Author

@yunhao-jiang I did soem check and changing things in helpers.cmake L39 does not appear to change anywhere else.

Same when trying to modify in defaults.cmake.

The only place i have found to change is in the cfreate-pacakge.cmake.in but this is not directly related to the install-path.

DistroAV try to stick as close to the OBS plugin template which suggest, that other plugin on brew would have the same type of issues.

I am out of options to figure things out.

@bevanjkay
Copy link
Member

There is a part to this issue that I would consider somewhat of an oddity on the OBS side.
The OBS application is installed by default for all users in /Applications/OBS.app, however the plugins are installed in the user folder. An additional concern is that in some contexts Homebrew may be executed by a user that is dedicated to Homebrew, so we try to avoid scoping things specific to an individual user. The symlinks in the distroav cask are an exception to this, but it was the best option at the time. I am not seeing any leftovers myself when installing/uninstalling the cask, can you provide a bit more information about what isn't being removed?

@Trouffman
Copy link
Author

Indeed, plugin are user based but OBS is system wide.

It's a choice by OBS folks to have it as such. This vision and package deployment seems to conflict a bit on that.

The cask does NOT leave anything being as of today.

The main challenge was that we changed the name from OBS-ndi to distroAV and we decided to let the user "clean-up/uninstall" themselves. If old files still exist it prevent from running the new version until cleaned-up.

Was fine until we got a surge of folks with the plugin installed in /Library, and up until recently could never reproduce/find the reason why :D. It's here :) (not saying it's homebrew's fault either).

In a hindsight, we should have "uninstalled + cleaned-up" old files ourselves when changing names.

For the longer term :

  • We are considering adding some clean-up / check for this.
  • Might add some extra step in the cask as well (That are specific to brew), once we have the updated installation (with cleanup).

I guess this can be closed then...

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

3 participants