Install modules in other rakudo versions using rakubrew

387 Views Asked by At

When upgrading rakudo version using rakubrew, is pretty easy to change versions, but I wnat to know if it is posible to import raku modules from the older version to the new version. doign zef install automatically:

to update:

rakubrew build 2020.10

but then:

❯ raku
Welcome to ™ v2020.10.
Implementing the ™ programming language v6.d.
Built on MoarVM version 2020.10.

You may want to `zef install Readline` or `zef install Linenoise` or use rlwrap for a line editor

To exit type 'exit' or '^D'

so I need to install all modules that I currently use:

rakubrew build-zef zef install Sparrow6 zef install Linenoise

so exists any file .zef or .rakubrew or something that checks to maintain this modules automatically

2

There are 2 best solutions below

0
On

You can get the list of installed modules using zef list --installed. Note you probably want to ignore the share/perl6 repo, as the CORE module included in it is specific to each version of rakudo.

see: https://github.com/ugexe/zef#list-from

list [*@from]

List known available distributions

$ zef --installed list

===> Found via /home/nickl/.rakubrew/moar-master/install/share/perl6/site

CSV::Parser:ver<0.1.2>:auth<github:tony-o>

Zef:auth<github:ugexe>

===> Found via /home/nickl/.rakubrew/moar-master/install/share/perl6

CORE:ver<6.c>:auth<perl>

Alternatively you can use the following one-liner to get a list:

$ raku -e 'say $*REPO.repo-chain.grep(CompUnit::Repository::Installation).map(*.installed.Slip).grep(*.defined).map({ CompUnit::Repository::Distribution.new($_).Str }).join(" ")'

Text::Table::Simple:ver<0.0.7>:auth<github:ugexe>:api<> CSV::Parser:ver<0.1.2>:auth<github:tony-o>:api<> CORE:ver<6.d>:auth<perl>:api<>

# $*REPO.repo-chain.grep(CompUnit::Repository::Installation) # Get only repos for installed raku modules
# .map(*.installed.Slip)                                     # Get a list of installed modules for this repo, and Slip it into the outer singular results list
# .grep(*.defined)                                           # Some repos will have had no modules, so remove these undefined entries
# .map({ CompUnit::Repository::Distribution.new($_).Str })   # Use CompUnit::Repository::Distribution to get at the normalized identifier
# .join(" ")                                                 # Join the results together

Once you have chosen a way to create a list of what needs to be installed you can just pass that list to zef (although your shell may require you to quote names passed in explicitly on the command line)

5
On

rakubrew installs different Raku versions in different directories $HOME/.rakubrew/versions/moar-*

So each Raku version has its own separate Installation repositories ( site, vendor, ... ).

And because zef installs distributions to site repo by default, I think. So the modules are not available under multiple versions.

However, because Raku uses the home Installation repo (#inst/home/user-name/.raku) and it exists in repo-chain so you can install the modules you want available on all versions to home repo (~/.raku). ( the modules will be precompiled the first time useed in a new Raku version ).

Please note I haven't tested that with zef but I use Pakku which installs to home repo by default, and the modules I install to home are available to all rakubrew Raku versions on my Linux machine.