Pakku State Update
Tags: rakulang
Published: 2023-05-18 18:19:01

[Pakku](https://github.com/hythm7/Pakku) is a package manager for the [Raku Programming Language](https://raku.org/). In this post I'm going to introduce two Pakku commands, `state` and `update`.


###state

`state` command gives an overview of the current state of installed distributions. eg. if there are missing dependencies, if a dist can be updated to a higher version or can be cleaned from the system. etc.


To check the current state of installed Raku dists:

<pre>
> pakku state
1 - 🦋 STT: ｢...｣
2 - 🦋 UPD: ｢App::Rak:ver&lt;0.2.17>:auth&lt;zef:lizmat>:api&lt;>｣
3 - 🦋 UPD: ｢App::Rak:ver&lt;0.2.16>:auth&lt;zef:lizmat>:api&lt;>｣
4 - 🧚 STT: ｢App::Rak:ver&lt;0.2.15>:auth&lt;zef:lizmat>:api&lt;>｣
...
</pre>

1. Reading current state, basically go through all installed dists and check if all deps are met, any updates available, etc.
2. There is an update available for `App::Rak` dist.
3. Same as above but another version.
4. The current state of installed `App::Rak` dist is OK, no issues.

<pre>
🧚 STT: ｢Backtrace::Files:ver&lt;0.0.3>:auth&lt;zef:lizmat>:api&lt;>｣
🧚 STT: ｢CLI::Version:ver&lt;0.0.8>:auth&lt;zef:lizmat>:api&lt;>｣
🧚 STT: ｢Git::Files:ver&lt;0.0.6>:auth&lt;zef:lizmat>:api&lt;>｣
🧚 STT: ｢IO::Path::AutoDecompress:ver&lt;0.0.2>:auth&lt;zef:lizmat>:api&lt;>｣
...
</pre>
The state of the above dists look fine, no issues, no updates available, no missing deps.

<pre>
🐞 DEP: ｢JSON::Fast:ver&lt;0.17>:auth&lt;cpan:TIMOTIMO>｣ missing!
🦗 STT: ｢JSON::Fast::Hyper:ver&lt;0.0.3>:auth&lt;zef:lizmat>:api&lt;>｣
...
</pre>

There is a dependency missing, basically `JSON::Fast::Hyper` depends on `JSON::Fast`, but `JSON::Fast` is not installed. So state of `JSON::Fast::Hyper` is not OK.

<pre>
🦋 UPD: ｢String::Utils:ver&lt;0.0.21>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 UPD: ｢String::Utils:ver&lt;0.0.20>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 UPD: ｢String::Utils:ver&lt;0.0.19>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 UPD: ｢String::Utils:ver&lt;0.0.18>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 UPD: ｢String::Utils:ver&lt;0.0.17>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 UPD: ｢String::Utils:ver&lt;0.0.16>:auth&lt;zef:lizmat>:api&lt;>｣
🧚 STT: ｢String::Utils:ver&lt;0.0.15>:auth&lt;zef:lizmat>:api&lt;>｣
...
</pre>

There  are multiple updates available for installed `String::Utils` dist.

<pre>
1 - 🦋 UPD: ｢paths:ver&lt;10.0.9>:auth&lt;zef:lizmat>:api&lt;>｣
2 - 🧚 STT: ｢paths:ver&lt;10.0.8>:auth&lt;zef:lizmat>:api&lt;>｣
3 - 🦋 CLN: ｢paths:ver&lt;10.0.8>:auth&lt;zef:lizmat>:api&lt;>｣
4 - 🧚 STT: ｢paths:ver&lt;10.0.9>:auth&lt;zef:lizmat>:api&lt;>｣
5 - 🧚 STT: ｢rak:ver&lt;0.0.47>:auth&lt;zef:lizmat>:api&lt;>｣
...
</pre>

1. There is an update available for `paths` dist
2. the current state of `paths:ver<10.0.8>` dist is OK
3. `paths:ver<10.0.8>` dist can be cleand, this means there is a higher version already installed (which is evident by next line), and no other dists depend on it.
4. `paths:ver<10.0.9>` dist state is OK
5. `rak` dist state is OK


Now I have an overview of the current state of the system, and if more info needed, I can run in debug mode and see more information like, dist dependencies, reverse dependencies, etc.

With this info I can install the missing deps or clean not needed dists. I also can update the system to get latest available versions, which what I'll do in the next section of this post.

###update

`update` command is used for updating all installed dists or specific dist to latest available version.

From previous section I found out that there are updates for `App::Rak` and `String::Utils` dists, there is also a missing dependency `JSON::Fast:ver<0.17>:auth<cpan:TIMOTIMO>` and some dists can be cleaned.

So time to run the `update` command:

<pre>
> pakku update
...
🦋 STT: ｢...｣
🦋 UPD: ｢App::Rak:ver&lt;0.2.17>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 UPD: ｢String::Utils:ver&lt;0.0.21>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 UPD: ｢paths:ver&lt;10.0.9>:auth&lt;zef:lizmat>:api&lt;>｣
...
</pre>

The `update` command starts by reading the current state, identify the updatable dists and resolve deps...

<pre>
🧚 TST: ｢JSON::Fast:ver&lt;0.17>:auth&lt;cpan:TIMOTIMO>:api&lt;>｣
🦋 STG: ｢App::Rak:ver&lt;0.2.17>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 TST: ｢App::Rak:ver&lt;0.2.17>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 TST: ｢01-basic.rakutest｣
🧚 TST: ｢App::Rak:ver&lt;0.2.17>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 STG: ｢String::Utils:ver&lt;0.0.21>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 TST: ｢String::Utils:ver&lt;0.0.21>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 TST: ｢01-basic.rakutest｣
🦋 TST: ｢02-selective-importing.t｣
🧚 TST: ｢String::Utils:ver&lt;0.0.21>:auth&lt;zef:lizmat>:api&lt;>｣
🧚 BIN: ｢rak｣
</pre>

Installed `JSON::Fast` missing dep, updated `App::Rak` and `String::Utils`

<pre>
🦋 RMV: ｢App::Rak:ver&lt;0.2.15>:auth&lt;zef:lizmat>:api&lt;> paths:ver&lt;10.0.8>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 RMV: ｢App::Rak:ver&lt;0.2.15>:auth&lt;zef:lizmat>:api&lt;>｣
🦋 RMV: ｢paths:ver&lt;10.0.8>:auth&lt;zef:lizmat>:api&lt;>｣
🧚 -Ofun
</pre>

Cleaning the not needed dists, the older versions of `App::Rak` and `paths`.
One might notice that `String::Utils:ver<0.0.15>` was not cleaned, and that is  because `App::Rak` depends on that specific version.

If one doesn't want to clean older versions of dists, `noclean` option can be provided to `update` command.

Thanks for reading!