kaby76 / Antlr4BuildTasks

Third-party build tool for 'Official' Antlr4 tool and runtime parsers using .Net. Drop-in replacement for 'Antlr4cs' Antlr4 tool and build rules.
MIT License
73 stars 10 forks source link

Error ANT02: Cannot find Java executable'' in .NET SDK Docker Image #59

Closed ps-pe closed 9 months ago

ps-pe commented 1 year ago

Using the official (linux-based) .NET SDK docker image (mcr.microsoft.com/dotnet/sdk:7.0, https://hub.docker.com/_/microsoft-dotnet-sdk) to build a project using dotnet CLI fails.

Error: ANT02: Cannot find Java executable''

The docker image does contain a "chmod" binary, but is is located in "/bin" not "/user/bin". The Problem seems to be that "/bin" is only searched on OSX (not Linux).

https://github.com/kaby76/Antlr4BuildTasks/blob/9a8f23cfb13b0403e3cfff82c5bf71f766a8eab8/Antlr4BuildTasks/Tasks/RunAntlrTool.cs#L1402

andreadistefano commented 9 months ago

I found the same issue, using version 12.2.0

andreadistefano commented 9 months ago

It should be possible to find the correct path both in Linux and OSX using something like

var executableName = "chmod";
var command = $"which {executableName}";
var process = new Process();
process.StartInfo.FileName = "/bin/sh";
process.StartInfo.Arguments = $"-c \"{command}\"";
process.StartInfo.RedirectStandardInput = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;

process.Start();
var fullPath = process.StandardOutput.ReadToEnd().Trim();
process.WaitForExit();
andreadistefano commented 9 months ago

Alternatively, in the docker image you can ln -s /bin/chmod /usr/bin/chmod