"snapcraft --destructive-mode" ends with "Failed to run 'override-pull': Exit code was 2."

I’m a new snapcraft user as a new snap developer, working on a private tutorial content. Please feel free to move to an appropriate forum.

I’m given this totorial with the expected result,

$ snapcraft --destructive-mode 
Pulling my-part  
Building my-part  
Staging my-part  
Priming my-part  
Snapping 'my-snap-name' | 
Snapped my-snap-name_0.1_amd64.snap

but I get the following. How can I get the same result as above?

$ snapcraft --destructive-mode --debug
Pulling my-part 
/bin/sh: 2: export: -: bad variable name
Failed to run 'override-pull': Exit code was 2.
$ tree -L 4
.
??? parts
??? ??? my-part
???     ??? build
???     ??? install
???     ??? src
???     ??? state
??? prime
??? snap
??? ??? snapcraft.yaml
??? stage

9 directories, 1 file

$ more snap/snapcraft.yaml 
name: my-snap-name
base: core18
version: '0.1'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel
confinement: devmode

parts:
  my-part:
    # See 'snapcraft plugins'
    plugin: nil

$ snapcraft --version
snapcraft, version 4.2
$ uname -a
Linux 130s-kudu1 5.4.0-47-generic #51~18.04.1-Ubuntu SMP Sat Sep 5 14:35:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
$

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.5 LTS
Release:        18.04
Codename:       bionic

$ which snapcraft
/snap/bin/snapcraft
$ snap --version
snap    2.46.1
snapd   2.46.1
series  16
ubuntu  18.04
kernel  5.4.0-47-generic
$ snapcraft --version
snapcraft, version 4.2

I get the same error for another source. So I’m leaning toward believing that the root cause is not in source that snapcraft tries to build, but somewhere else.

$ snapcraft --destructive-mode
Pulling adaemon 
/bin/sh: 2: export: -: bad variable name
Failed to run 'override-pull': Exit code was 2.

$ more snap/snapcraft.yaml
name: test-apps
base: core18
version: '0.1'
summary: Snapcraft demo for apps
description: |
  Simple snap to exercise snapcraft apps

grade: stable
confinement: strict

apps:
  test-apps:
    command: test-apps.sh
  hello:
    command: hello.sh
  adaemon:
    command: adaemon.sh
    daemon: simple

parts:
  test-apps:
    source: test-apps
    plugin: dump
  hello:
    source: hello
    plugin: dump
  adaemon:
    source: adaemon
    plugin: dump

$ tree -L 2
.
??? adaemon
??? ??? adaemon.sh
??? hello
??? ??? hello.sh
??? snap
??? ??? snapcraft.yaml
??? test-apps
    ??? test-apps.sh

4 directories, 4 files

I wonder if something in your environment is breaking snapcraft. Can you try:
env -i - PATH=/snap/bin:/usr/bin:/bin:/sbin:/usr/local/bin USER=$USER /snap/bin/snapcraft --enable-developer-debug --destructive-mode

Thanks. I ran the command at the directory where the following file exists in snap folder,

name: my-snap-name # you probably want to 'snapcraft register <name>'
base: core18 # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: Single-line elevator pitch for your amazing snap # 79 char long summary
description: |
  This is my-snap's description. You have a paragraph or two to tell the
  most important story about your snap. Keep it under 100 words though,
  we live in tweetspace and your description wants to look good in the snap
  store.

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

# parts:
#   my-part:
#     # See 'snapcraft plugins'
#     plugin: nil

parts:
  gnu-hello:
    source: http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz
    plugin: autotools

Then I got the following (seems like a lot of web access and installation):

$ env -i - PATH=/snap/bin:/usr/bin:/bin:/sbin:/usr/local/bin USER=$USER /snap/bin/snapcraft --enable-developer-debug --destructive-
mode                                                        
Locale not set! Snapcraft will temporarily use C.UTF-8                                  
Starting snapcraft 4.3 from /snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/cli.
configure_requests_ca: using '/etc/ssl/certs/ca-certificates.crt' for certificate verification
snapcraft is running in a docker or podman (OCI) container                                                                                                                                                         Parts dir /home/nfoouser/data/Dropbox/pg/myDevelopment/git_repo/foouser/snappy_hello/snap/parts
Stage dir /home/foouser/git_repo/foouser/snappy_hello/snap/stage
Prime dir /home/foouser/git_repo/foouser/snappy_hello/snap/prime                                                                                                                          ignoring or passing through unknown parts=OrderedDict([('gnu-hello', OrderedDict([('source', 'http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz'), ('plugin', 'autotools')]))])
Parts dir /home/foouser/git_repo/foouser/snappy_hello/snap/parts
:
ignoring or passing through unknown parts=OrderedDict([('gnu-hello', OrderedDict([('source', 'http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz'), ('plugin', 'autotools')]))])
ignoring or passing through unknown parts={'gnu-hello': {'source': 'http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz', 'plugin': 'autotools', 'stage': [], 'prime': []}}
Loading plugin module 'autotools' with sys.path ['/home/foouser/git_repo/foouser/snappy_hello/snap/snap/plugins', '/snap/snapcraft/5472/bin', '/snap/snapcraft/5472/usr/lib/python36.zip',
 '/snap/snapcraft/5472/usr/lib/python3.6', '/snap/snapcraft/5472/usr/lib/python3.6/lib-dynload', '/snap/snapcraft/5472/usr/lib/python3/dist-packages', '/snap/snapcraft/5472/lib/python3.6/site-packages']
Setting up part 'gnu-hello' with plugin 'autotools' and properties {'source': 'http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz', 'plugin': 'autotools', 'stage': [], 'prime': []}.
Requested build-packages: ['autoconf', 'automake', 'autopoint', 'libtool', 'make']
Executing: ['sudo', '--preserve-env', 'apt-get', 'update']
[sudo] password for nfoouser:                   
Hit:1 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Ign:2 http://linux.dropbox.com/ubuntu bionic InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
Get:4 http://linux.dropbox.com/ubuntu bionic Release [6600 B]
Hit:5 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:6 https://typora.io/linux ./ InRelease    
Hit:7 http://linux.teamviewer.com/deb stable InRelease
Ign:8 http://dl.google.com/linux/chrome-remote-desktop/deb stable InRelease
Hit:9 http://packages.ros.org/ros/ubuntu bionic InRelease
Hit:10 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:11 http://dl.google.com/linux/chrome-remote-desktop/deb stable Release
Hit:12 http://build.openvpn.net/debian/openvpn/stable bionic InRelease
Hit:13 http://ppa.launchpad.net/ansible/ansible/ubuntu bionic InRelease
Hit:14 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:15 https://packages.microsoft.com/repos/ms-teams stable InRelease
Hit:17 http://ppa.launchpad.net/peek-developers/stable/ubuntu bionic InRelease
Hit:18 http://ppa.launchpad.net/system76-dev/stable/ubuntu bionic InRelease
Err:12 http://build.openvpn.net/debian/openvpn/stable bionic InRelease
  The following signatures were invalid: EXPKEYSIG 8E6DA8B4E158C569 Samuli Seppänen (OpenVPN Technologies, Inc) <samuli@openvpn.net>
Fetched 6600 B in 2s (4059 B/s)  
Reading package lists... Done                                              
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://build.openvpn.net/debian/openvpn/stable bionic InRelease: The fo
llowing signatures were invalid: EXPKEYSIG 8E6DA8B4E158C569 Samuli Seppänen (OpenVPN Technologies, Inc) <samuli@openvpn.net>
W: Failed to fetch http://build.openvpn.net/debian/openvpn/stable/dists/bionic/InRelease  The following signatures were invalid: EXPKEYSIG 8E6DA8B4E158C569 Samuli Seppänen (OpenVPN Technologies, Inc) <samuli@ope
nvpn.net>                                 
W: Some index files failed to download. They have been ignored, or old ones used instead.
Marking 'make' (and its dependencies) to be fetched                                                                                                                                
package: <Package: name:'make' architecture='amd64' id:458>                                                                                                                                                        
Marking 'libtool' (and its dependencies) to be fetched
package: <Package: name:'libtool' architecture='amd64' id:368>                                                                                                                                                     
Marking 'autoconf' (and its dependencies) to be fetched
package: <Package: name:'autoconf' architecture='amd64' id:359>
Marking 'automake' (and its dependencies) to be fetched                                    
package: <Package: name:'automake' architecture='amd64' id:363>                               
Marking 'autopoint' (and its dependencies) to be fetched  
package: <Package: name:'autopoint' architecture='amd64' id:389>                         
Installing build dependencies: autoconf automake autopoint m4                            
Reading package lists... Done                                                            

Because I wasn’t sure this result is helpful, I went back to the folder I used when I originally reported, then got this.

$ env -i - PATH=/snap/bin:/usr/bin:/bin:/sbin:/usr/local/bin USER=$USER /snap/bin/snapcraft --enable-developer-debug --destructive-mode
Locale not set! Snapcraft will temporarily use C.UTF-8
Starting snapcraft 4.3 from /snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/cli.
configure_requests_ca: using '/etc/ssl/certs/ca-certificates.crt' for certificate verification
snapcraft is running in a docker or podman (OCI) container
Parts dir /home/nfoouser/lab1/create-snap/parts
Stage dir /home/nfoouser/lab1/create-snap/stage
Prime dir /home/nfoouser/lab1/create-snap/prime
ignoring or passing through unknown parts=OrderedDict([('my-part', OrderedDict([('plugin', 'nil')]))])
snapcraft is running as a snap True, SNAP_NAME set to 'snapcraft'
Running legacy snapcraft with: ['/snap/snapcraft/5472/legacy_snapcraft/usr/bin/python3', '/snap/snapcraft/5472/legacy_snapcraft/bin/snapcraft', '--enable-developer-debug', '--destructive-mode']
Error: no such option: --enable-developer-debug
nfoouser@foouser-kudu1:~/lab1/create-snap$ 

Unfortunately I ran out of time with this Ubuntu setting with other issues prenset as well, so I’m about to cleanly re-install Ubuntu so that I won’t likely get to work on this issue unless it re-appears. Feel free to close.

Might want to double check that lab1/create-snap has 'base: core18` in it. It’s invoking legacy snapcraft which is used for snaps prior to bases (that is, no base is specified).