Deploying self contained Perl 6 script
Asked Answered
H

1

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?

Haswell answered 29/8, 2016 at 11:22 Comment(2)
2024 update I'm briefly reviewing SOs related to producing a stand-alone exe. I've decided to write some FYI comments. I've found this SO plus 3 others: How can I compile perl6 file to exe, how do I create a stand-alone executable with perl 6?, how to compile perl6 program to generate bytecode?.Cordless
See also (reddit comment "Distributing Raku Programs".Cordless
W
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)
Weasner answered 13/10, 2016 at 23:20 Comment(1)
Here are some developments a few years later (2013→2016): there was an NQP tool to do this 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.Lamed

© 2022 - 2024 — McMap. All rights reserved.