environment variable setting issue

Bug #1665756 reported by Brian Murray
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snappy
Fix Released
Undecided
Unassigned

Bug Description

I'm using the new environment variable settings (bug1583259) from snapcraft 2.27 and noticed a couple of surprising things.

My snapcraft.yaml contained the following:

environment:
  APPORT_CRASHDB_CONF: $SNAP/lib/python3.5/site-packages/etc/apport/crashdb.conf

Then running apport-cli produced the following Traceback:

brian-murray@localhost:~$ /snap/bin/apport.apport-cli --help
Traceback (most recent call last):
  File "/snap/apport/x7/bin/apport-cli", line 369, in <module>
    app = CLIUserInterface()
  File "/snap/apport/x7/bin/apport-cli", line 127, in __init__
    apport.ui.UserInterface.__init__(self)
  File "/snap/apport/x7/lib/python3.5/site-packages/apport/ui.py", line 187, in __init__
    self.crashdb = apport.crashdb.get_crashdb(None)
  File "/snap/apport/x7/lib/python3.5/site-packages/apport/crashdb.py", line 822, in get_crashdb
    with open(conf) as f:
FileNotFoundError: [Errno 2] No such file or directory: '$SNAP/lib/python3.5/site-packages/etc/apport/crashdb.conf\n'

Two things about this were surprising to me.

1) The addition of "\n" to the environment variable. On a classic Ubuntu system using 'APPORT_CRASHDB_CONF=$SOMETHING apport-cli --help' doesn't pass along a carriage return.

2) The fact that "$SNAP" wasn't expanded in the environment. Again on a classic Ubuntu system if I use the following 'PLACE=/home/bdmurray APPORT_CRASHDB_CONF=$PLACE/source-trees/apport/trunk/etc/apport/blah apport-cli --help' APPORT_CRASHDB_CONF expands $PLACE so the traceback looks like this:

"FileNotFoundError: [Errno 2] No such file or directory: '/home/bdmurray/source-trees/apport/trunk/etc/apport/blah'"

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

The \n is fixed in master and will be released as 2.23 shortly.

The $SNAP expansion is likely fixed as well. I'll mark this as fix committed.

Changed in snappy:
status: New → Fix Committed
Revision history for this message
Brian Murray (brian-murray) wrote :

I was running 2.27 of snapcraft, is it fixed in 2.23 of something else?

Revision history for this message
Mark Shuttleworth (sabdfl) wrote : Re: [Bug 1665756] Re: environment variable setting issue

Probably snap/snapd. It's a runtime issue aiui not a build-time issue.

Mark

Revision history for this message
Kyle Fazzari (kyrofa) wrote :

> I was running 2.27 of snapcraft, is it fixed in 2.23 of something else?

Indeed, snapd v2.23. The `environment` keyword is a snapd thing; snapcraft just passes it through unmodified.

Revision history for this message
Brian Murray (brian-murray) wrote :

While the $SNAP and $SNAP_DATA variables are now expanded there is something else special going on.

APPORT_REPORT_DIR=/var/snap/apport/x1/crash/crash
APPORT_CRASHDB_CONF=/snap/apport/x1/lib/python3.5/site-packages/etc/apport/crashdb.conf/lib/python3.5/site-packages/etc/apport/crashdb.conf

Notice the doubling of what was in the snapcraft.yaml file.

$SNAP_DATA/crash became /var/snap/apport/x1/crash/crash.

Changed in snappy:
status: Fix Committed → Confirmed
Revision history for this message
Barry Warsaw (barry) wrote :

I think this might be the problem I'm having with ubuntu-image classic snap. It uses the environment key to set $PATH and $PYTHONPATH. It works in Zesty but not Xenial or Yakkety, and that's probably because 2.23 is in Zesty but still sitting in {xenial,yakkety}-proposed.

Revision history for this message
Alberto Mardegan (mardy) wrote :

I'm seeing the same issues in xenial (+ stable phone overlay PPA), where I've snap 2.23 installed.

Revision history for this message
Brian Murray (brian-murray) wrote :

This is fixed for me now (APPORT_CRASHDB_CONF=/snap/apport/x5/lib/python3.5/site-packages/etc/apport/crashdb.conf) with the following versions:

snap 2.24
snapd 2.24

 $ apt-cache policy snapcraft
snapcraft:
  Installed: 2.29+16.10

Changed in snappy:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.