Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to ensure charm apt dependencies

See original GitHub issue

Before a charm does ‘import yaml’ or ‘import psycopg2’, we need to ensure that these non-core dependencies are installed on the host system.

Currently, it looks like we need a stanza like this at the start of src/

EDIT(niemeyer): Please don’t do that as it’s an ugly hack. See notes below.

import subprocess
    import yaml
    import psycopg2
except ImportError:
        'apt-get', '--assume-yes', '--option=Dpkg::Options::=--force-confold', 'install',
        'python3-yaml', 'python3-psycopg2',
    import yaml
    import psycopg2

I don’t think we can hide this uglyness in hooks/install, as it is expected to be a symlink.

It would be best if this could somehow be bootstrapped using code in the operator framework, so that the ‘apt-get installs’ get run in a consistent manner with any OS release specific settings.

Perhaps the operator framework could detect at import time that it is a) being imported from a script in hooks/* b) in a hook environment, and if so run platform specific bootstrapping to install apt packages listed in a .txt or .yaml file. Extra points if we can support PPAs, but they are much more likely to contain application dependencies that the charm should be installing, rather than charm dependencies needed for the charm code to run.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

mthaddoncommented, Nov 6, 2020

Ah indeed, I should learn to read the title of issues before replying to them (apt dependencies).

pengalecommented, Sep 1, 2022

I believe that this is addressed well by charmcraft, or by charmcraft plans.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Platform Install Manual — Charm-Crypto 0.50 documentation
Another way to install dependencies is to use your package manager of choice. ... Charm requires 2.7 or 3.x) and header files/static library:...
Read more >
Charms.Reactive Documentation
You can tell it to install python and apt dependencies of your handlers. ... This ensures that all charms using that interface protocol...
Read more >
Install charm on Ubuntu using the Snap Store - Snapcraft
Enable snaps on Ubuntu and install charm. Snaps are applications packaged with all their dependencies to run on all popular Linux ...
Read more >
Charm 2.0 makes it even easier to publish charms - Ubuntu
sudo apt update sudo apt install charm charm-tools ... 2.1.1 godeps -u $GOPATH/src/ go get ...
Read more >
How to manage dependencies between Transport Requests ...
You want to ensure that object dependencies are maintained in the Transport Request import sequence when using ChaRM; You want ChaRM to trigger...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found