classic snap are missing some env variables for reaching command name. (snap build, executing it fails)

Bug #1670388 reported by Didier Roche-Tolomelli
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Snapcraft
Triaged
Low
Sergio Schvezov
snapcraft (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

1. Classic snap, where snapcraft.yaml can be found on lp:~didrocks/+junk/chuck-norris-webserver-classic.
2. Note that it declares and builds ok:
apps:
  node-service:
    command: chuck-norris-app
    daemon: simple
    restart-condition: always
  cli:
    command: chuck-norris-cli
3. Building and installing, executing:
$ chuck-norris-webserver-classic.cli
/snap/chuck-norris-webserver-classic/x2/command-cli.wrapper: 2: exec: chuck-norris-cli: not found

The issue is that indeed, the wrapper don't add $SNAP/bin/ to $PATH:
#!/bin/sh
exec "chuck-norris-cli" "$@"

The non classic version works as it does add it to the path.

Note that specifying "bin/chuck-norris-cli" instead of just "chuck-norris-cli" works in classic and generate something like:
exec "$SNAP/bin/node" "$SNAP/bin/chuck-norris-cli" "$@"

4. Another side effect is that it's not the snap node version which is used in that case. The script declares "#!/usr/bin/env node" resolving to system one.
#!/bin/sh
exec "chuck-norris-cli" "$@"
-> will resolve to the system one, while if specified as bin/chuck-norris-cli:
exec "$SNAP/bin/node" "$SNAP/bin/chuck-norris-cli" "$@"

I would expect in both case to prefer the snap version.

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: snapcraft 2.27.1 [modified: usr/lib/python3/dist-packages/snapcraft/_baseplugin.py usr/lib/python3/dist-packages/snapcraft/plugins/python.py]
ProcVersionSignature: Ubuntu 4.4.0-64.85-generic 4.4.44
Uname: Linux 4.4.0-64-generic x86_64
NonfreeKernelModules: zfs zunicode zcommon znvpair zavl
ApportVersion: 2.20.1-0ubuntu2.5
Architecture: amd64
CurrentDesktop: Unity
Date: Mon Mar 6 16:06:59 2017
InstallationDate: Installed on 2012-05-28 (1743 days ago)
InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Release amd64 (20120425)
PackageArchitecture: all
SourcePackage: snapcraft
UpgradeStatus: Upgraded to xenial on 2014-10-31 (857 days ago)

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :
summary: - classic snap are missing some env variables for reaching command
+ classic snap are missing some env variables for reaching command name.
+ (snap build, executing it fails)
description: updated
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

These are the constraints of a classic snap. The developer of such snap would need to setup environment variables if needed to not accidentally pollute the environment. If execution is the problem, the use the relative path in prime to the command.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

we can make the error message clearer about this though.

Changed in snapcraft:
status: New → Triaged
importance: Undecided → Low
assignee: nobody → Sergio Schvezov (sergiusens)
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

If there is an error message about it (Note that there is none presently, only at runtime), yeah, I guess that's okish.

The issue is that the logic for finding the binary is still the same in snapcraft to validate the prime step. So, it passes. The logic should remove the "look in bin/ and other well-known path" to error out at build time.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in snapcraft (Ubuntu):
status: New → Confirmed
Changed in snapcraft (Ubuntu):
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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