'snap install' return code unhelpful

Bug #1622782 reported by Jacek Nykis
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Snap Layer
Fix Released
Critical
Stuart Bishop
Snappy
Fix Released
Undecided
Unassigned
snapd (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

'snap install <name>' exits with return code 1 if the snap is already installed and prints error message:
error: cannot install "<name>": snap "<name>" already installed

It would make scripting much easier if it worked in the same way as apt-get which is to return 0 when there is nothing to do with info message, something like:
"snap <name> already installed"

snap 2.14.2~16.04
snapd 2.14.2~16.04
series 16
ubuntu 16.04

Tags: canonical-is
Jacek Nykis (jacekn)
tags: added: canonical-is
Changed in snapd (Ubuntu):
status: New → Triaged
Revision history for this message
Stuart Bishop (stub) wrote :

Snap layer for juju needs to work around this bug to make the install helper idempotent.

Changed in layer-snap:
status: New → In Progress
importance: Undecided → Critical
Stuart Bishop (stub)
Changed in layer-snap:
status: In Progress → Fix Released
assignee: nobody → Stuart Bishop (stub)
Stuart Bishop (stub)
Changed in layer-snap:
status: Fix Released → Confirmed
Revision history for this message
Michael Vogt (mvo) wrote :
Changed in snapd (Ubuntu):
status: Triaged → In Progress
Revision history for this message
Jacek Nykis (jacekn) wrote :

One important note - exit code 1 is still error so your PR:
https://github.com/snapcore/snapd/pull/2292

does not address root cause.

It will allow for another way to detect "snap already installed" failure (using exit code rather than string) but calls like this will still cause traceback:
subprocess.check_call(["snap", "insatll", "snapname"])

Stuart Bishop (stub)
Changed in layer-snap:
status: Confirmed → Fix Released
Michael Vogt (mvo)
Changed in snappy:
status: New → Fix Released
Changed in snapd (Ubuntu):
status: In Progress → Fix Committed
Changed in snappy:
status: Fix Released → Fix Committed
Michael Vogt (mvo)
Changed in snapd (Ubuntu):
status: Fix Committed → Fix Released
Changed in snappy:
status: Fix Committed → 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.