Skip to content

Homebrew formula #557

@mhanberg

Description

@mhanberg

@mhanberg Hey, I wrote the formula for Expert and wanted to clarify the use of burrito.

The homebrew formula does not need to use burrito tho, so that should probably get changed.

I was not aware of this. This is actually my first time writing a Homebrew formula, so I took quite a lot of inspiration from others; mainly, the Next LS formula from the elixir-tools tap, which also used burrito, but it's good to know, as that would eliminate the zig and xz dependencies the formula currently has when building from source.

Though one more thing I will add is that the plain releases appear to be significantly slower than the burrito ones, so that's one potential reason to keep using burrito for the formula as well. Take for example this command:

expert --version

With the burrito release, this takes ~200 ms to run, but with a plain release it takes ~2 seconds (this is on macOS Intel); that's 10 times slower!

I'm not sure why there's such a big difference. Perhaps this won't matter much when actually using the language server, but it's something to keep in mind (and potentially improve about the plain releases).


Anyways, while prototyping a version of the formula that builds a plain release instead, I initially was going to switch it to this:

    system "mix", "local.hex", "--force", "--if-missing"
    system "mix", "local.rebar", "--force", "--if-missing"
    system "just", "release"

    libexec.install Dir["apps/expert/_build/prod/rel/plain/*"]
    libexec.glob("bin/*.bat").map(&:unlink)
    bin.install_symlink libexec/"bin/start_expert" => "expert"

But I quickly discovered that this doesn't work because symlinking the start_expert executable prevents it from calling the plain executable (which is not symlinked and should probably not be symlinked).

The failure seems to be caused by the use of $(dirname -- "$0")"/plain which returns the directory of the symlink rather than the directory of start_expert in its actual location.

ElixirLS does something similar to the plain releases with its use of a launch_server.sh executable, so I looked at how they solve this issue. They include this to resolve calls from symlinks:

readlink_f () {
  cd "$(dirname "$1")" > /dev/null || exit 1
  filename="$(basename "$1")"
  if [ -h "$filename" ]; then
    readlink_f "$(readlink "$filename")"
  else
    echo "$(pwd -P)/$filename"
  fi
}

dir="$(dirname "$(readlink_f "$0")")"
exec "${dir}/launch.sh"

Something like this could be included in the start_expert executable as well.

In the meantime, the only way to get the plain release to work with Homebrew is to do this instead:

    system "mix", "local.hex", "--force", "--if-missing"
    system "mix", "local.rebar", "--force", "--if-missing"
    system "just", "release"

    libexec.install Dir["apps/expert/_build/prod/rel/plain/*"]
    libexec.glob("bin/*.bat").map(&:unlink)
    (bin/"expert").write <<~SHELL
      #!/bin/sh
      exec "#{libexec}/bin/plain" eval "System.no_halt(true); Application.ensure_all_started(:xp_expert)" "$@"
    SHELL

P.S.

Any chance we could merge #550?

That would allow us to simply the formula from this:

    system "mix", "local.hex", "--force", "--if-missing"
    system "mix", "local.rebar", "--force", "--if-missing"
    system "just", "release"

    ...

To this:

    system "just", "release"

    ...

Originally posted by @AlternateRT in #556 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions