17

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?

Pat
  • 36,282
  • 18
  • 72
  • 87
smith
  • 3,232
  • 26
  • 55

1 Answers1

8

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)
Daniel Lathrop
  • 191
  • 1
  • 8
  • Here are some developments a few years later (2013→2016): there was [an NQP tool to do this](http://code.activestate.com/lists/perl6-compiler/13740/) but I'm not sure that it's working. It is possible today to run Perl 6 in the JVM (when Rakudo is complied with the JVM backend), but I'm not sure if it is presently possible to create a standalone JAR. – Tommy Stanton Feb 27 '19 at 00:20