Unable to use `build-environment`

Hello,

I am trying to use build-environment in one of the parts to set PIP flags as below.

parts:
  my_part:
    build-environment:
      - PIP_NO_BINARY: numpy,pandas
    plugin: python

when trying to the build the snap with above changes in my snapcraft.yaml, I am encountering the below error.
Failed to load plugin: properties failed to load for mysnap: Additional properties are not allowed ('build-environment' was unexpected)

What am I doing wrong here ?

I am running snapcraft version 2.42.1 on Ubuntu 16.04.

You’re using a very old version of snapcraft. I would recommend apt remove snapcraft and snap install snapcraft.

Thanks, I did followed your instruction and installed snapcraft with --classic flag and now when I run snapcraft I end up with -bash: /usr/bin/snapcraft: No such file or directory error. If I use sudo snapcraft I still am getting the same error 'build-environment' was unexpected .

My current snapcraft version is 3.4.1

$ sudo snapcraft --version
snapcraft, version 3.4.1

$ sudo snapcraft
Failed to load plugin: properties failed to load for mysnap: Additional properties are not allowed ('build-environment' was unexpected)

The reason for the No such file or directory error is because your shell is still remembering the old path to /usr/bin/snapcraft which came from the deb, rather than the new path /snap/bin/snapcraft from the snap.

Simply close the shell and start a new one or launch bash to get the path updated. Don’t run snapcraft as sudo.

Thanks but No luck building, snapcraft is unable to resolve build-environment property. I am trying to build a python part . Is there a restriction that certain plugins don’t support this property yet ?

Can you share the full yaml please? So we can further debug?

Can you make sure you set base to either core or core18 depending on which base you want to use as the base of your snap?

Here is the snippet from snapcraft.yml (Note base: core18 was added based on the comment by @sergiusens )

name: mysnap
version: 1.4.11py3
adopt-info: mypart
base: core18
environment:
  LANG: C.UTF-8
  LC_ALL: C.UTF-8

parts:
  mysnap:
    build-environment:
      - PIP_NO_BINARY: numpy,pandas
   parse-info: [setup.py]
    plugin: python
    source: mysnap
    requirements: requirements.txt
    build-packages:
      - libxslt1-dev
      - libxml2-dev
    stage:
      - -tests
    override-prime: |
      snapcraftctl prime

I rebooted my machine and ran snapcraft and agreed to install multipass as per the message on the console. But now my snapcraft command fails with a new error.

$ snapcraft
Using 'snap/snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
Launching a VM.
start failed: timed out waiting for instance to respond
An error occurred with the instance when trying to start with 'multipass': returned exit code 2.
Ensure that 'multipass' is setup correctly and try again.

Tried restarting mulitpass with sudo snap restart multipass and the logs shows this message

2019-05-22T04:46:53Z multipassd[12187]: dnsmasq: failed to create listening socket for 10.124.155.1: Address already in use

Changing the base to core , I am now struck at Starting snapcraft-mysnap

$ snapcraft
Using 'snap/snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
Launching a VM.
Project base changed from None to 'core', cleaning build instance.
Starting snapcraft-mysnap /
launch failed: timed out waiting for instance to respond
Stopping snapcraft-mysnap |
An error occurred with the instance when trying to launch with 'multipass': returned exit code 2.
Ensure that 'multipass' is setup correctly and try again.

I wish it was as simpler as before!! All this because I was lazy enough to run a wrapper script which would set the environment variables and then run snapcraft command to build the snap :stuck_out_tongue:

@dhoomakethu the dnsmasq error means that something’s jumping on our bridge interface. Do you have named running or some other DNS or DHCP server on that machine?

Nope, no DNS/DHCP server running.

Are you sure?

What’s the output of this?

$ sudo netstat -ap | grep LISTEN | grep -e :domain -e :dhcp
…
tcp        0      0 hostname:domain    0.0.0.0:*               LISTEN      32283/dnsmasq

The number before the / is the PID of the process, you can then check what process that is.

Here is the output. I am not sure what the process named is for and what it does.

tcp        0      0 10.124.155.1:domain     *:*                     LISTEN      1505/named
tcp        0      0 192.168.122.1:domain    *:*                     LISTEN      1505/named
tcp        0      0 172.17.0.1:domain       *:*                     LISTEN      1505/named
tcp        0      0 192.168.128.63:domain   *:*                     LISTEN      1505/named
tcp        0      0 localhost:domain        *:*                     LISTEN      1505/named
tcp6       0      0 [::]:domain             [::]:*                  LISTEN      1505/named
snapman@snapman:~$ ps -aef | grep 1505
bind      1505     1  0 May22 ?        00:00:00 /usr/sbin/named -f -u bind

That’s bind, most often used as an authoritative name server, i.e. if you have your own domains, it serves details of those.

If it’s your machine, it’s very unlikely that you need it.

If in doubt, you can reconfigure it to only listen on addresses that make sense.