Snap app debug with snap env variables

Setup: RPi3 running Ubuntu Core 16, ssh in from macair

I am currently debugging a simple apps bash script that uses snap environment variables. I guess to debug the script, the snap needs to be created and installed. Otherwise, the variables don’t exists.

My debug cycle is:

  1. modify the script
  2. snapcraft clean scripts -s pull
  3. snapcraft OR snapcraft prime
  4. snap remove (previous install)
  5. sudo snap install OR sudo snap try --devmode prime
  6. snap run…
  7. repeat until clean

Is this how it’s done? Or is there a faster way?

1 Like

I guess this isn’t a good question…But I believe the answer is:
yes, this is how it is done and
no, there is not a faster way.

You could do this by running up-to and including the prime step and then separately run the pack prime step after modifying the script in your prime/ directory:

snapcraft
sudo snap install my-app.snap --dangerous
snap run my-app # realise it's broken
vi script.sh
cp script.sh prime/path/to/script.sh # put the script in the prime/ directory
snapcraft pack prime
sudo snap install my-app.snap --dangerous
snap run my-app # it's fixed?

@lucyllewy . Cool! Thanks for this. I’ll give it a try.