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 Error #86

Open revmischa opened 3 years ago

revmischa commented 3 years ago

🐛 Bug description

❯ rustup target add x86_64-unknown-linux-musl
info: component 'rust-std' for target 'x86_64-unknown-linux-musl' is up to date
❯ brew install filosottile/musl-cross/musl-cross
Warning: filosottile/musl-cross/musl-cross 0.9.9 is already installed and up-to-date
To reinstall 0.9.9, run `brew reinstall musl-cross`
❯ sls invoke local -f getPosts
Serverless: Running "serverless" installed locally (in service node_modules)
Serverless: Building Rust jkv2-demo.get_posts func...
Serverless: Running local cargo build on darwin
   Compiling cfg-if v0.1.10
   Compiling lazy_static v1.4.0
   Compiling pin-project-internal v0.4.22
   Compiling futures-core v0.3.5
   Compiling slab v0.4.2
   Compiling log v0.4.8
   Compiling version_check v0.9.2
   Compiling proc-macro-hack v0.5.16
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed

error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed

error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-linux-musl` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: build failed
Serverless: Rust build encountered an error: undefined 101.

🌍 Your environment

serverless version:1.82.0

rust-plugin version:0.3.8

softprops commented 3 years ago

Thanks for the report.

Can you paste the cargo.toml file contents you are using here?

seanpianka commented 3 years ago

I'm seeing the same issues with the same development environment:

$ rustup target add x86_unknown-linux-musl
error: toolchain 'nightly-x86_64-apple-darwin' does not contain component 'rust-std' for target 'x86_unknown-linux-musl'; did you mean 'i586-unknown-linux-musl'?

$ rustup default stable
info: using existing install for 'stable-x86_64-apple-darwin'
info: default toolchain set to 'stable-x86_64-apple-darwin'

  stable-x86_64-apple-darwin unchanged - rustc 1.47.0 (18bf6b4f0 2020-10-07)

$ rustup target add x86_unknown-linux-musl
error: toolchain 'stable-x86_64-apple-darwin' does not contain component 'rust-std' for target 'x86_unknown-linux-musl'; did you mean 'i586-unknown-linux-musl'?

$ rustup component add rust-std --toolchain x86_unknown-linux-musl
error: x86_unknown-linux-musl is a custom toolchain

Should I be using:

$ rustup target add i586-unknown-linux-musl

Or will this not work in Lambda?

seanpianka commented 3 years ago

This issue prompted me to try the above command due to an issue with the Rust version used by the compiler:

$ node_modules/serverless/bin/serverless.js deploy
Serverless: Building Rust app.cmd.lambda func...
Serverless: Running containerized build
   Compiling termcolor v1.1.0
   Compiling md5 v0.6.1
   Compiling smol_str v0.1.17
error[E0658]: `while` is not allowed in a `const fn`
  --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/smol_str-0.1.17/src/lib.rs:58:9
   |
58 | /         while i < text.len() {
59 | |             buf[i] = text.as_bytes()[i];
60 | |             i += 1
61 | |         }
   | |_________^
   |
   = note: see issue #52000 <https://github.com/rust-lang/rust/issues/52000> for more information

error: aborting due to previous error

serverless version:1.83.0 rust-plugin version:0.3.8