Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get 'divide by zero` errors when I try to run my script with Rakudo?

Tags:

raku

rakudo

I just built Rakudo and Parrot so that I could play with it and get started on learning Perl 6. I downloaded the Perl 6 book and happily typed in the first demo program (the tennis tournament example).

When I try to run the program, I get an error:

Divide by zero
current instr.: '' pc -1 ((unknown file):-1)

I have my perl6 binary in the build directory. I added a scripts directory under the rakudo build directory:

  rakudo
  |- perl6
  \- scripts
     |- perlbook_02.01
     \- scores

If I try to run even a simple hello world script from my scripts directory I get the same error:

#!/home/daotoad/rakudo/perl6

use v6;
say "Hello nurse!";

However if I run it from the rakudo directory it works.

It sounds like there are some environment variables I need to set, but I am at a lost as to what the are and what values to give them.

Any thoughts?

Update:

I'd rather not install rakudo at this point, I'd rather just run things from the build directory. This will allow me to keep my changes to my system minimal as I try out different Perl6 builds (Rakudo * is out very soon).

The README file encouraged me to think that this was possible:

   $ cd rakudo
   $ perl Configure.pl --gen-parrot
   $ make

This will create a "perl6" or "perl6.exe" executable in the current (rakudo) directory. Programs can then be run from the build directory using a command like:

   $ ./perl6 hello.pl

Upon rereading, I found a reference to the fact that it is necessary to install rakudo before running scripts outside the build directory:

Once built, Rakudo's make install target will install Rakudo and its libraries into the Parrot installation that was used to create it. Until this step is performed, the "perl6" executable created by make above can only be reliably run from the root of Rakudo's build directory. After make install is performed, the installed executable can be run from any directory (as long as the Parrot installation that was used to create it remains intact).

So it looks like I need to install rakudo to play with Perl 6.

The next question is, where rakudo be installed? README says into the Parrot install used to build.

I used the --gen-parrot option in my build, which looks like it installs into rakudo/parrot-install. So rakudo will be installed into my rakudo\parrot-install?

Reading the Makefile, supports this conclusion. I ran make install, and it did install into parrot_install.

This part of the build/install process is unclear for a newbie to Perl6. I'll see if I can up with a documentation patch to clarify things.

Off the top of my head:

  1. Emphasize running make install before running scripts outside of build. This requirement is currently burried in the middle of a paragraph and can be easily missed by someone skimming the docs (me).

  2. Explicitly state that with --gen-parrot will install perl6 into the parrot_install directory.

like image 461
daotoad Avatar asked Jun 29 '10 19:06

daotoad


1 Answers

In response to your update I've now updated the README:

http://github.com/rakudo/rakudo/commit/261eb2ae08fee75a0a0e3935ef64c516e8bc2b98

I hope you find that clearer than before. If you still see room for improvement, please consider submitting a patch to [email protected].

like image 160
moritz Avatar answered Sep 19 '22 23:09

moritz