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

Windows: SAM build failed due to .git folder #1160

Closed
abrooksv opened this issue Apr 30, 2019 · 4 comments
Closed

Windows: SAM build failed due to .git folder #1160

abrooksv opened this issue Apr 30, 2019 · 4 comments

Comments

@abrooksv
Copy link
Contributor

Copied from aws/aws-toolkit-jetbrains#932

Describe the bug
When i try to run lambda local using intellij IDE. Sam started to build project from temp location where it copies the files and folder from source (using codeUri) to temp location and parsing all the files then start to executing invoke command. After that build get failed and showing permission denied error.

To reproduce

  1. After configure for lambda function with required options
  2. Click run icon

Expected behavior
Build won't get failed.

Screenshots
1

Your Environment

  • OS: Windows
  • JetBrains' Product:Intelli Idea Community Edition
  • JetBrains' Product Version: 2018.3.4
  • Toolkit Version: 1.2
  • SAM CLI Version: 0.14.2
  • JVM/Python Version: 3.5.2

Additional context
My project contains source control files (.git files). SAM build failed because it not able read git objects. If there any way to SKIP the folder while build.

Also face this error sometimes,
Error: JavaMavenWorkflow:MavenBuild - 'ascii' codec can't encode character u'\xbb' in position 1266705: ordinal not in range(128)

Error log:

C:\Python37-32\Scripts\sam.exe build --template C:\Users\test-user\AppData\Local\Temp\template1.yaml --build-dir C:\Users\sys-user\AppData\Local\Temp\lambdaBuild1
2019-04-29 20:26:20 Building resource 'Function'
2019-04-29 20:26:21 Running JavaMavenWorkflow:CopySource
2019-04-29 20:26:34 Running JavaMavenWorkflow:MavenBuild
2019-04-29 20:29:01 Running JavaMavenWorkflow:MavenCopyDependency
2019-04-29 20:29:20 Running JavaMavenWorkflow:MavenCopyArtifacts
Traceback (most recent call last):
  File "c:\python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python37-32\Scripts\sam.exe\__main__.py", line 9, in <module>
  File "c:\python37-32\lib\site-packages\click\core.py", line 722, in _call_
    return self.main(*args, **kwargs)
  File "c:\python37-32\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\python37-32\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python37-32\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python37-32\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\python37-32\lib\site-packages\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, args[1:], *kwargs)
  File "c:\python37-32\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\sys-user\AppData\Roaming\Python\Python37\site-packages\samcli\commands\build\command.py", line 95, in cli
    skip_pull_image, parameter_overrides)  # pragma: no cover
  File "C:\Users\sys-user\AppData\Roaming\Python\Python37\site-packages\samcli\commands\build\command.py", line 133, in do_cli
    artifacts = builder.build()
  File "C:\Users\sys-user\AppData\Roaming\Python\Python37\site-packages\samcli\lib\build\app_builder.py", line 99, in build
    lambda_function.runtime)
  File "C:\Users\sys-user\AppData\Roaming\Python\Python37\site-packages\samcli\lib\build\app_builder.py", line 190, in _build_function
    runtime)
  File "c:\python37-32\lib\contextlib.py", line 119, in _exit_
    next(self.gen)
  File "C:\Users\sys-user\AppData\Roaming\Python\Python37\site-packages\samcli\lib\utils\osutils.py", line 40, in mkdir_temp
    shutil.rmtree(temp_dir)
  File "c:\python37-32\lib\shutil.py", line 513, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "c:\python37-32\lib\shutil.py", line 392, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "c:\python37-32\lib\shutil.py", line 392, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "c:\python37-32\lib\shutil.py", line 392, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "c:\python37-32\lib\shutil.py", line 397, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "c:\python37-32\lib\shutil.py", line 395, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\test-user\\AppData\\Local\\Temp\\tmpcok3g9n9\\.git\\objects\\01\\211802753b064db7468a67a23241b18c59db64'
@ghost
Copy link

ghost commented May 15, 2019

Hi,

This is a critical issue. Running a compilation in Docker is slow and not all our customers can run Docker on their Windows laptops/workstations because of organizations security policies.

Do you have any updates when it is planned to be resolved?

Thanks in advance!

@ghost
Copy link

ghost commented May 15, 2019

It looks like this issue exists only when function code in the root folder. If you move the function code into the subfolder, everything is working as expected.

@matt-lumer
Copy link

matt-lumer commented Jul 9, 2019

I submitted a PR to ignore .git folder, looks like Python already had this but Java (maven specifically, I did not look at gradle) only has .aws-sam as the ignore directory. Suggested by @TheSrira #1241

PR
aws/aws-lambda-builders#120

Look for EXCLUDED_FILES

Python
https:/awslabs/aws-lambda-builders/blob/develop/aws_lambda_builders/workflows/python_pip/workflow.py

Java
https:/awslabs/aws-lambda-builders/blob/develop/aws_lambda_builders/workflows/java_maven/workflow.py

@sriram-mv
Copy link
Contributor

This is merged. Closing the issue.

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

No branches or pull requests

4 participants