I’m trying to run a Python module in a classic snap, and I’m running into a similar issue to the one encountered here:
That is, I get the following error:
$ dotrun --help
Traceback (most recent call last):
File "/snap/dotrun/x6/bin/dotrun", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3252, in <module>
@_call_aside
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3236, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3265, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 584, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 901, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 787, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'canonicalwebteam.dotrun==0.0.0' distribution was not found and is required by the application
Presumably because the snap is using the host’s python3
binary, where I have installed my package into the snap’s python3
binary.
I tried overriding this with:
environment:
PATH: $SNAP/bin:$SNAP/usr/bin:$SNAP/usr/local/bin:$PATH
But I still get the above error, even though if I actually shell into the snap I get the expected path and python3 binary, and the dotrun
binary works:
robin@rt480:~/Projects/dotrun (python) $ which dotrun
/snap/bin/dotrun
robin@rt480:~/Projects/dotrun (python) $ dotrun --help
Traceback (most recent call last):
File "/snap/dotrun/x6/bin/dotrun", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3252, in <module>
@_call_aside
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3236, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 3265, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 584, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 901, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 787, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'canonicalwebteam.dotrun==0.0.0' distribution was not found and is required by the application
robin@rt480:~/Projects/dotrun (python) $ snap run --shell dotrun
robin@rt480:~/Projects/dotrun (python) $ echo $PATH
/snap/dotrun/x6/bin:/snap/dotrun/x6/usr/bin:/snap/dotrun/x6/usr/local/bin:/home/robin/.poetry/bin:/home/robin/.local/bin:/home/robin/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/robin/.cargo/bin:/home/robin/.cargo/bin:/home/robin/.cargo/bin
robin@rt480:~/Projects/dotrun (python) $ which dotrun
/snap/dotrun/x6/bin/dotrun
robin@rt480:~/Projects/dotrun (python) $ dotrun --help
usage: dotrun [-h] [-C DIRECTORY] [-s] [-e ENV] [command]
Containerized project-level dependency management and package.json commands
positional arguments:
command A package.json command to run with `yarn run XXX` inside dotrun.
Simply typing `dotrun` will run `yarn run start`.
Or a special command - one of:
- version: Print the version
- exec [command]: Execute a command or open a bash shell within the dotrun context
- install: Reinstall node and python dependencies
- clean: Run `yarn run clean` and remove all dotrun files
(default: start)
optional arguments:
-h, --help show this help message and exit
-C DIRECTORY, --directory DIRECTORY
The directory in which to run commands (default: current directory)
-s, --skip-install Don't check for python or node dependencies before running (default: False)
-e ENV, --env ENV Environment variables to use when running commands.
These will override what's in .env or .env.local
What have I done wrong? How can I change the $PATH
for my dotrun
command?