bashdockerenvironment-variableslando

Lando: exec error with environment variables


I'm using Lando (v3.0.0-rc.21 on Windows 10 Enterprise) and trying to set up an environment variable on container creation in my .lando.yml:

services:
  appserver:
    type: ruby # the same for php, but didn't tested other types
  run:
    - export SOMENAME=somevalue

tooling:
  test:
    cmd: export SOMENAME=somevalue
    service: appserver

It looks like the command is not recognized while Lando starts since it throws: OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: \"export\": executable file not found in $PATH": unknown

The very same error occurs on lando ssh -c "export SOMENAME=somevalue" or adding it as a command into tooling section in .lando.yml (see above) and then running lando test.

However, running the same command from lando ssh after lando has started works as it should:

lando ssh
www-data@81bd623b9c3a:/app$ export SOMENAME=somevalue
www-data@81bd623b9c3a:/app$ printenv SOMENAME
somevalue
www-data@81bd623b9c3a:/app$

Is this a Lando bug? Or some (which?) shell commands should be called somehow different?


Solution

  • you may use this env_file in lando yaml:

    env_file:
      - defaults.env
    

    in defaults.env:

    SOMENAME=somevalue
    

    see this