I've been working on this issue for the past 3 months and am completely stuck.
I am trying to package up my NodeJS AWS Lambda function that will use SoX and it's dependencies to convert audio files to MP3. I can get my code to recognize the custom location of the SoX binary by following instructions referenced here, and here. I ended up adding this code to the start of my Lambda function call to update the process.env PATH variable to include the path to the custom binary.
process.env['PATH'] = process.env['PATH'] + ':'
+ path.join(process.env['LAMBDA_TASK_ROOT'], 'binaries');
This results in my process.env PATH updating to look like this:
/usr/local/lib64/node-v4.3.x/bin:/usr/local/bin:/usr/bin/:/bin:/var/task/binaries
Which looks correct, binaries
is the directory that contains the sox binary I compiled.
Since I'm using NodeJS, I had to modify the sox-audio NPM module so it used the updated process.env variable for the child_process exec and spawn calls. This allows the code to find the binary, but I'm still getting an error during execution.
Sox process exited with code 127 and signal null
I understand that although it can find the SoX binary I included, it is not able to find a command used with SoX, but without more information I can't tell what it is. I was thinking it was because I am not sure if I have all the files included for the binary to work.
In an attempt to make a clean compiled build of SoX with MP3 support, I created a fresh EC2 linux instance and then followed the instructions provided here.
I went line by line to ensure I could get it working, and after installing a few dependencies to enable compiling (such as developer tools), and by exporting the build PATH with export PATH=$PATH:/usr/local/bin
I was able to get a full build installed with MP3 support. I tested it and it works exactly like how I need it.
Since AWS Lambda Functions run on the same stripped down version of Linux (Amazon Linux AMI) as AWS EC2 instances, theoretically, if I could export the SoX build and include it in my Lambda Package, then I should be able to get it to work.
That is where I am having trouble. What makes up the built itself? There is a SoX linux executable in /usr/local/bin
which is a single file, but there are also a ton more files there that seem all related to making SoX and its dependencies work. Here is a list of files within /usr/local/bin
on the working build I have.
I attempted to export all these files via FTP and then import them into another clean EC2 instance, but even after running export PATH=$PATH:/usr/local/bin
SoX would fail to run because of a dependency issue. It is clear that just exporting these files is not enough.
- How do I export and what do I export to take my working build of SoX with MP3 support off the EC2 instance and include it to work within my AWS Lambda Function?
- Is the long list of installed dependencies to get MP3 to work going to make this impossible?
- Are there files in more than just the
/usr/local/bin
directory that I need to include?
I really don't know where else to go with this. Please help :(