A Ruby script and matching .desktop stopped working :p

Forum Forums General Software A Ruby script and matching .desktop stopped working :p

  • This topic has 5 replies, 2 voices, and was last updated Dec 21-2:28 am by Mynaardt.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #47565
    Member
    Mynaardt

      Hi, all!

      Just had a bit of a bother with antiX trying to run a Ruby script like an
      executable bash. It was working a few days ago, but now it’s not.

      It’s working nicely if I just execute it like “$ ./ruby file_tidy.rb”

      But If I try to double click the icon or Ruby file from the file manager, it
      won’t work as it did.

      Now it opens up with an execute file menu (Execute, Execute in Terminal,
      Open, Cancel).

      And then when I do click on either, I get this response in an error message like this:
      Invalid desktop entry file: ‘~/Dropbox/education/Anki Files/programming/file_tidy.desktop’

      I tried to make the first like either of these in the Ruby script:

      #!/usr/bin/env ruby
      #!/usr/bin/env /usr/bin/ruby

      But got the same result for both.

      And here’s the content of my desktop icon file I try double clicking from the
      file manager:

      #!/usr/bin
      [Desktop Entry]
      Encoding=UTF-8
      Name=Program Tidy
      Comment=for Anki
      Exec=./file_tidy.rb
      Terminal=true
      Type=Application

      I did the chmod +x filename thing for both the ruby script and desktop file.
      They are both in the same directory of one of my Dropbox sub-folders. They had
      both been working nicely at first in antiX. Then I used my laptop, running on
      Linux Mint, and it worked there too. But now neither seems to want to work when
      I try them again on antiX.

      Can anyone tell me if this is a problem caused because I tried accessing the
      same desktop and script files in a Debian and Ubuntu based OS (antiX and Mint
      respectively), or am I missing something else?

      I also just had the RAM maxed out on this computer today too. I don’t know if
      that might be a factor or not.

      It’s not the end of the world if it won’t work, but I was doing this to quickly
      run my script from the file manager instead of going through the terminal. I
      was pleased with myself for getting it to work properly the first time , but
      am just a bit miffed it won’t work now. *sigh*

      Thanks in advance!

      • This topic was modified 2 years, 4 months ago by Mynaardt.
      • This topic was modified 2 years, 4 months ago by Mynaardt.

      What have the Romans ever done for us?
      Apart from: sanitation, medicine, education, wine, public order, irrigation, roads, fresh water, and public health?

      #47574
      Anonymous
        Helpful
        Up
        0
        ::

        remove from the .desktop file the “hashbang” (shebang) line.

        Next, browse the content of the /usr/share/applications/ directory, and take note that the desktop files are NOT chmod +x (because they are parsed, not executed). All of the .desktop files are plaintext ~~ you can drag one or a dozen into geany editor and have a peek (learn by example). For a more full understanding, visit and read: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.1.html

        Next, regarding “But got the same result for both”, I recommend you read this:
        https://stackoverflow.com/questions/43793040/how-does-usr-bin-env-work-in-a-linux-shebang-line
        (it’s a quick read, general reading, not specific to Ruby)

        Next, regarding “Exec=./file_tidy.rb”
        some remedial learning is in order. Pasting here a few (of the many available) ‘splainers
        which can be found via a websearch query “linux $PATH” or “bash $PATH”
        http://www.linfo.org/path_env_var.html
        https://astrobiomike.github.io/unix/modifying_your_path
        https://linuxhint.com/path_in_bash/

        #47605
        Anonymous
          Helpful
          Up
          0
          ::

          related:

          Forum › Forums › General › Tips and Tricks ›
          topic: understanding desktop (.desktop) application launchers

          #47814
          Member
          Mynaardt
            Helpful
            Up
            0
            ::

            This is annoying! Most of them work, except one in particular! 😛

            I got rid of the shebang lines, ran chmod -x on the desktop icon files in question, then tried running them.

            First of all, this desktop icon works just fine:

            [Desktop Entry]
            Encoding=UTF-8
            Type=Application
            Name=Multi Choice
            Comment=for Anki
            Icon=/home/malcolm/.extra-icons/utilities/gear&hammer_02.png
            Path=/home/malcolm/Documents/education/Anki Files/
            Exec="/home/malcolm/Documents/programming/Ruby/programs/for_anki/multichoice.rb"
            Terminal=true
            NoDisplay=True

            But another one that I based on that and only change the relavent paths and file names just won’t work no matter how I try editing it. I keep getting this error message:
            The new terminal's command failed to run: Failed to execute child process “/home/malcolm/Documents/education/Anki” (No such file or directory)

            And here’s the desktop file that won’t work:

            [Desktop Entry]
            Encoding=UTF-8
            Type=Application
            Name=Tidy Program
            Comment=for Markdown
            Icon=/home/malcolm/.extra-icons/utilities/gear&hammer_02.png
            Path=/home/malcolm/Documents/education/Anki Files/programming/
            Exec="/home/malcolm/Documents/education/Anki Files/programming/program_tidy.rb"
            Terminal=true
            NoDisplay=True

            Both ruby files in question start with the same shebang (#!/usr/bin/env ruby)

            Any ideas what I might be overlooking here? The program_tidy.rb script works just fine in the terminal, by the way…

            Is the one directory name “/Anki Files” messing things up for one but not the other, maybe?

            Thanks in advance, if anyone can give me a nudge in the right direction…

            • This reply was modified 2 years, 4 months ago by Mynaardt.
            • This reply was modified 2 years, 4 months ago by Mynaardt.
            • This reply was modified 2 years, 4 months ago by Mynaardt.

            What have the Romans ever done for us?
            Apart from: sanitation, medicine, education, wine, public order, irrigation, roads, fresh water, and public health?

            #47818
            Anonymous
              Helpful
              Up
              0
              ::

              The new terminal’s command failed to run: Failed to execute child process “/home/malcolm/Documents/education/Anki” (No such file or directory)

              The problem is due to using Windoze-like filenames containing spaces
              and the presence of an unquoted commandstring in the line Exec=

              As is, the commandstring is being interpreted as

              “Hey, I want ya to run an executable, named Anki.
              It’s in my ~/Documents/education directory. Oh, by the way,
              when ya call Anki, pass along this message (arg, commandline option): Files/

              spoiler:
              ██████████████████████████████████████████████████████████████
              ████████████████████████████████████████████████████████████████
              ██████████████████████████████████████████████████████
              ██████████████████████████████████████

              #47877
              Member
              Mynaardt
                Helpful
                Up
                0
                ::

                Oh, bugger!

                Yes, all it was was one subdirectory with a (smelly) Windoze style space in it. 😐

                Lapse in judjement and/or a total coffee sortage when I made that sub directory!

                Anyway, thanks for that, skidoo. It’s all working right and proper now.

                • This reply was modified 2 years, 4 months ago by Mynaardt. Reason: Got it sorted out

                What have the Romans ever done for us?
                Apart from: sanitation, medicine, education, wine, public order, irrigation, roads, fresh water, and public health?

              Viewing 6 posts - 1 through 6 (of 6 total)
              • You must be logged in to reply to this topic.