Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NodejsFunction broken on Windows #8107

Closed
misterjoshua opened this issue May 20, 2020 · 1 comment · Fixed by #8140
Closed

NodejsFunction broken on Windows #8107

misterjoshua opened this issue May 20, 2020 · 1 comment · Fixed by #8140
Assignees
Labels
@aws-cdk/aws-lambda-nodejs bug This issue is a bug. in-progress This issue is being actively worked on.

Comments

@misterjoshua
Copy link
Contributor

NodejsFunction doesn't work on Windows. There's some sort of problem with the way it translates Windows paths (backslash) to Docker.

Reproduction Steps

lib/my-stack.ts:

export class MyStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
    new NodejsFunction(this, 'handler');
  }
}

lib/my-stack.handler.ts:

export const handler = () => 'anything';

Error Log

PS E:\p\break> yarn cdk synth                                                                                                                                                                                                  yarn run v1.22.4
warning package.json: No license field
$ cdk synth
Failed to build file at E:\p\break\lib\my-stack.handler.ts: Error: [Status 125] stdout:


stderr: docker: Error response from daemon: the working directory '\project\lib' is invalid, it needs to be an absolute path.
See 'docker run --help'.
Subprocess exited with error 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Environment

  • CLI Version : 1.40.0
  • Framework Version: 1.40.0
  • OS : Windows 10
  • Language : TypeScript on NodeJS v12.1.0

This is 🐛 Bug Report

@misterjoshua misterjoshua added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 20, 2020
@jogold
Copy link
Contributor

jogold commented May 21, 2020

The problem is here:

'-w', path.dirname(containerEntryPath),

containerEntryPath is constructed using a path.join() but it should always use forward slashes.

Will open a PR to fix this.

jogold added a commit to jogold/aws-cdk that referenced this issue May 21, 2020
This is because the operations of [`path`](https://nodejs.org/api/path.html) are
OS specific. But for the container working directory and inside the container we
never want to use Windows style paths.

Fixes aws#8107
@SomayaB SomayaB added @aws-cdk/aws-lambda-nodejs in-progress This issue is being actively worked on. and removed needs-triage This issue or PR still needs to be triaged. labels May 26, 2020
@mergify mergify bot closed this as completed in #8140 May 26, 2020
mergify bot pushed a commit that referenced this issue May 26, 2020
This is because the operations of [`path`](https://nodejs.org/api/path.html) are
OS specific. But for the container working directory and inside the container we
never want to use Windows style paths.

Fixes #8107


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda-nodejs bug This issue is a bug. in-progress This issue is being actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants