jvm-profiling-tools / honest-profiler

A sampling JVM profiler without the safepoint sample bias
https://github.com/RichardWarburton/honest-profiler/wiki
MIT License
1.25k stars 146 forks source link

Gui script fails to start on Mac OS Sierra - ilegal option -- f #207

Open jsotuyod opened 7 years ago

jsotuyod commented 7 years ago

The script fails on MacOS with:

$ ./gui
readlink: illegal option -- f
usage: readlink [-n] [file ...]
cinquin commented 7 years ago

We're going round in circles on this issue; see the history of the script. It would be nice if someone could sit down and find a way of setting up the script in a way that works reliably on all platforms (or, failing that, detects the platform and switches behavior accordingly).

PhRX commented 7 years ago

TL;DR : proposal = drop the scripts, use gradle facilities (or maven if it can do it)

The crux of the problem AFAICS is that tools.jar must be on the classpath, which requires the script to be non-trivial (trivial would be to just use the jar).

My proposal for resolving this issue, as well as #122 is in #187 : if we switch to gradle (although for all I know the same can be achieved using maven - can anyone comment?) it can be used instead of the generated scripts. In gradle it's easy to declare the necessary dependency on what is used from the tools.jar.

The end result is that when the hp project is checked out, all that is needed to run the UI is the command ./gradlew run. A ./gradlew runConsole (or something similar) can be added trivially to start the console.

AFAIK, the gradle solution would work on any platform (OSX, Linux, Windows - the only one I haven't tried for now is OSX). The wrapper mechanism (which uses the gradlew script which is checked in, with a version both for Win and non-Win) ensures you don't even need to install gradle.

The above is for people who have a JDK installed (gradle will compile and create the jar the first time). If only a JRE is available, we can use a deployment module for gradle (such as https://github.com/shemnon/javafx-gradle) which allows building of a distribution. I've successfully used it in the past to create a self-contained zip/tgz which contains a Win or nonWin executable running the project. The JRE is also included. This I could do in less than half a day. I think the JDK itself also contains deployment tools these days, those could be used too.

fzh890523 commented 6 years ago

on OSX, you can install greadlink via "brew install greadlink" and then use this script content below to replace that in GUI script:

!/bin/sh

set -eu

java_path=$(greadlink -f $(which javac)) [ -f /usr/libexec/java_home ] && java_home=/usr/libexec/java_home || java_home=$(echo ${java_path} | sed 's/javac$//') tools_path="$java_home/lib/tools.jar" [ -f ${tools_path} ] || (echo "Could not find tools.jar at ${tools_path}" && exit 1)

BASEDIR=$(dirname "$0")

java -cp $tools_path:${BASEDIR}/honest-profiler.jar com.insightfullogic.honest_profiler.ports.javafx.JavaFXApplication

nitsanw commented 6 years ago

Is this still an issue?

snowe2010 commented 6 years ago

@nitsanw this is still an issue.

nitsanw commented 6 years ago

@snowe2010 I don't have a Mac to test on, so sadly can't help. Please try the workaround above, and report back. If you can resolve the issue and contribute a PR that would be great.

snowe2010 commented 6 years ago

Workaround for me was brew install coreutils and then doing as said. I'm not experienced in this area, so I'm not sure I could submit an effective PR.