Where are native binaries put when deployed?

Hi all I’m deploying a Python lambda function with a native dependency (ffmpeg)

I’m getting this error:

[ERROR] FileNotFoundError: [Errno 2] No such file or directory: 'ffprobe': 'ffprobe'

I have this demo in Node which works fine.

This is the relevant snippet of serverless.yml file for the example. Beautifully simple:

    handler: handler.mkgif
      - s3: ${self:custom.bucket}
      - {Ref: FfmpegLambdaLayer}

    path: layer

And this is mine:

        # Ref name is generated by TitleCasing the layer name & appending LambdaLayer
      - {Ref: AudioLambdaLayer}

    path: dependencies

This produces in both cases, inside .serverless/ the zip file named ffmpeg.zip in the demo case and audio.zip in my case, as you’d expect, and both contain what you’d expect inside.

Layers are set up properly in AWS, they look good.

But in my case, ffmpeg is nowhere to be found, whereas the demo, ffmpeg turns up inside /opt/ffmpeg/ffmpeg

I’d have expected mine to turn up either (a) in one of the directories in the PATH, or (b) /opt/audio/ffmpeg

Buuut it’s not. In fact, /opt appears to be blank: I get its contents via os.popen(f"ls -Rl /opt")

I’m also using serverless-python-requirements too to copy over the other dependencies. I’m hoping that’s not interfering with the other bits and pieces, but maybe it is. I can just see the antipattern: external script crashes, taking down the whole pipeline, causing other elements of the pipeline to fail.

I’m pretty stuck. The next step will be to port the example to python and maybe I’ll find something. Or try to manually build the dependencies rather than use the serverless-python-requirements?

Any guidance most appreciated.

1 Like

I’m having the exact same issue. running ls showed that the opt directory is truly empty.

Did you ever solve this?

@danieloi sorry for the late reply. I hope you got unblocked in the end. I’ve sinced moved on and don’t need this any more but this may be useful for future people:

The binaries are stored stored in /opt, in locations that are language-specific. Here are my notes:

had to manually set the path to include the location it appeared to land in (/opt). Unclear why the binaries had to be in a folder inside /opt but that’s the only way it seemed to work. This is how you do that: process.env['PATH'] = process.env['PATH'] + ':' + process.env['LAMBDA_TASK_ROOT'] at the beginning of your lambda function that calls the methods

Had to manually copy the binaries:

pip install --target ../dependencies/python -r requirements.txt