Skip to content

[assemble] APP_HOME (java-archive) does not work if bin/app is linked in a relative way #1994

@bmarwell

Description

@bmarwell

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem (link to git repository is ideal)
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Build an assembly
  2. Extract app somewhere, e.g. ~/.local/apps/myapp/bin/myapp
  3. Link somewhere in a relative way, e.g. (cd ~/.local/bin && ln -s ../apps/myapp/bin/app)

Expected Behaviour

When executed, should work

Actual Behaviour

When executed, lib path is determined in a wrong way, because APP_HOME is not correctly resolved:

$ bash -x myapp
+ app_path=myapp
+ APP_HOME=
+ '[' -h myapp ']'
++ cd ./..
++ pwd -P
+ APP_HOME=/Users

... which is wrong.

Workaround

Link in an absolute path: (cd ~/.local/bin && ln -s ~/.local/apps/myapp/bin/app)

Then:

$ bash -x ./myapp
+ app_path=./myapp
+ APP_HOME=./
+ '[' -h ./myapp ']'
++ ls -ld ./myapp
+ ls='lrwxr-xr-x  1 theUser  1000  57 17 Oct 10:47 ./myapp -> /Users/theUser/.local/apps/myapp-1.2.0-SNAPSHOT/bin/myapp'
+ link=/Users/theUser/.local/apps/myapp-1.2.0-SNAPSHOT/bin/myapp
+ case $link in
+ app_path=/Users/theUser/.local/apps/myapp-1.2.0-SNAPSHOT/bin/myapp
+ APP_HOME=/Users/theUser/.local/apps/myapp-1.2.0-SNAPSHOT/bin/
+ '[' -h /Users/theUser/.local/apps/myapp-1.2.0-SNAPSHOT/bin/myapp ']'
++ cd /Users/theUser/.local/apps/myapp-1.2.0-SNAPSHOT/bin/..
++ pwd -P
+ APP_HOME=/Users/theUser/.local/apps/myapp-1.2.0-SNAPSHOT

Environment Information

  • Operating System: MacOS
  • JReleaser Version: latest/any
  • JDK Version: any, not relevant for this issue (but I used IBM Semeru 17 and 25)

Please paste stacktraces from [out|build|target]/jreleaser/trace.log.

not relevant

But here is the relevant snippet:

# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in
/*) app_path=$link ;;
*) app_path=$APP_HOME$link ;;
esac
done
APP_HOME=$( cd "${APP_HOME:-./}.." && pwd -P ) || exit

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions