Snap package giving errors when installed from other folders

I generated a snap of my application and installed from a folder and it works fine as below :

but if i move the snap to another folder or other machine and re-install it. I get the below error.

Here it looks for a Hello.py file. and i have placed it in path /home/boschrexroth/pythonfiles. And it gets internally called from my dotnet application. It works fine in the first instance and gives file missing error in the 2nd instance. why is this happening ?

The snapcraft.yaml is as below :

name: processorsnap2
version: '0.1'
summary: A simple example snap for dotnet in snaps
description: A simple example snap for dotnet in snaps

grade: devel 
confinement: strict 

base: core

apps:
  processorsnap2:
    command: IoT_AnalyticsProcessor.Service
    environment:
          PYTHONPATH: $SNAP/lib/x86_64-linux-gnu/:$SNAP/usr/lib/python3.5/:/$SNAP/usr/lib/python3.5/plat-x86_64-linux-gnu/:/$SNAP/lib/referencer/:$PYTHONPATH
          PYTHONHOME: $SNAP/lib/x86_64-linux-gnu/:$SNAP/usr/lib/python3.5/:/$SNAP/usr/lib/python3.5/plat-x86_64-linux-gnu/:/$SNAP/lib/referencer/:$PYTHONHOME

layout:
  /usr/bin/python3.5:
    bind-file: $SNAP/usr/bin/python3.5

parts:
  processorsnap2:
    source: .
    plugin: dump
    stage-packages:
        - libasn1-8-heimdal
        - libcurl3
        - libgssapi3-heimdal
        - libhcrypto4-heimdal
        - libheimbase1-heimdal
        - libheimntlm0-heimdal
        - libhx509-5-heimdal
        - libkrb5-26-heimdal
        - libldap-2.4-2
        - liblttng-ust0
        - libroken18-heimdal
        - librtmp1
        - libsasl2-2
        - libunwind8
        - liburcu4
        - libwind0-heimdal
        - icu-devtools
        - wget
        - zlib1g
        - python3.5
        - python2.7
        - python

Is the application installed on the first machine already when you install it with snap install .snap --devmode?

Both are happening on the same machine.

1st instance : is the folder where all the binaries are present and i create snap. I install it and it works fine. And then i remove the snap.

2nd instance : I move just the snap file to another location and install again and it doesnt work normal anymore. It gives file missing error.

If it’s being installed in devmode then you’re not using confinement, so the contents of the snap can ‘see’ files in your current directory. Perhaps there’s something it’s loading from the current folder which isn’t there in the new folder.

1 Like

Ok thanks for your responses.

In my visual studio code. I give path of the python folder where Hello.py exists. as below :
image

is there anyway that i can add the python file path inside the snap and give the snap directory path inside my visual studio code ?

i tried giving path in visual studio code as $SNAP/PythonFiles , but VS code did not take the path. so how can i add the python file hello.py into the snap and mention its path in VS code. So that when the application is executed it looks for python script within the snap and not in /home directory