Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying self contained Perl 6 script

Tags:

raku

What is the best strategy to deploy a Perl 6 script which use external modules like LWP::Simple?

For example in Perl we have PAR. Is there are an option in Perl 6 to deploy a self contained script that the user need only to run without bothering himself with installing Rakudo and external Perl 6 modules?

like image 991
smith Avatar asked Aug 29 '16 11:08

smith


1 Answers

You can create a .jar file and then use java to execute the code. From there, there are plenty of tools to convert a .jar into a binary file (or .exe in Windows).

The syntax for that is:

perl6 --target=jvm  --output=your_file.jar your_file.pl6

If that script were the trivial

say "this is running as a .jar file"

You should be able to run java -jar your_file.jar and get

this is running as a .jar file

On macOS, there is a bit of a wrinkle since this feature requires you to build perl6 (Rakudo Star) with Java 1.7+ instead of the Mac's system Java. For this reason the version on your system may not have shipped with JVM support.

If you're using homebrew, here's what you do to fix that:

  1. brew uninstall perl6
  2. brew tap homebrew/versions (so you can install Java 1.7)
  3. brew install Caskroom/versions/java7 (install Java 1.7)
  4. optionally: open a new tab in terminal (you only need to do this if, for some reason, you get an error that Java 1.6 is still in use. )
  5. brew install perl6 --with-jvm (build perl6 with Java Virtual Machine support)
like image 117
Daniel Lathrop Avatar answered Nov 18 '22 15:11

Daniel Lathrop