How to download/pull charms from charmhub?

Hi, I’m trying to download/pull a charm from the charmhub and I’m getting a bit confused.

Is charm-tools and charm pull still the only way to do this?

I was trying to download rev 19 of the ubuntu charm which is available in all the channels, however working with charm was not straight forward. It defaulted to referring to the charm store (cs:) and downloaded rev 18 unless ubuntu-19 was specified.

Am I doing something wrong?

P.S. charm still refers to the charm store.

$ charm version
charmstore-client 2.5.1
charm-tools 2.8.2

$ charm pull --help
Usage: charm pull [flags] <charm or bundle id> [--channel <channel>] [<directory>]

Summary:
download a charm or bundle from the charm store

Flags:
-B, --no-browser-login  (= false)
    do not use web browser for authentication
-a, --agent (= "")
    name of file containing agent login details
--auth  (= )
    user:passwd to use for basic HTTP authentication
-c, --channel  (= )
    the channel the charm or bundle is assigned to (stable|candidate|beta|edge|unpublished)

Details:
The pull command downloads a copy of a charm or bundle
from the charm store into a local directory.
If the directory is unspecified, the directory
will be named after the charm or bundle, so:

   charm pull trusty/wordpress

will fetch the wordpress charm into the
directory "wordpress" in the current directory.

To select a channel, use the --channel option, for instance:

        charm pull wordpress --channel edge
$ charm pull ubuntu
cs:ubuntu-18

$ charm pull ch:ubuntu
cs:ubuntu-18

$ charm pull ch:ubuntu --channel latest/stable
ERROR cannot get archive: Invalid channel: latest/stable

$ charm pull ch:ubuntu --channel stable
cs:ubuntu-18

$ charm pull ch:ubuntu-19
cs:ubuntu-19
1 Like

You can use juju to download charms from Charmhub.

juju download ubuntu --channel latest/stable --filepath ubuntu.charm

In case you’d like to modify the downloaded charm, you can unzip it.

unzip -q ubuntu.charm -d ubuntu/

Once your modifications are done, zip it back up.

cd ubuntu/ && zip -rq ../ubuntu.charm . && cd ..

This also works for bundles as well!

juju download charmed-kubernetes --channel 1.24/stable --filepath charmed-kubernetes-1.24-stable.bundle
unzip -q charmed-kubernetes-1.24-stable.bundle -d charmed-kubernetes-1.24-stable/
1 Like