Skip to content

/lib64/libc.so.6: version `GLIBC_2.18' not found #17

Description

@Dgame

I'm building the lambda on Ubuntu with the basic example you've provided in the README.
It builds without any errors but if I upload and test it on aws in crashes with:

{
  "errorType": "Runtime.ExitError",
  "errorMessage": "RequestId: c24d34ab-f4a9-11e8-a9b7-d5cbfb363674 Error: Runtime exited with error: exit status 1"
}

The log output is:

START RequestId: c24d34ab-f4a9-11e8-a9b7-d5cbfb363674 Version: $LATEST
/var/task/bootstrap: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /var/task/bootstrap)
END RequestId: c24d34ab-f4a9-11e8-a9b7-d5cbfb363674
REPORT RequestId: c24d34ab-f4a9-11e8-a9b7-d5cbfb363674	Duration: 61.35 ms	Billed Duration: 100 ms 	Memory Size: 128 MB	Max Memory Used: 12 MB	
RequestId: c24d34ab-f4a9-11e8-a9b7-d5cbfb363674 Error: Runtime exited with error: exit status 1
Runtime.ExitError

Activity

davidbarsky commented on Nov 30, 2018

@davidbarsky
Contributor

Oh man, I'm not sure, and I don't have an Ubuntu instance handy. Can you try building this using musl-libc instead of GNU libc? This would entail adding the x86_64-unknown-linux-musl target using rustup.

sapessi commented on Dec 1, 2018

@sapessi
Contributor

@Dgame I would probably use a docker image to build in local. AWS Lambda uses Amazon Linux 2017.03.1. We are working to add Rust support to SAM build.

drogus commented on Dec 2, 2018

@drogus

I get the same error when compiling on Arch Linux. And it seems that using amazonlinux doesn't help, building with a docker image yields the same result. Here's a Dockerfile that I used: https://gist.github.com/drogus/e16260baa0210a30922a3808a9eed8ff

After building it I just ran the command from the README:

cargo build -p lambda_runtime --example basic --release 

drogus commented on Dec 2, 2018

@drogus

That said, building with musl works correctly (on Arch I installed the musl package and added a x86_64-unknown-linux-musl target)

sapessi commented on Dec 3, 2018

@sapessi
Contributor

Mh, I was able to cargo build successfully and run the basic example with this Dockerfile:

FROM amazonlinux:2017.03.1.20170812
RUN curl https://sh.rustup.rs -sSf | /bin/sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup install stable
RUN yum install -y gcc gcc-c++ make openssl openssl-devel
RUN mkdir /code
WORKDIR /code

I will try to replicate with Nightly next, not sure what's causing your issue yet.

Dgame commented on Dec 3, 2018

@Dgame
Author

@Dgame I would probably use a docker image to build in local. AWS Lambda uses Amazon Linux 2017.03.1. We are working to add Rust support to SAM build.

Well, we are already doing that, but there was the slight hope that building it locally would be faster.

Oh man, I'm not sure, and I don't have an Ubuntu instance handy. Can you try building this using musl-libc instead of GNU libc? This would entail adding the x86_64-unknown-linux-musl target using rustup.

I've tried but I get this:

rustup install stable-musl
info: syncing channel updates for 'stable-x86_64-unknown-linux-musl'
info: latest update on 2018-11-08, rust version 1.30.1 (1433507eb 2018-11-07)
error: target not found: 'x86_64-unknown-linux-musl'

Dgame commented on Dec 3, 2018

@Dgame
Author

I've tried

cargo build --release --target=x86_64-unknown-linux-musl

but then I get those strange OpenSSL errors which I don't get if I drop --target=x86_64-unknown-linux-musl:

Compiling openssl-sys v0.9.39
error: failed to run custom build command for openssl-sys v0.9.39
process didn't exit successfully: /mnt/lambda/target/release/build/openssl-sys-a16ee2b07ae0e6c5/build-script-main (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR
cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR
cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR
cargo:rerun-if-env-changed=OPENSSL_DIR
run pkg_config fail: "Cross compilation detected. Use PKG_CONFIG_ALLOW_CROSS=1 to override"

--- stderr
thread 'main' panicked at '

Could not find directory of OpenSSL installation, and this -sys crate cannot
proceed without this knowledge. If OpenSSL is installed and this crate had
trouble finding it, you can set the OPENSSL_DIR environment variable for the
compilation process.

Make sure you also have the development packages of openssl installed.
For example, libssl-dev on Ubuntu or openssl-devel on Fedora.

If you're in a situation where you think the directory should be found
automatically, please open a bug at https://github.com/sfackler/rust-openssl
and include information about your system as well as this message.

$HOST = x86_64-unknown-linux-gnu
$TARGET = x86_64-unknown-linux-musl
openssl-sys = 0.9.39

', /home/dgame/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.39/build/main.rs:269:9
note: Run with RUST_BACKTRACE=1 for a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed

Any ideas?

sapessi commented on Dec 3, 2018

@sapessi
Contributor

@Dgame Are you compiling on a Mac or in a container? In a Mac, you get these errors because the version of OpenSSL and source you need are not available or the compiler/linker cannot find them. There's a pretty good explanation on StackOverflow here. I would recommend using a docker container for building with the Dockerfile from my previous answer.

drogus commented on Dec 3, 2018

@drogus

@Dgame I'm on ARCH so I'm not sure if it helps you in any way, but I had to specify openssl paths and allow cross compilation:

OPENSSL_LIB_DIR=/usr/lib/openssl-1.0
OPENSSL_INCLUDE_DIR=/usr/include/openssl-1.0
PKG_CONFIG_ALLOW_CROSS=1

Dgame commented on Dec 4, 2018

@Dgame
Author

@sapessi
I'm using Ubuntu 18.04 and only get those pesky ssl errors if I append --target=x86_64-unknown-linux-musl. Without it, it compiles fine but will crash with the error message you can see in my initial post.

@drogus
Thanks, I'll try that next. :)

sapessi commented on Dec 4, 2018

@sapessi
Contributor

On thing I should have added @Dgame, is that if you use the Amazon Linux Docker container to build then you don't have to specify a --target option in the build command.

dbcfd commented on Dec 5, 2018

@dbcfd

Until some of the command line tools finish, you may want to use the docker and cargo_config from https://github.com/srijs/rust-aws-lambda/tree/master/docker

More information on setting up environment here: https://github.com/srijs/rust-aws-lambda/blob/master/docs/getting-started.md#Deploy

marcomagdy commented on Dec 5, 2018

@marcomagdy

@Dgame you could also try using the C++ runtime. It deals with this issue seamlessly ;) you can build on Ubuntu, ArchLinux, Alpine, etc.

Dgame commented on Dec 6, 2018

@Dgame
Author

@marcomagdy No, thanks. ;) I've already written the code in rust. It's just about the build time. With Docker it takes ~15 min, without <4min.

cedws commented on Dec 7, 2018

@cedws

This is quite painful. I've spent a good few hours trying to get all of the required musl tools and musl Rust target to compile, and now I'm having issues getting openssl-sys to compile on musl. I'd rather not build inside Docker if possible.
@sapessi You mentioned SAM build - will that resolve these difficulties? Thanks.

7 remaining items

konstantinvlasenko commented on Jan 23, 2020

@konstantinvlasenko

Hi everyone,

Having the same issue.

  • My build environment is AWS EC2 instance (Amazon Linux 2 AMI 2.0.20190313 x86_64 HVM ebs).

  • Lambda fails (after successful deployment) with the same error /var/task/bootstrap: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /var/task/bootstrap)

davidbarsky commented on Jan 23, 2020

@davidbarsky
Contributor

I think the takeaway of this issue is that this project has to built against musl, as the glibc on the Lambda sandbox is too old for Rust.

konstantinvlasenko commented on Jan 23, 2020

@konstantinvlasenko

@davidbarsky sorry for my ignorance. What your statement "has to built against musl" means? Can I achieve that by using Ubuntu, Debian or Amazon Linux by installing the special packages? Or/And I need to change some configuration of a system or a project?

Thank you.

davidbarsky commented on Jan 23, 2020

@davidbarsky
Contributor

@konstantinvlasenko Sorry, that's my bad! Nothing to apologize for: I was curt in my previous message. You'll need to build against the x86_64-unknown-linux-musl target, which statically links against the musl-libc. You can install musl-libc on Ubuntu/Debian/Amazon Linux; some of the instructions on https://wiki.debian.org/musl#Installation cover that. You'll also need to add the x86_64-unknown-linux-musl target via Rustup: https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/musl-support-for-fully-static-binaries.html.

All that being said, I am primarily a macOS user (with the occasional Amazon Linux usage), so I can't really tell you how to install Musl on a Debian-based system. Personally, I build everything via a Docker image.

davidbarsky commented on Jan 23, 2020

@davidbarsky
Contributor

(I also apologize if I over-explained anything to you!)

konstantinvlasenko commented on Jan 23, 2020

@konstantinvlasenko

Works! Works! Works!
@davidbarsky Thank you very much!

So in my case after following all the steps from here https://aws.amazon.com/blogs/opensource/rust-runtime-for-aws-lambda/ I was missing this one command in my Ubuntu instance:

apt-get install musl

chumaumenze commented on Jun 6, 2020

@chumaumenze

@davidbarsky I am currently facing this issue. I initially tried building with musl but the problem is that some crates rely heavily on C++ libraries. Static linking to the libraries definitely require some extra work (time) as described in rust-lang/rust#36710 (comment).

Is there another way to resolve this?

davidbarsky commented on Jun 6, 2020

@davidbarsky
Contributor

@chumaumenze That makes sense. Trying to build crates with C/C++ dependencies isn't trivial. Unfortunately, there isn't anything that you can do at the moment. To properly resolve this issue, the runtime environment needs to be updated to use Amazon Linux 2, which has a significantly more recent glibc. I'm unable to share a date for when that work will be completed, but I'll let you know when that update has launched.

rimutaka commented on Jun 16, 2020

@rimutaka
Contributor

@softprops , would it be better to replace

Since Lambda uses Amazon Linux, you'll need to target your executable for an x86_64-linux platform.

with

Since Lambda uses Amazon Linux, you'll need to target your executable for x86_64-unknown-linux-musl platform.

in the ReadMe (https://github.com/awslabs/aws-lambda-rust-runtime#aws-cli)?

I managed to get my Lambda going after targeting -musl.

softprops commented on Jun 17, 2020

@softprops
Contributor

That doc is still true but when expanded, you've got options.

For local builds musl seems reliable with the tradeoff I'm warming up to of making sure your os or the one your building on has all of the musl prerequisites manually installed. This varies by os.

This is the approach I'm trying to get sam team to accept aws/aws-lambda-builders#174 (available someday maybe)

And one I'm experimenting with in the serverless framework https://github.com/softprops/serverless-rust/blob/master/README.md#-experimental-local-builds (available today)

The alternative is to build on a container that matches the lambda runtime. The tradeoff here is that assumes docker. Docker is most likely already present on many dev envs but comes with some limitations of what is preinstalled in that docker image https://github.com/softprops/lambda-rust. (available today)

brainstorm commented on Aug 19, 2021

@brainstorm

I'd actually close this issue and direct folks to provided.al2, all the MUSL tooling is not required anymore... unless there's an edge usecase I'm not aware of nowadays?

I'm looking into building a docker container for rust and lambda that can work well with SAM CLI (and Apple Silicon trying to cross-compile ring) in aws/aws-sam-cli#3132 (comment).... so that local builds and sam local start-api works reliably for Rust.

coltonweaver commented on Nov 3, 2021

@coltonweaver
Contributor

Hey, I've added references to provided.al2 in the README now. Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions