9

I'm running Rakudo Star 2019.03.1 on Windows 7, Cro was installed by zef. Following the Getting Started section on the Cro website, the following should work:

The cro stub command generates stub services for you, to get started more quickly and with better defaults. Here we use it to create a simple HTTP service, with ID hello and in the hello directory:

cro stub http hello hello

...which actually does work, it generates a lot of files for the project including the .cro.yml file, which I assume is the central description file for the service. But if I try to follow the docs and run cro run (from inside the hello directory, I assumed):

The cro run command will start your service (and automatically restart the service if you change a file):

cro run

...the service isn't started but cro errors out:

A react block:
  in sub run-services at C:\rakudo\share\perl6\site\sources\709F4B18755ADE6922C88B8C44A0930A5DDD77C9 (Cro::Tools::CLI) line 227
  in sub MAIN at C:\rakudo\share\perl6\site\sources\709F4B18755ADE6922C88B8C44A0930A5DDD77C9 (Cro::Tools::CLI) line 199
  in block <unit> at C:\rakudo\share\perl6\site\resources\C1E87B0F084684C12CD87240AE4C12E746174570 line 1
  in sub MAIN at C:\rakudo\share\perl6\site\bin\cro line 3
  in block <unit> at C:\rakudo\share\perl6\site\bin\cro line 1

Died because of the exception:
    no such file or directory
      in any  at C:\rakudo\share/perl6/runtime/CORE.d.setting.moarvm line 1
      in sub run-services at C:\rakudo\share\perl6\site\sources\709F4B18755ADE6922C88B8C44A0930A5DDD77C9 (Cro::Tools::CLI) line 227
      in sub MAIN at C:\rakudo\share\perl6\site\sources\709F4B18755ADE6922C88B8C44A0930A5DDD77C9 (Cro::Tools::CLI) line 199
      in block <unit> at C:\rakudo\share\perl6\site\resources\C1E87B0F084684C12CD87240AE4C12E746174570 line 1
      in sub MAIN at C:\rakudo\share\perl6\site\bin\cro line 3
      in block <unit> at C:\rakudo\share\perl6\site\bin\cro line 1

This error message is unfortunately not speaking to me. What do I miss?

Elizabeth Mattijsen
  • 25,654
  • 3
  • 75
  • 105
zb226
  • 9,586
  • 6
  • 49
  • 79
  • 1
    It works for me, Ubuntu 19.04, Perl 6 version 2019.03. But I had to clear my `PERL6LIB` before running `cro stub`: `PERL6LIB= cro stub http hello hello`. If not, I got error: `Failed to get the directory contents of 'xxx': Failed to open dir: No such file or directory`, where `xxx` was an empty directory in my `PERL6LIB`. Apparently it did not check if the directory was empty – Håkon Hægland Jul 15 '19 at 23:04
  • @HåkonHægland `cro stub http hello hello` is actually working, it's the `cro run` that fails... – zb226 Jul 15 '19 at 23:06
  • 2
    Yes, but for me `cro run` works fine. So it is strange :) – Håkon Hægland Jul 15 '19 at 23:07
  • 2
    Ah, I see. I'm on Windows though, maybe that's the problem? – zb226 Jul 15 '19 at 23:08
  • 2
    maybe the problem is with Cro::Tools::Runner line 269 where it tries to run a command called `perl6`, which on windows would possibly have to be `perl6.exe` or `perl6.bat` or something? – timotimo Jul 15 '19 at 23:13
  • @timotimo: quick side-question - is there a shortcut to go from something like `Cro::Tools::Runner` to the hashed file name of the lib? – zb226 Jul 15 '19 at 23:15
  • 1
    @timotimo: found the module, tested adding a `.bat` or `.exe` but it doesn't cause any change :( – zb226 Jul 15 '19 at 23:19
  • 2
    you're likely running into this: https://stackoverflow.com/questions/56084388/how-to-hack-on-installed-perl6-module-source – timotimo Jul 15 '19 at 23:28
  • 1
    @timotimo You were right, twice! – zb226 Jul 16 '19 at 00:08

1 Answers1

8

Update

Somehow I missed this Cro github issue yesterday when googling, which is precisely what my problem was. I backlinked this question+answer in the github issue. A fix has since been merged and will be part of the next release of Cro. Props for the quick response everybody!


Original Answer

This could be resolved with the help of timotimo (Thanks!), who

  • suggested Cro::Tools::Runner calls perl6 instead of perl6.bat which is needed for Windows.
  • pointed me to this answer which has the important bits of information regarding changing code in zef-installed modules.

So I headed over to %USERPROFILE%\.zef\store\cro-0.8.1.tar.gz\cro-0.8.1\lib\Cro\Tools and patched the executable name in line 269 of Runner.pm6. Then I went back up to %USERPROFILE%\.zef\store\cro-0.8.1.tar.gz\cro-0.8.1 and recompiled and installed the module with the following command (note the --/test to skip the tests, which take a lot of time):

C:\...\.zef\store\cro-0.8.1.tar.gz\cro-0.8.1>zef install . --force-install --/test --verbose
The following local path candidates are already installed: .
===> Installing: cro:ver<0.8.1>
===> Install [OK] for cro:ver<0.8.1>

1 bin/ script [cro] installed to:
C:\rakudo\share\perl6\site\bin

Now, cro run spews what I believe to be ANSI codes at me, but it is working :)

C:\ws\perl6\hello>cro run
←[1;32mÔûÂ Starting hello (hello)←[0m
←[32m­ƒöî Endpoint HTTP will be at http://localhost:20000/←[0m
←[32m­ƒôô hello ←[0mListening at http://localhost:20000
zb226
  • 9,586
  • 6
  • 49
  • 79
  • 2
    This is what I wrote this morning. "Don't forget to click the check mark on your answer. :) Unless you're waiting till you can edit it to add a link to the bug report you file. ;)" But then I paused to go check if you had, then had to go do other things, and now returned here, and see your Addendum, your comment in the issue, and ugexe, jnthn, Altai-man swing into action. So, thanks, please move the Addendum to the top, noting the merge of the fix -- and then don't forget to accept your excellent answer. :) – raiph Jul 16 '19 at 21:53
  • @raiph: If I got you here for a second :) Another thing I noticed is, that unfortunately the automatic restarts on source file changes do not happen. Somehow I think this might be another Windows thing...? Should I open another question for that? – zb226 Jul 16 '19 at 22:27
  • "automatic restarts". I'm not sure what you mean. EITHER **1** Is there some auto restart feature in *Cro*? If so, I'd check Cro's issues and file a bug if there isn't one. OR **2** Do you mean something related to [How to hack on installed perl6 module source?](https://stackoverflow.com/questions/56084388/how-to-hack-on-installed-perl6-module-source). If you do, then have you also read the related links in the first comment on the question? Did all three answers make sense to you? Could you try the same thing on a non-Windows system? OR **3** Something else? – raiph Jul 16 '19 at 22:55
  • 1
    @raiph: It's **1**, the feature advertised in the docs (as quoted in the question). Didn't find a related issue on github. I'll see if I can setup Rakudo on a Linux machine tomorrow... – zb226 Jul 16 '19 at 23:50