Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [solved] Mavericks File Permission Problem
QtWS25 Last Chance

[solved] Mavericks File Permission Problem

Scheduled Pinned Locked Moved Installation and Deployment
15 Posts 3 Posters 3.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brebarth
    wrote on last edited by
    #1

    Hi there,

    building my app under Mavericks, Qt 5.2rc with xcode 5.0.2, compiles and runs fine when started from QtCreator.
    I do macdeployqt on the .app file

    Then I try to run it by double clicking it in finder. It opens a window, but that window stays black. This is in fact expected behavior for my app, if it can't find or open required resource files.

    When I run it from terminal "open My.app", same results, black window in my face.
    However, when I go "sudo open My.app" it runs just fine, loads all the resource files and displays.

    So this must be some kind of file permission issue with Mavericks / Qt?
    I never had this on OSX 10.8 down to 10.6.8

    Any ideas?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      brebarth
      wrote on last edited by
      #2

      by the way the files I'm trying to open from My.app exist in the same folder, they're not inside the .app/content.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        What kind of application is it (Widget, QML) ? What are the files you are opening ? When you say they exist in the same folder, which folder are you talking about ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • B Offline
          B Offline
          brebarth
          wrote on last edited by
          #4

          It's a Widget application
          from the .pro file:

          @
          QT += opengl
          QT += widgets
          @

          the files I'm opening are xml data (Settings.xml) and image and sound files. (.tga, .ogg)

          Just the folder, in which the .app file lives, it also contains the resource files (all the xml , tga, ogg files)

          [top application folder, can be placed anywhere] ->{ lots of files, My.app, some more folders with more files}

          the app loads "lots of files" and also "some more files" in "some more folders". This works fine if I'm sudo, but not if I'm a normal user. Then it won't let the app open the files. I don't know why..

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Did you run macdeployqt on your application bundle ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • B Offline
              B Offline
              brebarth
              wrote on last edited by
              #6

              yes I have.... but not in sudo mode..

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                And that's correct, you don't need to run it in sudo mode.

                Can you create a minimal example program that shows the problem ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  brebarth
                  wrote on last edited by
                  #8

                  I made a minimal code version of the problem I have.

                  Compiled with Qt 5.2rc and qtmacdeployed on Mavericks. Source included.

                  When launched it will attempt to open one file ("Controls.xml"). If success it will open a QMessageBox "Success"
                  otherwise a QMessageBox with "Fail"

                  On Mavericks:
                  -running this as sudo or from QtCreator -> success
                  -running it from finder -> fails.

                  To test it, get it here ( couldn't figure out how to attach this zip here..):

                  https://drive.google.com/file/d/0B2hpkmDPq1oaRUEyYmdYWEUyV2s/edit?usp=sharing

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Just tested it (Had to rebuild your sources, OS X told me It could not open the app because it was from an unidentified developer)
                    The problems come from the fact that you try to open Controls.xml without giving the path to the file so it's relative to the "current path" of the application. In Mavericks, Apple has modified what working directory it gives to the application and e.g. calling it from the console (./My.app/Contents/MacOS/My) or from finder, will not give the same result, thus your file is really not found

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      brebarth
                      wrote on last edited by
                      #10

                      So you mean, instead of "Controls.xml"

                      I should attempt to open "../../Controls.xml"

                      ?

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        For the sake of testing, you should give the absolute path e.g. "/Users/your_user_name/path_to/Controls.xml"

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • B Offline
                          B Offline
                          brebarth
                          wrote on last edited by
                          #12

                          Just tested it and it works fine with “/Users/your_user_name/path_to/Controls.xml”
                          both from QtCreator and from Finder. So that's great for testing..

                          But I can't use that for deployment. And the ../../../ thing doesn't seem to work..
                          when I use
                          "../../../Controls.xml"
                          as path (relative to the executable) it works, when running from QtCreator but it doesn't work via double click starting from finder.

                          What could be the solution?

                          1 Reply Last reply
                          0
                          • B Offline
                            B Offline
                            brebarth
                            wrote on last edited by
                            #13

                            i.e. is there a way to tell Qt in the .pro file to set the working dir? Or what would I do?

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              sandy.martel
                              wrote on last edited by
                              #14

                              The working dir is set by the parent process. You'll get different result if you launch from the Finder or the terminal. This is not a reliable way to find your resources.
                              Look at QCoreApplication::applicationDirPath or QStandardPaths::locate.

                              1 Reply Last reply
                              0
                              • B Offline
                                B Offline
                                brebarth
                                wrote on last edited by
                                #15

                                Thanks. A combination of using
                                QCoreApplication::applicationDirPath and QDir worked to solve this.

                                1 Reply Last reply
                                0

                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • Users
                                • Groups
                                • Search
                                • Get Qt Extensions
                                • Unsolved