Fix x permission for own formular


I wrote my first tap, so I’m still not sure how it works. I wrote this small formula:

class Konversation < Formula
  desc "Konversation is a tool to generate rich and diversified responses to the user of a voice application."
  homepage ""
  url ""
  sha256 "6123d126278faae2419f5de00411a1b67ae57e0cf2265a5d484ed6f9786baaca"

  def install
    prefix.install "#{buildpath}/konversation-cli.jar"
    File.write("#{buildpath}/konversation", "java -jar #{prefix}/konversation-cli.jar $@")
    bin.install "#{buildpath}/konversation"
    system "chmod", "+x", "#{bin}/konversation"

However I cannot run my tool since the “konversation” executable has no x permission. I tried to fix that with a system chmod, however I see that my x flag is removed after the installation by brew as some kind of cleanup:

==> Cleaning
Fixing /home/linuxbrew/.linuxbrew/opt/konversation/bin/konversation permissions from 777 to 444

How can I set the file permissions correctly?

Please note that I don’t want to host the shell script itself somewhere, since I see no advance in packaging the shell script and the jar file in another zip file for destitution.

If you want to try it yourself try this command:

brew install rekire/packages/konversation

By the way I asked that same question on Stack Overflow, if you like to get there some reputation feel free to answer there too.

(Jonathan Chang) #2

Shell scripts need to have a shebang line, otherwise the install cleaner will set its permissions as though it were not an executable. My suggestions:

  • use bin.write_jar_script instead
  • install .jars to libexec instead of prefix

See the many Java formulae in homebrew/core for examples.

1 Like

Now it works fine. Thank you!

Do you want to answer on Stack Overflow too? I would like to accept it.

(Jonathan Chang) #4

Alright, I added a stack overflow answer.


Accepted. Thank you again!