croservices / cro

Development tools for building services and distributed systems in Raku using the Cro libraries.
https://cro.services/
Artistic License 2.0
88 stars 34 forks source link

cro run attempts to read all directories on start and fails when lacking privileges #128

Open camstuart opened 3 years ago

camstuart commented 3 years ago

Hi,

I am using a docker-compose.yml to start up postgres in my Cro application with the data directory mounted in the top level of my project.

But because the directory is created by docker, it is not readable to the user launching cro run. Oddly, cro run seems to be attempting to scan all directories, and when it hits this one, it fails.

You can replicate this very easily in an existing Cro project like so:

sudo mkdir foo
sudo chmod -R 600 foo
cro run

Exception:

A react block:
  in sub run-services at /home/cam/rakudo/share/perl6/site/sources/2F5DE0083923025BCEC5898DAEB588F0A0CEBDC3 (Cro::Tools::CLI) line 227
  in sub MAIN at /home/cam/rakudo/share/perl6/site/sources/2F5DE0083923025BCEC5898DAEB588F0A0CEBDC3 (Cro::Tools::CLI) line 199
  in block <unit> at /home/cam/rakudo/share/perl6/site/resources/31DFBB60DDF0B7CC0994DED3586AF43BA050D249 line 1
  in sub MAIN at /home/cam/rakudo/share/perl6/site/bin/cro line 3
  in block <unit> at /home/cam/rakudo/share/perl6/site/bin/cro line 1

Died because of the exception:
    Failed to get the directory contents of '/home/cam/dev/github.com/camstuart/raku-cro-realworld-example-api-app/foo': Failed to open dir: Permission denied
      in sub run-services at /home/cam/rakudo/share/perl6/site/sources/2F5DE0083923025BCEC5898DAEB588F0A0CEBDC3 (Cro::Tools::CLI) line 227
      in sub MAIN at /home/cam/rakudo/share/perl6/site/sources/2F5DE0083923025BCEC5898DAEB588F0A0CEBDC3 (Cro::Tools::CLI) line 199
      in block <unit> at /home/cam/rakudo/share/perl6/site/resources/31DFBB60DDF0B7CC0994DED3586AF43BA050D249 line 1
      in sub MAIN at /home/cam/rakudo/share/perl6/site/bin/cro line 3
      in block <unit> at /home/cam/rakudo/share/perl6/site/bin/cro line 1

Is there perhaps a way of telling cro run to ignore a given directory?

camstuart commented 3 years ago

I was able to get out of trouble by prefixing the directory with a . which are ignored. However, using the .cro.yml file and specifying the ignore locations did not seem to work:

ignore:
  - foo/

I wonder if a file stat just after: https://github.com/croservices/cro/blob/master/lib/Cro/Tools/Services.pm6#L43 and check for readable permissions, or skip would help? not sure how much that might slow the file watcher?