softprops / serverless-rust

⚡ 🦀 a serverless framework plugin for rustlang applications
https://www.npmjs.com/package/serverless-rust
MIT License
541 stars 81 forks source link

MacOs dockerless: fork/exec /var/task/bootstrap: permission denied #102

Closed marijnhurkens closed 2 years ago

marijnhurkens commented 2 years ago

🐛 Bug description

On MacOs using the dockerless function I get a permission denied error:

{"errorType":"exitError","errorMessage":"RequestId: 8ed9feed-c1a2-1705-f60b-4ca1d6303f50 Error: fork/exec /var/task/bootstrap: permission denied"}

 Serverless Error ----------------------------------------

  ServerlessError: Failed to run docker for rust image (exit code 1})
      at AwsInvokeLocal.invokeLocalDocker (/Users/marijn/qikker/test-serverless-rust/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:539:13)
      at async PluginManager.invoke (/Users/marijn/qikker/test-serverless-rust/node_modules/serverless/lib/classes/PluginManager.js:576:9)
      at async PluginManager.run (/Users/marijn/qikker/test-serverless-rust/node_modules/serverless/lib/classes/PluginManager.js:634:7)
      at async Serverless.run (/Users/marijn/qikker/test-serverless-rust/node_modules/serverless/lib/Serverless.js:441:5)
      at async /snapshot/serverless/scripts/serverless.js:725:9

I'm using the master branch of this plugin because this should be solved in https://github.com/softprops/serverless-rust/issues/93

Cargo.toml

[package]
name = "test-serverless-rust"
version = "0.1.0"
edition = "2018"

[dependencies]
tokio = { version = "1.0", features = ["macros", "io-util", "sync", "rt-multi-thread"] }
serde = { version = "1", features = ["derive"] }
serde_json = "^1"
lambda_runtime = "0.3.0"
lambda_http = "0.3.0"

package.json

{
  "name": "test-serverless-rust",
  "version": "1.0.0",
  "description": "",
  "main": "",
  "dependencies": {
    "serverless": "^2.51.0",
    "serverless-rust": "github:softprops/serverless-rust#master"
  },
  "devDependencies": {}
}

serverless.yml

service: test-serverless-rust
frameworkVersion: ^2.51
provider:
    name: aws
    runtime: rust
    memorySize: 128
    region: eu-west-1

package:
    individually: true

plugins:
    - serverless-rust

functions:
    test-serverless-rust:
        handler: test-serverless-rust
        events:
            -   http: 'ANY /'
            -   http: 'ANY /{proxy+}'
custom:
    rust:
        dockerless: true

And main.rs

use lambda_runtime::{handler_fn, Context, Error};
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Error> {
    let func = handler_fn(func);
    lambda_runtime::run(func).await?;
    Ok(())
}

async fn func(event: Value, _: Context) -> Result<Value, Error> {
    let first_name = event["firstName"].as_str().unwrap_or("world");

    Ok(json!({ "message": format!("Hello, {}!", first_name) }))
}

I am running using serverless invoke local -f test-serverless-rust -d '{"firstName":"world"}'

🤔 Expected Behavior

The function to be built and invoked locally.

🌍 Your environment

MacOs 11.4

serverless version: 2.51.0

rust-plugin version: master branch

zamazan4ik commented 2 years ago

I have the same issue on Linux (Fedora 34)

zamazan4ik commented 2 years ago

@softprops can you please create a new release of the package? It will be really much more convenient for the end-users. Thanks in advance!