{"id":32216036,"url":"https://github.com/domm/lib-projectroot","last_synced_at":"2025-10-22T07:55:05.311Z","repository":{"id":23936710,"uuid":"27318037","full_name":"domm/lib-projectroot","owner":"domm","description":"easier loading of local libs","archived":false,"fork":false,"pushed_at":"2024-02-05T11:40:32.000Z","size":30,"stargazers_count":2,"open_issues_count":3,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T07:54:55.489Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/domm.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-29T23:14:27.000Z","updated_at":"2022-03-10T15:46:41.000Z","dependencies_parsed_at":"2022-09-12T11:51:08.843Z","dependency_job_id":null,"html_url":"https://github.com/domm/lib-projectroot","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/domm/lib-projectroot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domm%2Flib-projectroot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domm%2Flib-projectroot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domm%2Flib-projectroot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domm%2Flib-projectroot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/domm","download_url":"https://codeload.github.com/domm/lib-projectroot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/domm%2Flib-projectroot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280402184,"owners_count":26324587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-22T07:55:03.979Z","updated_at":"2025-10-22T07:55:05.304Z","avatar_url":"https://github.com/domm.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nlib::projectroot - easier loading of a project's local libs\n\n# VERSION\n\nversion 1.010\n\n# SYNOPSIS\n\n    # your_project/bin/somewhere/deep/down/script.pl\n    use strict;\n    use warnings;\n    # look up from the file's location until we find a directory\n    # containing a directory named 'lib'. Add this dir to @INC\n    use lib::projectroot qw(lib);\n\n    # look up until we find a dir that contains both 'lib' and 'foo',\n    # add both to @INC\n    use lib::projectroot qw(lib foo);\n\n    # look up until we find 'lib' and 'local'. Add 'lib' to @INC,\n    # load 'local' via local::lib\n    use lib::projectroot qw(lib local::lib=local);\n\n    # based on the dir we found earlier, go up one dir and try to add\n    # 'Your-OtherModule/lib' and 'Dark-PAN/lib' to @INC\n    lib::projectroot-\u003eload_extra(Your-OtherModule Dark-PAN);\n\n    # the same as above\n    use lib::projectroot qw(lib local::lib=local extra=Your-OtherModule,Dark-PAN);\n\n    # if you want to know where the project-root is:\n    say $lib::projectroot::ROOT;  # /home/domm/jobs/Some-Project\n\n    # also load local::libs installed in extras\n    use lib::projectroot qw(lib local::lib=local extra_with_local=Your-OtherModule,Dark-PAN);\n\n# DESCRIPTION\n\nI'm usually using a setup like this:\n\n    .\n    ├── AProject\n    │   ├── bin\n    │   │   ├── db\n    │   │   │   └── init.pl\n    │   │   ├── onetime\n    │   │   │   ├── fixup\n    │   │   │   │   └── RT666_fix_up_fubared_data.pl\n    │   │   │   └── import_data.pl\n    │   │   └── web.psgi\n    │   ├── lib\n    │   └── local\n    ├── MyHelperStuff\n    │   └── lib\n    └── CoolLib-NotYetOnCPAN\n        └── lib\n\nThere is `AProject`, which is the actual code I'm working on. There\nis also probably `BProject`, e.g. another microservice for the same\ncustomer. `AProject` has its own code in `lib` and its CPAN\ndependencies in `local` (managed via `Carton` and used via\n`local::lib`). There are a bunch of scripts / \"binaries\" in `bin`,\nin a lot of different directories of varying depth.\n\nI have some generic helper code I use in several projects in\n`MyHelperStuff/lib`. It will never go to CPAN. I have some other code\nin `CoolLib-NotYetOnCPAN/lib` (but it might end up on CPAN if I ever\nget to clean it up...)\n\n`lib::projectroot` makes it easy to add all these paths to `@INC` so\nI can use the code.\n\nIn each script, I just have to say:\n\n    use lib::projectroot qw(lib local::lib=local);\n\n`lib` is added to the beginning of `@INC`, and `local` is loaded via\n`local::lib`, without me having to know how deep in `bin` the\ncurrent script is located.\n\nI can also add\n\n    lib::projectroot-\u003eload_extra(qw(MyHelperStuff CoolLib-NotYetOnCPAN));\n\nto get my other code pushed to `@INC`. (Though currently I put this\nline, and some other setup code like initialising `Log::Any` into\n`AProject::Run`, and just `use AProject::Run;`)\n\nYou can also define extra dists directly while loading `lib::projectroot`:\n\n    use lib::projectroot qw(\n        lib\n        local::lib=local\n        extra=MyHelperStuff,CoolLib-NotYetOnCPAN\n    );\n\nIf your extra dists themselves have deps which are installed into their `local::lib`, you can add those via `extra_with_local`:\n\n    use lib::projectroot qw(\n        lib\n        local::lib=local\n        extra=MyHelperStuff\n        extra_with_local=CoolLib-NotYetOnCPAN\n    );\n\nYou can access `$lib::projectroot::ROOT` if you need to know where the projectroot actually is located (e.g. to load some assets)\n\n# TODOs\n\nSome ideas for future releases:\n\n- what happens if `$PERL5LIB` is already set?\n- think about the security issues raised by Abraxxa (http://prepan.org/module/nY4oajhgzJN 2014-12-02 18:42:07)\n\n# SEE ALSO\n\n- [FindBin](https://metacpan.org/pod/FindBin) - find out where the current binary/script is located, but no `@INC` manipulation. In the Perl core since forever. Also used by `lib::projectroot`.\n- [Find::Lib](https://metacpan.org/pod/Find%3A%3ALib) - combines `FindBin` and `lib`, but does not search for the actual location of `lib`, so you'll need to know where your scripts is located relative to `lib`.\n- [FindBin::libs](https://metacpan.org/pod/FindBin%3A%3Alibs) - finds the next `lib` directory and uses it, but no [local::lib](https://metacpan.org/pod/local%3A%3Alib) support. But lots of other features\n- [File::FindLib](https://metacpan.org/pod/File%3A%3AFindLib) - find and use a file or dir based on the script location. Again no [local::lib](https://metacpan.org/pod/local%3A%3Alib) support.\n- and probably more...\n\n# THANKS\n\nThanks to `eserte`, `Smylers` \u0026 `abraxxa` for providing feedback\nat [prepan.org](http://prepan.org/module/nY4oajhgzJN). Meta-thanks to\n[kentaro](http://twitter.com/kentaro) for running prepan, a very handy\nservice!\n\nThanks to `koki`, `farhad` and `Jozef` for providing face-to-face\nfeedback.\n\n# AUTHOR\n\nThomas Klausner \u003cdomm@plix.at\u003e\n\n# COPYRIGHT AND LICENSE\n\nThis software is copyright (c) 2014 - 2021 by Thomas Klausner.\n\nThis is free software; you can redistribute it and/or modify it under\nthe same terms as the Perl 5 programming language system itself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomm%2Flib-projectroot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdomm%2Flib-projectroot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdomm%2Flib-projectroot/lists"}