Installing pack from disk does not include lib/ directory

I have a pack (it is a Git repo) that I am attempting to install from disk using
st2 pack install file://<path to pack>. The pack installs successfully, but there is a lib sub-directory within my actions folder that is not moved into /opt/stackstorm/packs.

Below is how my pack is structured on disk before installing:

> pwd
> ls -l
-rw-r--r--. 1 root root 470 Mar 24  2021
-rw-r--r--. 1 root root 483 Mar 23 16:08 create_release.yaml
-rw-r--r--. 1 root root   0 Feb  8 23:58
drwxr-xr-x. 2 root root  67 Feb  8 23:58 lib
-rw-r--r--. 1 root root 394 Mar 24  2021
-rw-r--r--. 1 root root 404 Mar 23 16:13 list_releases.yaml

> ls -l lib
-rw-r--r--. 1 root root 2093 Mar 23 16:11
-rw-r--r--. 1 root root    0 Feb  8 23:58

And here is a snippet from the log from when I installed this pack with the --debug flag:

# -------- begin 140499208565520 request ----------
curl -X GET -H  'Connection: keep-alive' -H  'Accept-Encoding: gzip, deflate' -H  'Accept: */*' -H  'User-Agent: python-requests/2.14.2' -H  'X-Auth-Token: aacc49af1148409aa9659e4f3d757d66'
# -------- begin 140499208565520 response ----------
    "files": [
    "name": "mypack",
    "contributors": [],
    "author": "justinm",
    "description": "My test pack",
    "system": {},
    "email": "",
    "version": "1.0.0",
    "dependencies": [],
    "keywords": [],
    "path": "/opt/stackstorm/packs/mypack",
    "ref": "mypack",
    "id": "605a5211a54923e4429fbfde",
    "uid": "mypack"

The lib directory is not included in the files list, and it does not exist in /opt/stackstorm/packs either:

> ls -l /opt/stackstorm/packs/mypack/actions
-rwxrwxr-x. 1 root st2packs 470 Mar 24 09:19
-rwxrwxr-x. 1 root st2packs 483 Mar 24 09:19 create_release.yaml
-rwxrwxr-x. 1 root st2packs   0 Mar 24 09:19
-rwxrwxr-x. 1 root st2packs 394 Mar 24 09:19
-rwxrwxr-x. 1 root st2packs 404 Mar 24 09:19 list_releases.yaml

My actions are failing because they rely on code in this lib directory. Anyone have any ideas? This lib directory has been committed into my Git repo as well.

I’m not sure, that’s weird.

Do you have the appropriate flag turned on in your st2.conf?

See Sharing code between Sensors and Python Actions — StackStorm 3.4.0 documentation :

This feature is turned off by default to avoid potential issues that might arise due to existing pack structures and lib imports. You may require to refactor your pack if enabling this feature breaks your packs. To enable this feature, simply set the following config option in /etc/st2/st2.conf :

enable_common_libs = True

You have to restart st2 via st2ctl restart for the config change to be picked up.

We do not have that flag enabled, however we’re also not trying to share the lib dir between actions and sensors. In fact, I added a couple of sensors to sensors along with a lib directory containing shared code for sensors, and it’s not installing that lib folder either. I renamed my lib dirs to lib2 and it installed them just fine, so the issue is clearly with the lib directory.

I’m a little hesitant to enable that option because I inherited this StackStorm instance from an employee who is no longer with the company, and this instance is used by a ton of automation processes, so I don’t want to break anything. However, I did a test by installing a pack from the StackStorm exchange that includes lib dirs in actions and sensors, and they installed perfectly. This is really perplexing.

Figured it out, this was a classic PEBKAC error. My .gitignore had an entry for lib/… When I did my initial Git commit I was lazy and just did a git commit -A and didn’t even notice my lib dir wasn’t included.

I removed the lib/ entry from .gitignore and the pack installed perfectly.