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

Auto generated scripts drop last character if its an r #1121

Closed
tobyweston opened this issue Apr 23, 2018 · 8 comments
Closed

Auto generated scripts drop last character if its an r #1121

tobyweston opened this issue Apr 23, 2018 · 8 comments
Labels
bug universal Zip, tar.gz, tgz and bash issues

Comments

@tobyweston
Copy link
Contributor

tobyweston commented Apr 23, 2018

Expected behaviour

sbt universal:packageBin generates the following script fragment:

loadConfigFile() {
  cat "$1" | sed '/^\#/d;s/\r$//'
}

But when run on Mac against the following:

-J-server
-J-Xms256m
-J-Xmx512m
-Dcom.sun.management.jmxremote=true 
-Dcom.sun.management.jmxremote.port=1616 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 

Actual behaviour

It drops the r from server, so the JVM fails to start with:

Unrecognized option: -serve
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

You can verify independently of script generation from a terminal by cat'ing the application.ini or similar into sed. As can be seen here:

$ cat src/universal/conf/application.ini | sed '/^\#/d;s/\r$//'
-J-serve
-J-Xms256m
-J-Xmx512m
-Dcom.sun.management.jmxremote=true 
-Dcom.sun.management.jmxremote.port=1616 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 

$ cat src/universal/conf/application.ini 
-J-server
-J-Xms256m
-J-Xmx512m
-Dcom.sun.management.jmxremote=true 
-Dcom.sun.management.jmxremote.port=1616 
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false

Windows seems fine.

Dropping the \r from the sed command seems to help. Tested with the following

ryder
slider
server
murder

...before I ran out of r words

tobyweston added a commit to tobyweston/temperature-machine that referenced this issue Apr 23, 2018
@dwickern
Copy link
Collaborator

That's supposed to strip carriage return but sed works differently on OSX/BSD where \r matches a literal r. We had the same issue in sbt's own launcher: sbt/sbt-launcher-package#186

Would you mind opening a PR with the same fix from sbt/sbt-launcher-package#187?

@tobyweston
Copy link
Contributor Author

tobyweston commented Apr 23, 2018

Will do, looks good:

$ echo server | sed '/^\#/d;s/\r$//'
serve
$ echo server | sed $'/^\#/d;s/\r$//'
server

Should l leave the ash equivalent alone?

@dwickern
Copy link
Collaborator

I suppose it wouldn't hurt to update the ash script too... I don't have any experience with it personally

tobyweston added a commit to tobyweston/sbt-native-packager that referenced this issue Apr 23, 2018
tobyweston added a commit to tobyweston/sbt-native-packager that referenced this issue Apr 23, 2018
@tobyweston
Copy link
Contributor Author

PR #1122

tobyweston added a commit to tobyweston/temperature-machine that referenced this issue May 8, 2018
@anilkumarmyla
Copy link
Contributor

I hit the same error while using -J-XX:+HeapDumpOnOutOfMemoryError, got intrigued and found this issue

@muuki88 any chance there will be a new release of sbt-native-packager with this fix?

@muuki88
Copy link
Contributor

muuki88 commented Jun 12, 2018

Thanks for the reminder 😍 Haven't released in a while. A new version will be up today.

@muuki88
Copy link
Contributor

muuki88 commented Jun 12, 2018

done :)

@anilkumarmyla
Copy link
Contributor

thank you @muuki88 , will give the new version a try!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug universal Zip, tar.gz, tgz and bash issues
Projects
None yet
Development

No branches or pull requests

4 participants