Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Linux: Make Stata default application of file type .dta (etc.)

    How can I change the default application of file types such as .dta, .do, .gph, .smcl to Stata? I succeeded to install Stata on Linux (Ubuntu 18.04). However, if I want to make Stata the default application of file type .dta (etc.), Stata (or xstata) is not listed in /usr/share/applications/ . I am not an experienced Linux user, step by step instruction would help a lot.

  • #2
    The instructions will depend on your particular desktop environment, which will be Gnome in the case of Ubuntu. You may try to adapt the instructions here.

    Comment


    • #3
      Thanks Leonardo, I tried to follow your suggestion to adapt to the instructions at https://askubuntu.com/questions/6867...program#686924 that suggests to create a new mime type. However, I don't know how to refer to Stata in my specific case. How should the configuration file (stata.xml??) look like?

      Comment


      • #4
        I do not have access to my Ubuntu machine at the moment, so I cannot precisely tell you the MIME-types that Stata associates with. There is a followup link in that thread that provides some clues to look at the desktop launcher configuration. I can take a look this evening when I am at home.

        Comment


        • #5
          A note to Linux users (I am not sure whether this applies to Ubuntu only or to other Linux variants, as well): When I fiddled around with MIME-types (I am not a Linux expert) the icons of active Stata changed to an ugly default icon and when starting different instances of Stata they didn't show up as separate icons but were collected under this ugly default icon. For a long time I was not able to get the previous behavior back such that each instance of Stata uses its own original Stata icon.

          By accident I found out how to get the original Stata icons per instance of an active program back: In the .default file I changed
          Code:
          Exec=/usr/local/stata16/xstata-se %F
          to
          Code:
          Exec=/usr/local/stata16/xstata %F
          (the same for the desktop launcher for Stata 17).
          Last edited by Dirk Enzmann; 30 May 2021, 07:41.

          Comment


          • #6
            Finding out by accident often means that you don't understand what is happening -- this is the case here, as well. After trying to make Stata the default application for .do- or .dta-files (with Krusader via -> open with -> other -> search + remember application association) the ugly behavior mentioned in #5 appeared again. I only got the behavior with multiple Stata icons with multiple instances back if I changed the .default files again to
            Code:
            Exec=/usr/local/stata16/xstata-se %F
            If I now start Stata with double-click on .do or .dta files the program (and additional instances) will still use the ugly default icon of Linux (and multiple instances will not use separate Stata icons), but at least I can get original Stata icons per instance if I am using the desktop launcher.

            I would appreciate it if onyone understands better what is going on and could show how to make Stata the default application for .do-, .ado-, .cht- and .dta-files without the problem of then having only one Linux default icon for separate instances of Stata. I using Ubuntu 18.04.

            Comment


            • #7
              While being a Linux user myself I was never bothered enough to actually tackle the problem you describe. I think this is more a Linux question than a Stata one and I would suggest to post in a Linux forum, depending on your system. I am aware of an automated script by Daniel Bela, that worked very well on my laptop one time. Maybe you find some helpful information here: https://github.com/dirtyhawk/stata-integration
              Best wishes

              (Stata 16.1 MP)

              Comment


              • #8
                Thanks for this advice! I did download "stata-integration-main.zip" and extraced its contents. There are several folders, the folder "/stata-integration-main/build" contains the file "stata-integraion.bin". I followed the instruction to simply run
                Code:
                sudo stata-integration.bin
                in the terminal window but receive the error message
                Code:
                sudo: stata-integraion.bin: command not found
                Obviously it is not as simple. Did you run the script successfully?

                Comment


                • #9
                  Is this the actual error message (since there is a typo?). For the error message I think you are in the wrong folder then running the command since he does not find the.bin file. Open the terminal in the folder that contains the file and run it again. For me it worked once but there are some dependencies. I think you also need
                  Code:
                  sudo apt install build-essential
                  Best wishes

                  (Stata 16.1 MP)

                  Comment


                  • #10
                    Thanks a lot!

                    I solved the problem by changing to the folder containing the file "stata-integration.bin". Subsequently I run
                    Code:
                    chmod a+x stata-integration.bin
                    sudo ./stata-integration.bin
                    and followed the instructions. Now my system recognizes Stata's file extensions and I can start Stata with a double click on a Stata file, if I want with multiple instances.

                    The only minor issue is that "stata-integration.bin" does not know Stata 17, yet. I think I have to wait for an update. It would be a nice service by Stata Corp. to provide users with a similar script.

                    Comment


                    • #11
                      I thought my problems were solved, but since I tried to make Stata 17 the default application for .do-files, Stata again starts using a Linux default icon and mupliple instances won't get separate icons but will be "colleced" under the same icon. A re-run of the script "stata-integration.bin" does not help.

                      It was a short pleasure. It is frustrating that I can't get Stata to run properly on a Linux system.

                      Comment


                      • #12
                        I think this also depends on the type of Linux you are using. For me (Mint 19.3) I can right click a .dta file, then select Properties and then "Open with". Here I select xstata-mp. It works, When I open multiple .dta fles, Stata starts correctly and I get a new window and icon in my desktop bar. With Ubuntu it might a slightly different but I guess it should work somehow? I would pose this question in a Ubuntu forum.
                        Best wishes

                        (Stata 16.1 MP)

                        Comment


                        • #13
                          Nearly a year later the problem described in #11 is still not solved. Because I re-installed my system (Linux, Ubuntu 20.04) and Stata 17 anew, I think I should give it another try.

                          Because the solution and script offered by "dirtyhawk" on GitHub (see #7) is written for Stata 16 but the icons and file associations of Stata 17 are the same, I followed the steps in #10 and run the script "stata-integration.bin" by specifying version 16 (sic!) but the path to Stata version 17 as follows:
                          Code:
                          stata-integration.bin --version 16 --flavour SE --libpngfix false --path "/usr/local/stata17" --users "enzmann"
                          However, although the file association issues are solved, the ugly behavior it is still the same: When starting Stata (xstata-se) the generic Linux icon for a running application (instead of the Stata icon) is shown and multiple instances of Stata appear "under" the same (single) icon. Strange enough: When starting "xstata" (i.e. Stata/BE) only, everything is OK: There is one original Stata icon per running instance of Stata.

                          Is there anybody around using Linux (it may also be another distribution than Ubuntu) who could help to solve this persisting issue?

                          Comment


                          • #14
                            Finally, the problem is solved:

                            For whatever reason there was a .desktop file (xstata-se.desktop) in my ~/home/.local/share/applications/ folder which contained
                            Code:
                            [Desktop Entry]
                            Exec=/usr/local/stata17/xstata-se
                            MimeType=application/x-stata-dta;
                            Name=xstata-se
                            NoDisplay=true
                            Type=Application
                            so that although my launcher "Stata 17.0.desktop" which reads
                            Code:
                            [Desktop Entry]
                            Version=17.0
                            Terminal=false
                            Icon=/usr/local/stata17/stata17.png
                            Type=Application
                            Categories=Education;Scientific;
                            Exec=/usr/local/stata17/xstata-se
                            Name=Stata/SE 17.0
                            Comment=Perform statistical analyses using Stata.
                            StartupNotify=true
                            MimeType=application/x-stata-dta;application/x-stata-do;application/x-stata-smcl;application/x-stata-stpr;application/x-stata-gph;application/x-stata-stsem;
                            Actions=doedit;use;view;graphuse;projmanag;semopen ;
                            seemed to be correct the original Stata icon for the running program was replaced by the generic Linux icon for running programs and several instances of Stata did not get their own icon when running.

                            I simply removed the "xstata-se.desktop" file from "~/home/.local/share/applications/" which solved the issue.
                            Last edited by Dirk Enzmann; 08 Jan 2022, 11:28.

                            Comment

                            Working...
                            X