guild icon
Toit
#Use jag to determine which version of a package is installed
Thread channel in help
addshore
addshore 08/14/2025 02:32 PM
I have some docs that want to do copy paste instructions, and I dont want to update them every time a new version of a package is updated.

It is somehting like

mkdir my-x-project cd my-x-project jag pkg init jag pkg install github.com/x-io/toit-x

then

cp ./.packages/github.com/x-io/toit-x/v0.1.1/examples/eink.toit ./main.toit

But I dont want to hardcode v0.1.1
Is there already a command I am missing that might say what is installed and being used by the project?
(edited)
addshore
addshore 08/14/2025 02:33 PM
ls ./.packages/github.com/x-io/toit-x/ | sort -V | tail -n 1 is the best i can some up with, but a bit evil, and techncially the highest thing on disk may not be what is used..?
floitsch
floitsch 08/14/2025 02:33 PM
I would definitely not rely on it. I'm in the process of rewriting the package manager (this time in Toit), and it won't (necessarily) follow the same directory conventions anymore.
floitsch
floitsch 08/14/2025 02:35 PM
Depending on the tutorial you could just install a specific version of your package.
floitsch
floitsch 08/14/2025 02:35 PM
that would hardcode the version a bit earlier, but at least the steps would always work.
floitsch
floitsch 08/14/2025 02:40 PM
For now, you could use the package.lock file. That's how the compiler finds the packages:
builder.join(package_dirs[i]); builder.join(entry.url); builder.join(entry.version);
floitsch
floitsch 08/14/2025 02:41 PM
As I said: I intend to change this in the future. (using the URLs as path is problematic; especially on Windows)
addshore
addshore 08/14/2025 02:49 PM
VERSION=$(jag pkg search lightbug-io/toit-lightbug | awk '{print $3}') :😛:
addshore
addshore 08/14/2025 02:50 PM
although now I'm depending on awk xD
floitsch
floitsch 08/14/2025 02:53 PM
And you might also run into issues with the new version of toit pkg.
floitsch
floitsch 08/14/2025 02:53 PM
The output might change.
👍1
11 messages in total