Error : Two sets of Qt binaries being loaded into the same process

I’m trying to package rstudio in MacBook Air 2019 with Intel CPU. Using nixos-21.11 packages with few tweaking through overlay in flake.nix, I’ve managed to pass through installPhase with the command nix develop .#pkgs_2111.x86_64-darwin.rstudioWrapper. However, when I try to nix run .#pkgs_2111.x86_64-darwin.rstudioWrapper, the following error occurs.
It is complaining that libQt5Core.5.dylib is in both qtbase package and rstudio package. I’ve inspected them with nix-tree and qtbase is from qtwebengine needed by rstudio. rstudio itself has libQt5Core.5.dylib directly.

objc[49639]: Class QMacAutoReleasePoolTracker is implemented in both /nix/store/r2jrhrwr9r1c2x2i06radsgvqqirz3vl-RStudio-1.4.1717/lib/rstudio/RStudio.app/Contents/Frameworks/libQt5Core.5.dylib (0x105cc6ab
8) and /nix/store/rhrhv2dgpb79wcj1rqlmv8nqrnyj6d7p-qtbase-5.12.10/lib/libQt5Core.5.12.10.dylib (0x111cb5ab8). One of the two will be used. Which one is undefined.
objc[49639]: Class QT_ROOT_LEVEL_POOL__THESE_OBJECTS_WILL_BE_RELEASED_WHEN_QAPP_GOES_OUT_OF_SCOPE is implemented in both /nix/store/r2jrhrwr9r1c2x2i06radsgvqqirz3vl-RStudio-1.4.1717/lib/rstudio/RStudio.ap
p/Contents/Frameworks/libQt5Core.5.dylib (0x105cc6b30) and /nix/store/rhrhv2dgpb79wcj1rqlmv8nqrnyj6d7p-qtbase-5.12.10/lib/libQt5Core.5.12.10.dylib (0x111cb5b30). One of the two will be used. Which one is 
undefined.                                                                                                   
objc[49639]: Class KeyValueObserver is implemented in both /nix/store/r2jrhrwr9r1c2x2i06radsgvqqirz3vl-RStudio-1.4.1717/lib/rstudio/RStudio.app/Contents/Frameworks/libQt5Core.5.dylib (0x105cc6b58) and /ni
x/store/rhrhv2dgpb79wcj1rqlmv8nqrnyj6d7p-qtbase-5.12.10/lib/libQt5Core.5.12.10.dylib (0x111cb5b58). One of the two will be used. Which one is undefined.
objc[49639]: Class RunLoopModeTracker is implemented in both /nix/store/r2jrhrwr9r1c2x2i06radsgvqqirz3vl-RStudio-1.4.1717/lib/rstudio/RStudio.app/Contents/Frameworks/libQt5Core.5.dylib (0x105cc6ba8) and /
nix/store/rhrhv2dgpb79wcj1rqlmv8nqrnyj6d7p-qtbase-5.12.10/lib/libQt5Core.5.12.10.dylib (0x111cb5ba8). One of the two will be used. Which one is undefined.
objc[49639]: Class QCocoaPageLayoutDelegate is implemented in both /nix/store/r2jrhrwr9r1c2x2i06radsgvqqirz3vl-RStudio-1.4.1717/lib/rstudio/RStudio.app/Contents/Frameworks/libQt5PrintSupport.5.dylib (0x10
2e70478) and /nix/store/rhrhv2dgpb79wcj1rqlmv8nqrnyj6d7p-qtbase-5.12.10/lib/libQt5PrintSupport.5.12.10.dylib (0x106e01478). One of the two will be used. Which one is undefined.
objc[49639]: Class QCocoaPrintPanelDelegate is implemented in both /nix/store/r2jrhrwr9r1c2x2i06radsgvqqirz3vl-RStudio-1.4.1717/lib/rstudio/RStudio.app/Contents/Frameworks/libQt5PrintSupport.5.dylib (0x10
2e704f0) and /nix/store/rhrhv2dgpb79wcj1rqlmv8nqrnyj6d7p-qtbase-5.12.10/lib/libQt5PrintSupport.5.12.10.dylib (0x106e014f0). One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x6000031c0070) is not the object's thread (0x6000031c8fc0).          
Cannot move to target thread (0x6000031c0070)                                                                
                                                                                                             
You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries
 are being loaded.                                                                                           
qt.qpa.plugin: Could not load the Qt platform plugin "cocoa" in "" even though it was found.                 
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
                                                                                                             
Available platform plugins are: cocoa, minimal, offscreen.

I’ve tried erasing libQt5Core.5.dylib in rstudio output with overriden postInstall phase as follows.

postInstall = old.postInstall + ''
  rm -r $out/lib/rstudio/RStudio.app/Contents/Frameworks/{libQt5Core.5.dylib,libQt5PrintSupport.5.dylib}
'';

Then the following error occurs.

dyld[11901]: Library not loaded: '@executable_path/../Frameworks/libQt5PrintSupport.5.dylib'                                                                                                                
  Referenced from: '/nix/store/py0xap4y2h3mjcy2l7ai9iahi4vljr2n-RStudio-1.4.1717/lib/rstudio/RStudio.app/Contents/MacOS/RStudio'                                                     
  Reason: tried: '/nix/store/py0xap4y2h3mjcy2l7ai9iahi4vljr2n-RStudio-1.4.1717/lib/rstudio/RStudio.app/Contents/MacOS/../Frameworks/libQt5PrintSupport.5.dylib' (no such file), '/usr/local/lib/libQt5PrintS
upport.5.dylib' (no such file), '/usr/lib/libQt5PrintSupport.5.dylib'

How do I set it so that it only reference libQt5PrintSupport.5.dylib from rstudio and not from qtbase?

I have a similar problem, running nix 2.19.2 on an Intel Mac (macOS 14.4.1). I have two repos that use slightly different commits of root-6.24.02, and nix gets confused when both sets of binaries are present

(.virtualenv) |13:11:07|~/code/lhcb-ntuples-gen/workflows$ ./JpsiK.py JpsiK-ntuple-run2-mc-demo
==== Job: JpsiK-ntuple-run2-mc-demo ====
Working on /Users/manuelf/code/lhcb-ntuples-gen/run2-JpsiK/samples/JpsiK--22_02_22--mc--Bu2JpsiK--2016--md--py8-sim09k-dv45-subset.root...
No aux ntuple cached, generating anew...
objc[63623]: Class RunStopper is implemented in both /nix/store/z32fdal41d4sblyss2mwpmz6vvqxxvdw-root-6.24.02/lib/libCore.so (0x111292cd0) and /nix/store/21z7afnwbsgr6pwh6m1avmyikr5gj7sp-root-6.24.02/lib/libCore.so (0x1119d4cd0). One of the two will be used. Which one is undefined.

 *** Break *** segmentation violation
[/usr/lib/system/libsystem_platform.dylib] _sigtramp (no debug info)
[/usr/lib/system/libsystem_malloc.dylib] free_small (no debug info)
[/nix/store/z32fdal41d4sblyss2mwpmz6vvqxxvdw-root-6.24.02/lib/libCling.so] llvm::sys::DynamicLibrary::addPermanentLibrary(void*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*) (no debug info)
[/nix/store/z32fdal41d4sblyss2mwpmz6vvqxxvdw-root-6.24.02/lib/libCling.so] CreateInterpreter (no debug info)
[/nix/store/21z7afnwbsgr6pwh6m1avmyikr5gj7sp-root-6.24.02/lib/libCore.so] TROOT::InitInterpreter() (no debug info)
...

I can run the repos if I delete the version not used by each repo, but that is a pain. I would have thought those binaries should be isolated. Is this a bug that only affects macs?