Hooks don't support an `environment` keyword

Currently one can add an app-specific environment like so:

# ...

apps:
  my-app:
    command: foo
    environment:
      FOO: BAR

One can implement a global environment, which will affect apps and hooks:

# ...

environment:
  FOO: BAR

apps:
  my-app:
    command: echo "$FOO"

hooks:
  configure:

However, there is no support for a hook-specific environment. Is there a reason for this, or is it an oversight?

Fixed with this:

I have just tested this out and it seems it does not work. I could not find any documentation about this either.

hooks:
  install:
  environment:
     LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/lib

Issues while validating snapcraft.yaml: The ‘hooks/install’ property does not match the required schema: Additional properties are not allowed (‘environment’ was unexpected)

Until snapcraft gains support you may use either of environment via passthrough, or command-chain:

hooks:
  <hookname>:
    command-chain:
    - ...
    passthrough:
      environment:
        LD_LIBRARY_PATH: ...
1 Like

Thanks. Any plans when this will be fully supported?

This is reported at https://bugs.launchpad.net/snapcraft/+bug/1848381, you could mark yourself affected by the bug, maybe it will get more priority from the snapcraft devs that way

done. and done. and some more done to pass the minimum required characters :wink:

1 Like