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

QT Designer does not start on MacOS #4700

Closed
slicerbot opened this issue Mar 13, 2020 · 31 comments
Closed

QT Designer does not start on MacOS #4700

slicerbot opened this issue Mar 13, 2020 · 31 comments
Assignees
Labels
Type: Bug Something isn't working correctly
Milestone

Comments

@slicerbot
Copy link
Collaborator

This issue was created automatically from an original Mantis Issue. Further discussion may take place here.

@slicerbot slicerbot added this to the Slicer 4.11.0 milestone Mar 13, 2020
@lassoan lassoan changed the title QT Designer does not start QT Designer does not start on MacOS Mar 21, 2020
@lassoan
Copy link
Contributor

lassoan commented Mar 26, 2020

@pieper Could you test this?

@pieper
Copy link
Member

pieper commented Mar 26, 2020

On local machine ./Slicer-build/Slicer --designer just launches regular slicer with no indication that the flag did anything. Same with a nightly build download.

@jcfr
Copy link
Member

jcfr commented Mar 26, 2020

On macOS, starting QtDesigner can be done without launcher because it is properly fixed up for either the build tree or the downloaded package.

That said, having a consistent interface is important to streamline the user/developer experience.

There are two cases:

  • (1) build tree: Slicer is a launcher .. and specifying --designer is expected to work.
  • (2) downloaded package: Slicer is not a launcher. We will have account for this. The good news is that we already have an "AppLauncherLib"' available on macOS and we could use this to parse the launcher settings and update the argument supported by the regular Slicer executable based on this.

First, we should address (1)

@jcfr
Copy link
Member

jcfr commented Mar 26, 2020

(1) build tree: Slicer is a launcher .. and specifying --designer is expected to work.

I am not able to reproduce the problem. @pieper Could you try the following and report the output. Especially the part with Starting.

$ ./Slicer  --designer --launcher-verbose

For example, here is what I get on the factory:

[...]
info: Starting [/Volumes/Dashboards/Support/qt-everywhere-build-5.10.0/bin/designer.app/Contents/MacOS/Designer]
info: launcher-timeout (ms) [-1000]
info: DisableSplash [1]
[...]

@lassoan
Copy link
Contributor

lassoan commented Mar 26, 2020

Please also try if these work?

  • DICOM module / Reload&Test section / Edit UI button opens Qt designer (with the module's GUI)
  • menu: Edit / Application settings / Developer / Qt Designer / launch button opens Qt designer

@pieper
Copy link
Member

pieper commented Mar 26, 2020

$ ./Slicer-build/Slicer --designer --launcher-verbose
info: AdditionalSettingsFilePath []
info: LauncherSplashImagePath [/Users/pieper/slicer/latest/Slicer/Applications/SlicerApp/Resources/Images/Slicer-SplashScreen.png]
info: LauncherSplashScreenHideDelayMs [3000]
info: ApplicationToLaunch [/s/Slicer-build/bin/Slicer.app/Contents/MacOS/./Slicer]
info: ApplicationToLaunchArguments []
info: AdditionalSettingsFilePath []
info: LauncherDir [/s/Slicer-build]
info: LauncherName [Slicer]
info: OrganizationDomain [www.na-mic.org]
info: OrganizationName [NA-MIC]
info: ApplicationName [Slicer]
info: ApplicationRevision [28881]
info: SettingsFileName [/s/Slicer-build/./SlicerLauncherSettings.ini]
info: SettingsDir [/s/Slicer-build]
info: UserAdditionalSettingsDir [/Users/pieper/.config/www.na-mic.org]
info: UserAdditionalSettingsFileName [/Users/pieper/.config/www.na-mic.org/Slicer-28881.ini]
info: UserAdditionalSettingsFileBaseName []
info: AdditionalSettingsDir []
info: AdditionalSettingsExcludeGroups []
info: LauncherNoSplashScreen [0]
info: AdditionalLauncherHelpShortArgument [-h]
info: AdditionalLauncherHelpLongArgument [--help]
info: AdditionalLauncherNoSplashArguments [--no-splash,--help,--version,--home,--program-path,--no-main-window,--settings-path,--temporary-path]
info: DetachApplicationToLaunch [0]
info: LoadEnvironment [-1]
info: LauncherSplashImagePath [/Users/pieper/slicer/latest/Slicer/Applications/SlicerApp/Resources/Images/Slicer-SplashScreen.png]
info: LauncherSplashScreenHideDelayMs [3000]
info: ApplicationToLaunch [/s/Slicer-build/bin/Slicer.app/Contents/MacOS/./Slicer]
info: ApplicationToLaunchArguments []
info: <APPLAUNCHER_DIR> -> [/s/Slicer-build]
info: <APPLAUNCHER_NAME> -> [Slicer]
info: <APPLAUNCHER_SETTINGS_DIR> (RegularSettings) -> [/s/Slicer-build]
info: <APPLAUNCHER_SETTINGS_DIR> (UserAdditionalSettings) -> [/Users/pieper/.config/www.na-mic.org]
info: <APPLAUNCHER_SETTINGS_DIR> (AdditionalSettings) -> [<APPLAUNCHER_SETTINGS_DIR-NOTFOUND>]
info: <PATHSEP> -> [:]
info: Setting env. variable [SLICER_HOME]:/s/Slicer-build
info: Setting env. variable [PIP_REQUIRE_VIRTUALENV]:0
info: Setting env. variable [ITK_AUTOLOAD_PATH]:/s/Slicer-build/lib/Slicer-4.11/ITKFactories/.
info: Setting env. variable [PYTHONNOUSERSITE]:1
info: Setting env. variable [PYTHONHOME]:/s/python-install
info: Setting env. variable [SSL_CERT_FILE]:/s/Slicer-build/share/Slicer-4.11/Slicer.crt
info: Setting env. variable [PATH]:/s/Slicer-build/bin/.:/usr/local/opt/qt5/bin:/s/Slicer-build/lib/Slicer-4.11/cli-modules/.:/s/python-install/bin:/s/teem-build/bin/.
info: Setting env. variable [QT_PLUGIN_PATH]:/s/Slicer-build/bin:/s/CTK-build/CTK-build/bin:/usr/local/opt/qt5/plugins
info: Setting env. variable [DYLD_LIBRARY_PATH]:/s/Slicer-build/bin/.:../lib/Slicer-4.11/qt-loadable-modules:/s/Slicer-build/lib/Slicer-4.11/cli-modules/.:/s/Slicer-build/lib/Slicer-4.11/qt-loadable-modules/.:/s/OpenSSL:/s/python-install/lib:/s/VTK-build/lib/.:/s/teem-build/bin/.:/s/DCMTK-build/lib/.:/s/ITK-build/lib/.:/s/CTK-build/CTK-build/bin/.:/s/CTK-build/QtTesting-build/.:/s/CTK-build/PythonQt-build/.:/s/LibArchive-install/lib:/s/SimpleITK-build/SimpleITK-build/lib/.:/s/JsonCpp-build/src/lib_json/.:/s/ParameterSerializer-build/lib/.:/s/SlicerExecutionModel-build/ModuleDescriptionParser/bin/.:/s/python-install/lib/python3.6/site-packages/numpy/core:/s/python-install/lib/python3.6/site-packages/numpy/lib
info: Setting env. variable [PYTHONPATH]:/s/Slicer-build/bin/.:/s/Slicer-build/bin/Python:/s/Slicer-build/lib/Slicer-4.11/qt-loadable-modules/.:/s/Slicer-build/lib/Slicer-4.11/qt-loadable-modules/Python:/s/Slicer-build/lib/Slicer-4.11/qt-scripted-modules:/s/python-install/lib/python3.6:/s/python-install/lib/python3.6/lib-dynload:/s/python-install/lib/python3.6/site-packages:/s/VTK-build/lib/python3.6/site-packages:/s/CTK-build/CTK-build/bin/Python:/s/CTK-build/CTK-build/bin/.
info: Starting [/s/Slicer-build/bin/Slicer.app/Contents/MacOS/./Slicer]
info: argument [--designer]
info: launcher-timeout (ms) [-1000]
info: DisableSplash [0]
2020-03-26 15:20:24.841 Slicer[39132:46699172] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead. 
toInt : value  10  for singleStep  1e-12  is out of integer bounds !
toInt : value  10  for singleStep  1e-12  is out of integer bounds !
toInt : value  10  for singleStep  1e-12  is out of integer bounds !
Switch to module:  "Welcome"

@pieper
Copy link
Member

pieper commented Mar 26, 2020

It's probably because I built with a homebrew Qt that doesn't include the designer. I'm not seeing that there's a way to install it via brew.

The path exists and it has all the other qt executables but no designer.

This prints when I click either of the buttons @lassoan suggested:

error: Application does NOT exists [/s/Slicer-build/bin/../../../usr/local/opt/qt5/bin/Designer.app/Contents/MacOS/./designer]
Usage
  SlicerDesigner [options]

Options
  --launcher-help                                 Display help
  --launcher-version                              Show launcher version information
  --launcher-verbose                              Verbose mode
  --launch                                        Specify the application to launch
  --launcher-detach                               Launcher will NOT wait for the application to finish
  --launcher-no-splash                            Hide launcher splash
  --launcher-timeout                              Specify the time in second before the launcher kills the application. -1 means no timeout (default: -1)
  --launcher-load-environment                     Specify the saved environment to load.
  --launcher-dump-environment                     Launcher will print environment variables to be set, then exit
  --launcher-show-set-environment-commands        Launcher will print commands suitable for setting the parent environment (i.e. using 'eval' in a POSIX shell), then exit
  --launcher-additional-settings                  Additional settings file to consider
  --launcher-additional-settings-exclude-groups   Comma separated list of settings groups that should NOT be overwritten by values in User and Additional settings. For example: General,Application,ExtraApplicationToLaunch
  --launcher-ignore-user-additional-settings      Ignore additional user settings
  --launcher-generate-exec-wrapper-script         Generate executable wrapper script allowing to set the environment
  --launcher-generate-template                    Generate an example of setting file

@lassoan
Copy link
Contributor

lassoan commented Mar 26, 2020

Do the "Edit UI" and "launch" buttons work well in an installed official Slicer Preview Release?

It's probably because I built with a homebrew Qt that doesn't include the designer. I'm not seeing that there's a way to install it via brew.

You cannot develop classic desktop applications without Qt designer, so there must be an option to install it via homebrew. Maybe it comes with Qt Creator. We could make qSlicerApplication::launchDesigner method more intelligent by also searching at typical Qt Creator install locations.

@pieper
Copy link
Member

pieper commented Mar 26, 2020

Do the "Edit UI" and "launch" buttons work well in an installed official Slicer Preview Release?

Yes, but I get this error when I do Edit UI in the module.

image

so there must be an option to install it via homebrew

Yes, I can get this

image

@jcfr
Copy link
Member

jcfr commented Mar 26, 2020

re: (1) build tree

That makes then. Since no designer was found at configuration time, the launcher settings for the build tree didn't include the --designer option ... and it was then considered as a regular Slicer option.

We could improve the build system to always add the launcher option but when designer is missing, it could instead starts Slicer with something like this :

Slicer --no-main-window --disable-modules --python-code 'qt.QMessageBox.critical(0, "Slicer", "Check your Qt install : QtDesigner executable was not found !")'

@jcfr
Copy link
Member

jcfr commented Mar 26, 2020

re: homebrew

@pieper Is qtdesigner in the libexec folder in your install ?

See https://github.com/Homebrew/homebrew-core/blob/26e125fc09298c120e2d3bf5dc557493fdeb0f49/Formula/qt.rb#L64-L67

@lassoan
Copy link
Contributor

lassoan commented Mar 26, 2020

downloaded package: Slicer is not a launcher. We will have account for this. The good news is that we already have an "AppLauncherLib"' available on macOS and we could use this to parse the launcher settings and update the argument supported by the regular Slicer executable based on this.

I don't think it is necessary to have the Slicer --designer shortcut to launch Qt designer in an installed package, but if we want then we can map Slicer --designer shortcut to Slicer --testing --no-main-window --python-code slicer.app.launchDesigner() instead.

@pieper
Copy link
Member

pieper commented Mar 26, 2020

@pieper Is qtdesigner in the libexec folder in your install ?

Yes! This launches the right one:

$ /usr/local/opt/qt5/libexec/Designer.app/Contents/MacOS/Designer

@fepegar
Copy link
Contributor

fepegar commented Jul 29, 2020

Hi all,

I came here to report this issue. I just got this after running startQtDesigner() in the console:
Screen Shot 2020-07-29 at 17 23 51

Slicer 4.11.0-2020-07-27 r29229 / 1217275.

@lassoan
Copy link
Contributor

lassoan commented Aug 26, 2020

@pieper you've worked on Qt related issues on Mac, could you have a look at this? Maybe qSlicerApplication::launchDesigner can be updated to run the designer directly instead of via a launcher.

@pieper
Copy link
Member

pieper commented Aug 26, 2020

Since I did brew cask install qt-creator after I'd configured my slicer build, I didn't have the --designer option and startQtDesigner() does nothing, as expected from @jcfr 's comment above.

But if I start slicer with this command the designer starts with all the Slicer widgets available:

/opt/s/Slicer-build/Slicer --launch /usr/local/opt/qt5/libexec/Designer.app/Contents/MacOS/Designer

I'm rebuilding from scratch now to see if the designer from homebrew is detected.

@pieper
Copy link
Member

pieper commented Aug 26, 2020

With a fresh build and qt-creator installed --designer still starts Slicer instead of Designer. If I run startDesigner() I get the message below, so I guess the path is just not detected correctly for the homebrew case.

 ./Slicer-build/Slicer --designer
2020-08-26 13:52:53.809 Slicer[77456:41501397] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead. 
Switch to module:  "Welcome"
Loading Slicer RC file [/Users/pieper/.slicerrc.py]
Python console user input: startQtDesigner()
True
error: Application does NOT exists [/opt/sr/Slicer-build/bin/../../../../usr/local/Cellar/qt/5.15.0/bin/Designer.app/Contents/MacOS/./designer]
Usage
  SlicerDesigner [options]

Options
  --launcher-help                                 Display help
  --launcher-version                              Show launcher version information
  --launcher-verbose                              Verbose mode
  --launch                                        Specify the application to launch
  --launcher-detach                               Launcher will NOT wait for the application to finish
  --launcher-no-splash                            Hide launcher splash
  --launcher-timeout                              Specify the time in second before the launcher kills the application. -1 means no timeout (default: -1)
  --launcher-load-environment                     Specify the saved environment to load.
  --launcher-dump-environment                     Launcher will print environment variables to be set, then exit
  --launcher-show-set-environment-commands        Launcher will print commands suitable for setting the parent environment (i.e. using 'eval' in a POSIX shell), then exit
  --launcher-additional-settings                  Additional settings file to consider
  --launcher-additional-settings-exclude-groups   Comma separated list of settings groups that should NOT be overwritten by values in User and Additional settings. For example: General,Application,ExtraApplicationToLaunch
  --launcher-ignore-user-additional-settings      Ignore additional user settings
  --launcher-generate-exec-wrapper-script         Generate executable wrapper script allowing to set the environment
  --launcher-generate-template                    Generate an example of setting file

@naterex23
Copy link

naterex23 commented Oct 3, 2020

I'm having a very similar issue to above. When I execute startQtDesigner() I get the following console output:

Python console user input: startQtDesigner() True dyld: Library not loaded: /Volumes/D/Support/qt-everywhere-build-5.15.0/lib/QtDesignerComponents.framework/Versions/5/QtDesignerComponents Referenced from: /Applications/Slicer.app/Contents/bin/Designer.app/Contents/MacOS/Designer Reason: image not found error: [/Applications/Slicer.app/Contents/bin/Designer.app/Contents/MacOS/Designer] exit abnormally - Report the problem.

When I try to run the aforementioned /opt/s/Slicer-build/Slicer --launch /usr/local/opt/qt5/libexec/Designer.app/Contents/MacOS/Designer Slicer successfully opens but nothing further seems to happen. Any thoughts or advice?

@lassoan
Copy link
Contributor

lassoan commented Oct 4, 2020

Does Qt designer work if you run it from an installed Slicer (that you got from download.slicer.org)?

@naterex23
Copy link

naterex23 commented Oct 4, 2020

Previously I was using 4.11 ~mid July nightly build. I just upgraded to the most recent stable release (10/2) of 4.11 and continue to have the same issues, although now when I execute the command startQtDesigner() instead of an error the command returns True but nothing else seems to happen. The ./Slicer --designer method (as documented at https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/QtDesigner) still seems to just open a regular version of slicer.

@hina-shah
Copy link
Contributor

Hello all. After installing Slicer-4.13 rev 29461 on my Mac. I tried Application Settings->Developer->Qt Designer -> launch button, and the designer does not launch with a Designer cannot be opened error. I tried looking in the log and get the following error: [CRITICAL][FD] 06.11.2020 00:06:28 [] (unknown:0) - dyld: Library not loaded: /Volumes/D/Support/qt-everywhere-build-5.15.1/lib/QtDesignerComponents.framework/Versions/5/QtDesignerComponents [CRITICAL][FD] 06.11.2020 00:06:28 [] (unknown:0) - Referenced from: /Applications/Slicer.app/Contents/bin/Designer.app/Contents/MacOS/Designer [CRITICAL][FD] 06.11.2020 00:06:28 [] (unknown:0) - Reason: image not found [CRITICAL][FD] 06.11.2020 00:06:28 [] (unknown:0) - error: [/Applications/Slicer.app/Contents/bin/Designer.app/Contents/MacOS/Designer] exit abnormally - Report the problem.

Alternatively, I also tried runnning /Applications/Slicer.app/Contents/MacOS/bin/Designer/Contents/MacOS/Designer, and get the error:
dyld: Library not loaded: /Volumes/D/Support/qt-everywhere-build-5.15.1/lib/QtDesignerComponents.framework/Versions/5/QtDesignerComponents Referenced from: /Applications/Slicer.app/Contents/bin/Designer.app/Contents/MacOS/Designer Reason: image not found

I don't know if this helps or not, but having a hardcoded path to a build of Qt does not seem right.

@lassoan lassoan added the Type: Bug Something isn't working correctly label Nov 6, 2020
@charuu
Copy link

charuu commented Jan 7, 2021

I am facing the same issue above.Has it been resolved on the stable build for Mac

@charuu
Copy link

charuu commented Jan 7, 2021

dyld: Library not loaded: /Volumes/D/Support/qt-everywhere-build-5.15.1/lib/QtDesignerComponents.framework/Versions/5/QtDesignerComponents
Referenced from: /
Slicer/Contents/bin/Designer.app/Contents/MacOS/Designer
Reason: image not found
error: [Slicer/Contents/bin/Designer.app/Contents/MacOS/Designer] exit abnormally - Report the problem.
I get this message on clicking Edit UI

@piiq
Copy link
Contributor

piiq commented Jan 28, 2021

Debugging the situation with Qt Designer on macOS

I am using macOS for my daily work and I desperately needed Qt Designer. Since Qt Designer doesn't work out of the box I went through some debugging to get Qt Designer working on my macOS 11.1 machine.

What works

The only way I have managed to make Qt Designer work is by completing the following steps:

  1. Build Qt from source. I've built Qt 5.15.2 using the following set of commands
  2. Build Slicer with the Qt5 that was built on the local machine
  3. Before packaging Slicer if I call ./Slicer --designer inside the Slicer-build folder, Qt Designer launches correctly with all Slicer related widgets bundled.

The only strange thing (if I can say so) I can see is that if I run ./Slicer --designer --laucher-verbose the terminal output says that
info: ApplicationToLaunch [/Users/p2p/Qt/bin/designer.app/Contents/MacOS/Designer] pointing to Qt Designer that was built with Qt and not the instance that's bundled with the built Slicer.


What doesn't work

Using the same launcher if I try to run Qt Designer from the GUI by either going to

  • Application settings -> Developer -> Qt Designer -> press the "launch" button
  • or by pressing the "Edit UI" button in the "Reload&Test" section of any python module

Nothing happens


I've tried some other options:

  • Launching Slicer.app/Contents/MacOS/Slicer --designer from the packaged version of the same build launches Slicer instead of Qt Designer with no warnings or errors.
  • Launching Slicer.app/Contents/MacOS/Slicer --designer from the downloaded version of the app launches Slicer instead of Qt Designer with no warnings or errors.
  • When asking downloaded Slicer to launch Qt Designer that was built from source like this /Applications/MedicalImaging/Slicer.app/Contents/MacOS/Slicer --launch ~/Qt/bin/Designer.app/Contents/MacOS/Designer the terminal logs errors (linked in this gist) and regular Slicer UI appears.
  • When asking downloaded Slicer to launch Qt Designer from python like this Slicer.app/Contents/MacOS/Slicer --testing --no-main-window --python-code "slicer.app.launchDesigner()" the error appears saying:
dyld: Library not loaded: /Volumes/D/Support/qt-everywhere-build-5.15.1/lib/QtDesignerComponents.framework/Versions/5/QtDesignerComponents
  Referenced from: /Applications/MedicalImaging/Slicer.app/Contents/bin/Designer.app/Contents/MacOS/Designer
  Reason: image not found
error: [/Applications/MedicalImaging/Slicer.app/Contents/bin/Designer.app/Contents/MacOS/Designer] exit abnormally - Report the problem.
  • I can see the same error as above if I run Slicer.app/Contents/bin/SlicerDesigner from the downloaded version.
  • If I run SlicerDesigner from the packaged version of the locally built app I get a different error:
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.

Abort trap: 6

I hope this information will help finding a solution to make macOS version of Slicer fully functional. In the mean time, please don't kill the Slicer --designer shortcut because it's the only way to get Qt Designer to run with all the necessary Slicer widgets on macOS.

@lassoan
Copy link
Contributor

lassoan commented May 5, 2021

I've debugged this and found that designer has absolute paths burnt in for Qt framework:

$ otool -l /Applications/Slicer.app/Contents/bin/Designer.app/Contents/MacOS/Designer
...
Load command 12
          cmd LC_LOAD_DYLIB
      cmdsize 144
         name /Volumes/D/Support/qt-everywhere-build-5.15.1/lib/QtDesignerComponents.framework/Versions/5/QtDesignerComponents (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 5.15.1
compatibility version 5.15.0
Load command 13
          cmd LC_LOAD_DYLIB
      cmdsize 120
         name /Volumes/D/Support/qt-everywhere-build-5.15.1/lib/QtDesigner.framework/Versions/5/QtDesigner (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 5.15.1
compatibility version 5.15.0
...

Instead of these absolute paths, we should see relative paths. For example, Qt designer installed by Qt:

$ otool -l ~/Qt5/5.15.0/clang_64/bin/Designer.app/Contents/MacOS/Designer 
...
Load command 12
          cmd LC_LOAD_DYLIB
      cmdsize 96
         name @rpath/QtDesignerComponents.framework/Versions/5/QtDesignerComponents (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 5.15.0
compatibility version 5.15.0
Load command 13
          cmd LC_LOAD_DYLIB
      cmdsize 80
         name @rpath/QtDesigner.framework/Versions/5/QtDesigner (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 5.15.0
compatibility version 5.15.0
Load command 14
          cmd LC_LOAD_DYLIB
      cmdsize 88
         name @rpath/QtPrintSupport.framework/Versions/5/QtPrintSupport (offset 24)
   time stamp 2 Wed Dec 31 19:00:02 1969
      current version 5.15.0
compatibility version 5.15.0

I could make the designer work manually by the following steps:

  • replace Designer with the one taken from the official Qt install (it uses rpaths to specify Frameworks location)
  • copy Frameworks folder content to two additional places:
    • /Applications/Slicer.app/Contents/bin/Designer.app/Contents/Frameworks
    • /Applications/Slicer.app/Contents/lib/Frameworks

@pieper Would you be able to fix the Designer installation based on these information?

@pieper
Copy link
Member

pieper commented May 5, 2021

That would certainly explain things.

@pieper Would you be able to fix the Designer installation based on these information?

I would think it can be done but I haven't looked at the mac packaging process (at least not for many years). Maybe @jcfr or @sjh26 would know where these changes would go?

@jcfr
Copy link
Member

jcfr commented Nov 10, 2021

The CMake code responsible for fixing up the designer is executable is the following:

# Since BundleUtilities module does not know how to install .app directory within
# an existing app, the following explicitly install the designer application as well
# as the QtDesignerComponents.framework.
set(Slicer_BUILD_QT_DESIGNER_PLUGINS "@Slicer_BUILD_QT_DESIGNER_PLUGINS@")
set(designer_app_subdir "Designer.app")
set(designer_src_dir "${qt_root_dir}/../bin/${designer_app_subdir}")
set(designer_dest_dir "${app_dir}/Contents/bin/${designer_app_subdir}")
if(Slicer_BUILD_QT_DESIGNER_PLUGINS AND EXISTS ${designer_src_dir})
# Designer
file(COPY "${designer_src_dir}/Contents" DESTINATION "${designer_dest_dir}/" USE_SOURCE_PERMISSIONS)
set(designer_executable "${designer_dest_dir}/Contents/MacOS/Designer")
# Collect list of Qt framework dependencies
set(prereqs )
get_prerequisites(${designer_executable} "prereqs" 1 0 "" "")
# Generate list of "-change" arguments
set(changes "")
foreach(item ${prereqs})
gp_item_default_embedded_path_override("${item}" path)
get_filename_component(item_name "${item}" NAME)
# Examples of values:
# item : /Volumes/Dashboards/Support/qt-everywhere-build-5.10.0/lib/QtNetwork.framework/Versions/5/QtNetwork
# item_name : QtNetwork
# path : @rpath/Frameworks
# embedded_item : @rpath/Frameworks/QtNetwork.framework/Versions/5/QtNetwork
string(REGEX REPLACE "^.*(${item_name}.framework/.*/?${item_name}).*$" "${path}/\\1" embedded_item "${item}")
set(changes ${changes} "-change" "${item}" "${embedded_item}")
endforeach()
# Update executable
execute_process(COMMAND install_name_tool
-rpath "@executable_path/Frameworks" "@loader_path/../../../../"
${changes} "${designer_executable}"
)
# Generate qt.conf file to override plugin paths and ensure plugins provided
# by Slicer package are loaded
file(WRITE "${designer_dest_dir}/Contents/Resources/qt.conf" "[Paths]
Plugins=../../../@Slicer_QtPlugins_DIR@
")
# QtDesignerComponents.framework
set(resolved_item "${qt_root_dir}/QtDesignerComponents.framework/Versions/5/QtDesignerComponents")
set(resolved_embedded_item "${app_dir}/Contents/Frameworks/QtDesignerComponents.framework/Versions/5/QtDesignerComponents")
copy_resolved_framework_into_bundle("${resolved_item}" "${resolved_embedded_item}")
# Collect list of Qt framework dependencies
set(prereqs )
get_prerequisites(${resolved_embedded_item} "prereqs" 1 0 "" "")
# Generate list of "-change" arguments
set(changes "")
foreach(item ${prereqs})
gp_item_default_embedded_path_override("${item}" path)
get_filename_component(item_name "${item}" NAME)
string(REGEX REPLACE "^.*(${item_name}.framework/.*/?${item_name}).*$" "${path}/\\1" embedded_item "${item}")
set(changes ${changes} "-change" "${item}" "${embedded_item}")
endforeach()
# Update executable
execute_process(COMMAND install_name_tool
${changes} -id "@rpath/Frameworks/QtDesignerComponents.framework/Versions/5/QtDesignerComponents"
"${resolved_embedded_item}"
)
endif()
endif()

the first part generates the following command responsible for fixing up the Designer executable:

install_name_tool \
  -rpath "@executable_path/Frameworks" "@loader_path/../../../../" \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtCore.framework/Versions/5/QtCore \
    @rpath/Frameworks/QtCore.framework/Versions/5/QtCore \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtDesigner.framework/Versions/5/QtDesigner \
    @rpath/Frameworks/QtDesigner.framework/Versions/5/QtDesigner \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtDesignerComponents.framework/Versions/5/QtDesignerComponents \
    @rpath/Frameworks/QtDesignerComponents.framework/Versions/5/QtDesignerComponents \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtGui.framework/Versions/5/QtGui \
    @rpath/Frameworks/QtGui.framework/Versions/5/QtGui \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtNetwork.framework/Versions/5/QtNetwork \
    @rpath/Frameworks/QtNetwork.framework/Versions/5/QtNetwork \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport \
    @rpath/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtWidgets.framework/Versions/5/QtWidgets \
    @rpath/Frameworks/QtWidgets.framework/Versions/5/QtWidgets \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtXml.framework/Versions/5/QtXml \
    @rpath/Frameworks/QtXml.framework/Versions/5/QtXml \
  "/Volumes/D/P/S-0-build/Slicer-build/_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.13.0-2021-11-09-macosx-amd64/Slicer.app//Contents/bin/Designer.app/Contents/MacOS/Designer"

... that said, after manually running the command, I noticed that it fails with the following:

error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: no LC_RPATH load command with path: @executable_path/Frameworks found in: /Volumes/D/P/S-0-build/Slicer-build/_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.13.0-2021-11-09-macosx-amd64/Slicer.app//Contents/bin/Designer.app/Contents/MacOS/Designer (for architecture x86_64), required for specified option "-rpath @executable_path/Frameworks @loader_path/../../../../"

Solution

Problem is that the argument -rpath "@executable_path/Frameworks" "@loader_path/../../../../" is incorrect. It should be "@executable_path/../Frameworks".

Running the following command allowed to find out which path should be replaced:

$ otool -l /Volumes/D/P/S-0-build/Slicer-build/_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.13.0-2021-11-09-macosx-amd64/Slicer.app//Contents/bin/Designer.app/Contents/MacOS/Designer | grep -A 3 LC_RPATH
          cmd LC_RPATH
      cmdsize 48
         path @executable_path/../Frameworks (offset 12)
Load command 29

After replacing the -rpath argument with "@executable_path/../Frameworks", the command displayed above succeed and this can be confirmed running otool -L

$ otool -L _CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.13.0-2021-11-09-macosx-amd64/Slicer.app/Contents/bin/Designer.app/Contents/MacOS/Designer 
_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.13.0-2021-11-09-macosx-amd64/Slicer.app/Contents/bin/Designer.app/Contents/MacOS/Designer:
	@rpath/Frameworks/QtDesignerComponents.framework/Versions/5/QtDesignerComponents (compatibility version 5.15.0, current version 5.15.2)
	@rpath/Frameworks/QtDesigner.framework/Versions/5/QtDesigner (compatibility version 5.15.0, current version 5.15.2)
	@rpath/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport (compatibility version 5.15.0, current version 5.15.2)
	@rpath/Frameworks/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.15.0, current version 5.15.2)
	@rpath/Frameworks/QtGui.framework/Versions/5/QtGui (compatibility version 5.15.0, current version 5.15.2)
	/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1671.10.106)
	/System/Library/Frameworks/Metal.framework/Versions/A/Metal (compatibility version 1.0.0, current version 1.0.0)
	@rpath/Frameworks/QtXml.framework/Versions/5/QtXml (compatibility version 5.15.0, current version 5.15.2)
	@rpath/Frameworks/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.15.0, current version 5.15.2)
	@rpath/Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.15.0, current version 5.15.2)
	/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
	/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
	/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)

@jcfr
Copy link
Member

jcfr commented Nov 10, 2021

The regression could have been introduced when transitioning from Qt 5.10.0 to Qt 5.15.0:

image

Note that I confirmed that the path was already @executable_path/../Frameworks in the designer executable built within Qt 5.15.0, 5.15.1 and 5.15.2.

jcfr added a commit to jcfr/Slicer that referenced this issue Nov 10, 2021
After inspecting the history of Slicer/DashboardScripts project (see [1]),
the regression was likely introduced when transitioning from Qt 5.10 to
5.15.0 in June 2020.

[1] https://github.com/Slicer/DashboardScripts/commits/master/factory-south-macos-slicer_preview_nightly.cmake

Issue was identified following this process:

(1) Copy relevant code from the configured "SlicerCPackBundleFixup.cmake"
    into a CMake script where calls to "file(COPY ..." and "execute_process"
    were changed to be no-op by using "message()" statements.

(2) Copy first command into a bash script and attempt to execute in a
    standalone way.


Doing so led to the following command and error message:

```
install_name_tool \
  -rpath "@executable_path/Frameworks" "@loader_path/../../../../" \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtCore.framework/Versions/5/QtCore \
    @rpath/Frameworks/QtCore.framework/Versions/5/QtCore \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtDesigner.framework/Versions/5/QtDesigner \
    @rpath/Frameworks/QtDesigner.framework/Versions/5/QtDesigner \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtDesignerComponents.framework/Versions/5/QtDesignerComponents \
    @rpath/Frameworks/QtDesignerComponents.framework/Versions/5/QtDesignerComponents \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtGui.framework/Versions/5/QtGui \
    @rpath/Frameworks/QtGui.framework/Versions/5/QtGui \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtNetwork.framework/Versions/5/QtNetwork \
    @rpath/Frameworks/QtNetwork.framework/Versions/5/QtNetwork \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport \
    @rpath/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtWidgets.framework/Versions/5/QtWidgets \
    @rpath/Frameworks/QtWidgets.framework/Versions/5/QtWidgets \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtXml.framework/Versions/5/QtXml \
    @rpath/Frameworks/QtXml.framework/Versions/5/QtXml \
  "/Volumes/D/P/S-0-build/Slicer-build/_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.13.0-2021-11-09-macosx-amd64/Slicer.app//Contents/bin/Designer.app/Contents/MacOS/Designer"
```

```
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: no LC_RPATH load command with path: @executable_path/Frameworks found in: /Volumes/D/P/S-0-build/Slicer-build/_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.13.0-2021-11-09-macosx-amd64/Slicer.app//Contents/bin/Designer.app/Contents/MacOS/Designer (for architecture x86_64), required for specified option "-rpath @executable_path/Frameworks @loader_path/../../../../"
```

Then, running the following command allowed to identify what should be the
correct rpath to  be updated:

```
otool -l /Volumes/D/P/S-0-build/Slicer-build/_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.13.0-2021-11-09-macosx-amd64/Slicer.app//Contents/bin/Designer.app/Contents/MacOS/Designer | grep -A 3 LC_RPATH
          cmd LC_RPATH
      cmdsize 48
         path @executable_path/../Frameworks (offset 12)
Load command 29

```

See Slicer#4700
@lassoan
Copy link
Contributor

lassoan commented Nov 10, 2021

Thank you @jcfr for fixing this and also sharing details about how to diagnose and fix such issue - we can learn a lot from it.

jcfr added a commit that referenced this issue Nov 10, 2021
After inspecting the history of Slicer/DashboardScripts project (see [1]),
the regression was likely introduced when transitioning from Qt 5.10 to
5.15.0 in June 2020.

[1] https://github.com/Slicer/DashboardScripts/commits/master/factory-south-macos-slicer_preview_nightly.cmake

Issue was identified following this process:

(1) Copy relevant code from the configured "SlicerCPackBundleFixup.cmake"
    into a CMake script where calls to "file(COPY ..." and "execute_process"
    were changed to be no-op by using "message()" statements.

(2) Copy first command into a bash script and attempt to execute in a
    standalone way.


Doing so led to the following command and error message:

```
install_name_tool \
  -rpath "@executable_path/Frameworks" "@loader_path/../../../../" \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtCore.framework/Versions/5/QtCore \
    @rpath/Frameworks/QtCore.framework/Versions/5/QtCore \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtDesigner.framework/Versions/5/QtDesigner \
    @rpath/Frameworks/QtDesigner.framework/Versions/5/QtDesigner \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtDesignerComponents.framework/Versions/5/QtDesignerComponents \
    @rpath/Frameworks/QtDesignerComponents.framework/Versions/5/QtDesignerComponents \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtGui.framework/Versions/5/QtGui \
    @rpath/Frameworks/QtGui.framework/Versions/5/QtGui \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtNetwork.framework/Versions/5/QtNetwork \
    @rpath/Frameworks/QtNetwork.framework/Versions/5/QtNetwork \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport \
    @rpath/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtWidgets.framework/Versions/5/QtWidgets \
    @rpath/Frameworks/QtWidgets.framework/Versions/5/QtWidgets \
  -change \
    /Volumes/D/Support/qt-everywhere-build-5.15.2/lib/QtXml.framework/Versions/5/QtXml \
    @rpath/Frameworks/QtXml.framework/Versions/5/QtXml \
  "/Volumes/D/P/S-0-build/Slicer-build/_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.13.0-2021-11-09-macosx-amd64/Slicer.app//Contents/bin/Designer.app/Contents/MacOS/Designer"
```

```
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/install_name_tool: no LC_RPATH load command with path: @executable_path/Frameworks found in: /Volumes/D/P/S-0-build/Slicer-build/_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.13.0-2021-11-09-macosx-amd64/Slicer.app//Contents/bin/Designer.app/Contents/MacOS/Designer (for architecture x86_64), required for specified option "-rpath @executable_path/Frameworks @loader_path/../../../../"
```

Then, running the following command allowed to identify what should be the
correct rpath to  be updated:

```
otool -l /Volumes/D/P/S-0-build/Slicer-build/_CPack_Packages/macosx-amd64/DragNDrop/Slicer-4.13.0-2021-11-09-macosx-amd64/Slicer.app//Contents/bin/Designer.app/Contents/MacOS/Designer | grep -A 3 LC_RPATH
          cmd LC_RPATH
      cmdsize 48
         path @executable_path/../Frameworks (offset 12)
Load command 29

```

See #4700
@lassoan
Copy link
Contributor

lassoan commented Nov 10, 2021

@ungi The problem is fixed now, please ask your students to try the Slicer Preview Release tomorrow and report back here if everything works as expected.

@lassoan
Copy link
Contributor

lassoan commented Nov 12, 2021

Confirmed it works well in Slicer-4.13.0-2021-11-10. Thank you @jcfr!

@lassoan lassoan closed this as completed Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working correctly
Development

No branches or pull requests

9 participants