question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Windows: Uploaded binaries cannot be executed

See original GitHub issue

Attaching a binary file to the project on the Windows platform should behave similarly to Linux, in which that given the correct permissions on the file it should be executable by the Lambda server (or similar Serverless binary compatible server)

A workaround for this issue is to use Bash for Windows to zip the project (with the file given 777) and upload manually

  • What did you expect should have happened? The file attached should be executable by Lambda (or similar Serverless binary compatible server)

Although I expect it to be executable the way Windows defines what is/is not executable is different to Linux, so the permissions on the file may be harder to utilise, a proposed idea is to have a configuration file marking files/folders as executable

  • What was the config you used? N/A
  • What stacktrace or error message from your provider did you see? [Error: spawn EACCES] code: 'EACCES', errno: 'EACCES', syscall: 'spawn' when trying to launch the process

Similar or dependent issues: #1631

Proposed solution

(Added by maintainers after investigating the matter)

  1. As proposed below in https://github.com/serverless/serverless/issues/3557#issuecomment-315525767 by @ilanc, when packaging on Windows ensure each packaged file is executable (as we’re packaging for environment with already properly restricted access, so there seems no risks in doing that) File permissions are setup here: https://github.com/serverless/serverless/blob/03940254385e138eb40f2f25bd56fcdbee0c3a22/lib/plugins/package/lib/zipService.js#L105-L109

  2. Revert tweak introduced here https://github.com/serverless/serverless/pull/5813 for golang runtime. It’s hacky and obsolete with above solution

PR’s welcome!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:33 (7 by maintainers)

github_iconTop GitHub Comments

13reactions
Agrumascommented, Feb 6, 2018

Some kind of workaround is really needed because go applications can not be used if deployed using win. Execution fails: { "errorMessage": "fork/exec /var/task/bin/main: permission denied", "errorType": "PathError" } executable option is good but not flexible I would suggest mode:

package:
  include:
    - some-shared-lib.js
    - sox
  mode: 0744 # change mode for all files
  mode: 
    0644:
      - sox # change mode per file
8reactions
mattisdadacommented, May 4, 2017

I completely agree with you, but having to build on a foreign system without a workaround feels pretty gross and mandating more complex build/deployment for it to work is painful (whereas right now you can just start working on something small and simple and get it up and running easily)

I’d say the way executable are currently being handled is equally insecure as right now it is unclear what the serverless deploy command is doing, if I was working on a developer machine to do my deployments, I would often have “looser” file permissions than I would on a normal build server/production environment, it would be easy to accidentally introduce something as too permissive

My proposed idea would be more to make everything non-executable (even if ithe file is 777 or similar on the deployment machine) unless specified in the config, if worried you could even remove globbing and just have listed files

For example:

package:
  include:
    - some-shared-lib.js
    - sox
   executable:
    - sox

It would make deployments more consistent regardless of the operating system running the deployment, and in general going out of your way to make something more permissible is often more secure (if that is a concern)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix Cannot Execute Binary File Error
When you cannot execute binary file Linux, generally the message of the error appears when Linux is not able to detect or identify...
Read more >
Event Id 18 - An attempt to execute a platform binary failed with
Hi, I'm trying to test WPBT feature. The table is accessed but the launch of binary failed. I tried in Windows 8 and...
Read more >
collection failed - binary cannot be executed - Intel Communities
Binary compiled under Windows 7, VS2010, and Intel Fortran 12.1, using open MP. This binary works fine in Debug mode under VS.
Read more >
Executing Binary Files - linux - Stack Overflow
Although Rad Hat Linux and Mac OS X are both 'Unix based', they cannot run each other's binaries. Just like you can't run...
Read more >
How can I resolve the error "cannot execute binary file"?
Usually that error message means Linux doesn't recognize the file as a shell script or as an executable file. Typically the cause is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found