Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux executable doesn't start if under a path with spaces #214

Closed
2 of 5 tasks
salmonb opened this issue Jul 3, 2022 · 11 comments
Closed
2 of 5 tasks

Linux executable doesn't start if under a path with spaces #214

salmonb opened this issue Jul 3, 2022 · 11 comments
Labels
bug Something isn't working feedback Waiting for feedback fixed Issue fixed and release pending

Comments

@salmonb
Copy link

salmonb commented Jul 3, 2022

I'm submitting a…

  • bug report
  • feature request
  • other

Short description of the issue/suggestion:

If the path to the repository contains spaces, the Linux executable generated by Javapackager doesn't start.

Steps to reproduce the issue/enhancement:

  1. Create a directory with spaces (ex: mkdir My\ Projects)
  2. Move the project under that directory
  3. Try to run the executable generated by Javapackager

What is the expected behavior?

The executable should run, whether or not there are spaces in the path

What is the current behavior?

The executable fails to run when there are spaces in the path

Do you have outputs, screenshots, demos or samples which demonstrate the problem or enhancement?

$ /home/bruno/My\ Projects/myproject/mymodule/target/javapackager/MyApp/MyApp
/home/bruno/My Projects/myproject/mymodule/target/javapackager/MyApp/MyApp: line 13: [: /home/bruno: binary operator expected
/home/bruno/My Projects/myproject/mymodule/target/javapackager/MyApp/MyApp: line 17: cd: $'/home/bruno\nProjects/myproject/mymodule/target/javapackager/MyApp': No such file or directory
/home/bruno/My Projects/myproject/mymodule/target/javapackager/MyApp/MyApp: line 20: /home/bruno: Is a directory

What is the motivation / use case for changing the behavior?

Just make it works :)

Please tell us about your environment:

  • JavaPackager version: 1.6.6
  • OS version: Ubuntu 22.04
  • JDK version: openjdk version "18.0.1.1" 2022-04-22
  • Build tool:
    • Maven
    • Gradle

Other information (e.g. related issues, suggestions how to fix, links for us to have context)

@fvarrui
Copy link
Owner

fvarrui commented Jul 11, 2022

Hi @salmonb!
Sorry for my late reply ... I've been traveling last week.

Please, can you share here the generated startup script for Linux? (it should be in target/assets/startup.sh)

Thanks!

@fvarrui fvarrui added bug Something isn't working feedback Waiting for feedback labels Jul 11, 2022
@salmonb
Copy link
Author

salmonb commented Jul 12, 2022

hi @fvarrui

Here is the content of startup.sh

#!/usr/bin/env bash
# GNU/Linux startup script generated by JavaPackager plugin

SCRIPTPATH=$(dirname $(readlink -e "$0"))

JAVA="$SCRIPTPATH/jre/bin/java"

BINARY="$SCRIPTPATH/WebFXExample"


JVMDefaultOptions=""
JVMOptionsFile="$SCRIPTPATH/WebFXExample.l4j.ini"
[ -f $JVMOptionsFile ] && while read -r option; do JVMDefaultOptions+=" $option"; done <<< $(sed "/^#.*$/d" $JVMOptionsFile)

JVMClassPath="$BINARY"

cd "$SCRIPTPATH"


$JAVA $JVMDefaultOptions -cp $JVMClassPath dev.webfx.platform.boot.ApplicationBooter $@
exit 0

If I run this script under a path with a space (ex: /home/bruno/dev/javapackager\ issue/... <= there is a space between javapackager and issue), then I'm getting this error:

./startup.sh: line 13: [: /home/bruno/dev: binary operator expected
./startup.sh: line 17: cd: $'/home/bruno/dev\nissue/webfx-example-application-openjfx/target/javapackager/assets': No such file or directory

@fvarrui
Copy link
Owner

fvarrui commented Jul 12, 2022

Yes, thank you! I'm working on it ... I've just reproduced your issue and find out that the problem is in this line:

SCRIPTPATH=$(dirname $(readlink -e "$0"))

Just adding doublequotes and the problem is fixed:

SCRIPTPATH=$(dirname "$(readlink -e "$0")")

Notice the double quotes

I've just released the change in issue-214 branch ... please, try it and give me some feedback. I'd like to include this fix in v1.6.7.

@fvarrui
Copy link
Owner

fvarrui commented Jul 12, 2022

AppImage generation feature is already included ... as you are trying on Linux, would you mind trying the AppImage binary too?

@salmonb
Copy link
Author

salmonb commented Jul 12, 2022

Great, glad that you found a fix 😃

I'm happy to test, but not sure how, as I never used a Maven plugin other than by listing it on my pom.xml...

I cloned your repository and checked out the issue-214 branch, but how can I tell Maven to use it now?
I'm not used to Maven plugin development, sorry...

@fvarrui
Copy link
Owner

fvarrui commented Jul 13, 2022

Hi @salmonb!

You can build JavaPackager on your own by running next commands:

git clone https://github.com/fvarrui/JavaPackager --branch issue-214
cd JavaPackager
./gradlew publishToMavenLocal

Last command will install the plugin in your local repo (inside .m2 directory) ... and that's all! Now you can use this version of the plugin. Just set 1.6.7-SNAPSHOT as JavaPackager version in your POM.

I'm using Java 11 because newer versions cause problems with Gradle 6 (yes! I have to upgrade Gradle, but it requires time as some plugins used in the building process are no longer available in newer versions 😓)

@salmonb
Copy link
Author

salmonb commented Jul 14, 2022

hi @fvarrui

Thank you, I managed to test your SNAPSHOT version by following your instructions 👍

I confirm that the Linux executable now starts correctly, good job! 😄

For the AppImage generation, some lines are logged as [ERROR] while they seem to be just [INFO], is it normal?

[INFO]         Executing command: /bin/sh -c cd '/home/bruno/dev/webfx example/.' && 'cp' "/home/bruno/dev/webfx example/webfx-example-application-openjfx/target/javapackager/assets/WebFXExample.png" "/home/bruno/dev/webfx example/webfx-example-application-openjfx/target/javapackager/assets/AppDir/WebFXExample.png"
[INFO]         Running appimagetool on /home/bruno/dev/webfx example/webfx-example-application-openjfx/target/javapackager/WebFXExample
[INFO]         Executing command: /bin/sh -c cd '/home/bruno/dev/webfx example/.' && '/home/bruno/dev/webfx example/webfx-example-application-openjfx/target/javapackager/assets/appimagetool' --appimage-extract-and-run "/home/bruno/dev/webfx example/webfx-example-application-openjfx/target/javapackager/assets/AppDir" "/home/bruno/dev/webfx example/webfx-example-application-openjfx/target/javapackager/WebFXExample.AppImage"
[ERROR]         appimagetool, continuous build (commit 8bbf694), build <local dev build> built on 2020-12-31 11:48:33 UTC
[INFO]         /home/bruno/dev/webfx example/webfx-example-application-openjfx/target/javapackager/assets/AppDir/WebFXExample.desktop: warning: value "WebFX Example" for key "Comment" in group "Desktop Entry" looks redundant with value "WebFX Example" of key "Name"
[ERROR]         Using architecture x86_64
[ERROR]         Deleting pre-existing .DirIcon
[ERROR]         Creating .DirIcon symlink based on information from desktop file
[ERROR]         WARNING: AppStream upstream metadata is missing, please consider creating it
[ERROR]                  in usr/share/metainfo/WebFXExample.appdata.xml
[ERROR]                  Please see https://www.freedesktop.org/software/appstream/docs/chap-Quickstart.html#sect-Quickstart-DesktopApps
[ERROR]                  for more information or use the generator at http://output.jsbin.com/qoqukof.
[ERROR]         Generating squashfs...

In the end the WebFXExample.AppImage executable file is generated.
But when I try to execute it, I'm getting:

dlopen(): error loading libfuse.so.2

AppImages require FUSE to run. 
You might still be able to extract the contents of this AppImage 
if you run it with the --appimage-extract option. 
See https://github.com/AppImage/AppImageKit/wiki/FUSE 
for more information

Is it a normal requirement to install FUSE to execute AppImages?

@fvarrui
Copy link
Owner

fvarrui commented Jul 18, 2022

Is it a normal requirement to install FUSE to execute AppImages?

Yes, are you testing on WSL? Because I got same error. I've tried on LinuxMint and it seems to be working fine. 🤷‍♂️

Here you can find instructions and why AppImage uses FUSE.

@fvarrui
Copy link
Owner

fvarrui commented Jul 18, 2022

Branch issue-214 merged into devel.

@fvarrui fvarrui added the fixed Issue fixed and release pending label Jul 18, 2022
@salmonb
Copy link
Author

salmonb commented Jul 18, 2022

are you testing on WSL?

No, I'm on Ubuntu 22.04. FUSE is already installed but it's FUSE 3, and the AppImage requires FUSE 2. It's possible to install FUSE 2 beside FUSE 3, which I did, and then the AppImage is running 👍

Do you know if there could be an option to choose the FUSE version when generating the AppImage?

Branch issue-214 merged into devel.

Great job 🥳

@fvarrui
Copy link
Owner

fvarrui commented Jul 18, 2022

JavaPackager v1.6.7 released to Maven Central. See changes here.

@fvarrui fvarrui closed this as completed Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feedback Waiting for feedback fixed Issue fixed and release pending
Projects
None yet
Development

No branches or pull requests

2 participants