Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install local modules?

Tags:

raku

For creating and maintaining Perl 5 modules, I use Dist::Zilla. One of my favorite features is being able to install local modules.

However, with Perl 6, I'm not sure how to install local modules. Sure, I can use use lib:

use lib 'relative/path';
use My::Awesome::Module;

But, I'd really like to be able to install My::Awesome::Module, so that all I had to do was use it:

use My::Awesome::Module;

One way to accomplish this, would be setting PERL6LIB, but that still isn't "installing" a module like zef install ./My-Awesome-Module.


Update: Looks like I need to craft an appropriate META6.json file.

like image 257
Christopher Bottoms Avatar asked Apr 05 '17 13:04

Christopher Bottoms


People also ask

How do I install all node modules?

It's simple. If you want to install all the node_modules from the package. json file you simply put: npm install in terminal (on the same directory where the package. json exists) and it would install all the node modules in the folder called node_modules .


2 Answers

To understand how to setup a module to be understood by toolchain utilities, see Preparing the module. Typically this means adding a META6.json file that describes the distribution, including quasi-manifest elements such as which files you really meant to include/provide. Once the META6.json is created the module is ready to be installed:

zef install ./My-Awesome-Module

which (assuming no uninstalled dependencies) is essentially:

my $install-to-repo = CompUnit::RepositoryRegistry.repository-for-name("site");
my $preinstall-dist = Distribution::Path.new("./My-Awesome-Module");
$install-to-repo.install($preinstall-dist);

Starting with rakudo 2019.01 you can, assuming no uninstalled dependencies, install a local distribution without a META6.json -- but this is purely developmental nicety that won't work on complex setups that do not have e.g. namespacing and file structures that can be inferred.

my $read-from-repo   = CompUnit::Repository::FileSystem.new(prefix => "./My-Awesome-Module/lib");
my $install-to-repo  = CompUnit::RepositoryRegistry.repository-for-name("site");
my $some-module-name = "My::Awesome::Module"; # needed to get at the Distribution object in the next step
my $preinstall-dist  = $read-from-repo.candidates($some-module-name).head;
$install-to-repo.install($preinstall-dist);
like image 187
ugexe Avatar answered Nov 04 '22 01:11

ugexe


I'm writing a bin that may help you: http://github.com/FCO/6pm

like image 35
SmokeMachine Avatar answered Nov 04 '22 01:11

SmokeMachine