SAM build command Raises Error: PythonPipBuilder:ResolveDependencies
See original GitHub issueDescription:
sam build command fails the build and raises the following error
Error: PythonPipBuilder:ResolveDependencies - ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte
Steps to reproduce:
- Make code change
- Commit and Push code change
- Takes in a change but fails the build
Observed result:
[Container] 2021/01/05 01:01:32 Running command sam build --debug
199 | 200 | SAM CLI now collects telemetry to better understand customer needs. 201 | 202 | You can OPT OUT and disable telemetry collection by setting the 203 | environment variable SAM_CLI_TELEMETRY=0 in your shell. 204 | Thanks for your help! 205 | 206 | Learn More: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-telemetry.html 207 | 208 | 2021-01-05 01:01:33,153 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics 209 | 2021-01-05 01:01:33,558 | ‘build’ command is called 210 | 2021-01-05 01:01:33,560 | No Parameters detected in the template 211 | 2021-01-05 01:01:33,579 | 1 resources found in the template 212 | 2021-01-05 01:01:33,579 | Found Serverless function with name=‘DatabaseFunction’ and CodeUri=‘lambda/’ 213 | 2021-01-05 01:01:33,579 | No Parameters detected in the template 214 | 2021-01-05 01:01:33,596 | Instantiating build definitions 215 | 2021-01-05 01:01:33,596 | No previous build graph found, generating new one 216 | 2021-01-05 01:01:33,596 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(python3.8, lambda/, Zip, , 86baab67-d2e2-40b1-963b-7846cc170686, {}, []), Function: Function(name=‘DatabaseFunction’, functionname=‘DatabaseFunction’, runtime=‘python3.8’, memory=None, timeout=3, handler=‘db_lambda_function.lambda_handler’, imageuri=None, packagetype=‘Zip’, imageconfig=None, codeuri=‘lambda/’, environment=None, rolearn=None, layers=[], events=None, metadata=None, codesign_config_arn=None)) 217 | 2021-01-05 01:01:33,597 | Building codeuri: lambda/ runtime: python3.8 metadata: {} functions: [‘DatabaseFunction’] 218 | 2021-01-05 01:01:33,597 | Building to following folder /codebuild/output/src453670849/src/.aws-sam/build/DatabaseFunction 219 | 2021-01-05 01:01:33,598 | Loading workflow module ‘aws_lambda_builders.workflows’ 220 | 2021-01-05 01:01:33,599 | Registering workflow ‘PythonPipBuilder’ with capability ‘Capability(language=‘python’, dependency_manager=‘pip’, application_framework=None)’ 221 | 2021-01-05 01:01:33,600 | Registering workflow ‘NodejsNpmBuilder’ with capability ‘Capability(language=‘nodejs’, dependency_manager=‘npm’, application_framework=None)’ 222 | 2021-01-05 01:01:33,601 | Registering workflow ‘RubyBundlerBuilder’ with capability ‘Capability(language=‘ruby’, dependency_manager=‘bundler’, application_framework=None)’ 223 | 2021-01-05 01:01:33,602 | Registering workflow ‘GoDepBuilder’ with capability ‘Capability(language=‘go’, dependency_manager=‘dep’, application_framework=None)’ 224 | 2021-01-05 01:01:33,603 | Registering workflow ‘GoModulesBuilder’ with capability ‘Capability(language=‘go’, dependency_manager=‘modules’, application_framework=None)’ 225 | 2021-01-05 01:01:33,604 | Registering workflow ‘JavaGradleWorkflow’ with capability ‘Capability(language=‘java’, dependency_manager=‘gradle’, application_framework=None)’ 226 | 2021-01-05 01:01:33,605 | Registering workflow ‘JavaMavenWorkflow’ with capability ‘Capability(language=‘java’, dependency_manager=‘maven’, application_framework=None)’ 227 | 2021-01-05 01:01:33,606 | Registering workflow ‘DotnetCliPackageBuilder’ with capability ‘Capability(language=‘dotnet’, dependency_manager=‘cli-package’, application_framework=None)’ 228 | 2021-01-05 01:01:33,607 | Registering workflow ‘CustomMakeBuilder’ with capability ‘Capability(language=‘provided’, dependency_manager=None, application_framework=None)’ 229 | 2021-01-05 01:01:33,607 | Found workflow ‘PythonPipBuilder’ to support capabilities ‘Capability(language=‘python’, dependency_manager=‘pip’, application_framework=None)’ 230 | 2021-01-05 01:01:33,622 | Running workflow ‘PythonPipBuilder’ 231 | 2021-01-05 01:01:33,622 | Running PythonPipBuilder:ResolveDependencies 232 | 2021-01-05 01:01:33,636 | PythonPipBuilder:ResolveDependencies raised unhandled exception 233 | Traceback (most recent call last): 234 | File “/root/.pyenv/versions/3.8.1/lib/python3.8/site-packages/aws_lambda_builders/workflow.py”, line 269, in run 235 | action.execute() 236 | File “/root/.pyenv/versions/3.8.1/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/actions.py”, line 39, in execute 237 | package_builder.build_dependencies( 238 | File “/root/.pyenv/versions/3.8.1/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/packager.py”, line 137, in build_dependencies 239 | self._dependency_builder.build_site_packages(requirements_path, artifacts_dir_path, scratch_dir_path) 240 | File “/root/.pyenv/versions/3.8.1/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/packager.py”, line 203, in build_site_packages 241 | if self._has_at_least_one_package(requirements_filepath): 242 | File “/root/.pyenv/versions/3.8.1/lib/python3.8/site-packages/aws_lambda_builders/workflows/python_pip/packager.py”, line 217, in _has_at_least_one_package 243 | for line in f: 244 | File “/root/.pyenv/versions/3.8.1/lib/python3.8/codecs.py”, line 322, in decode 245 | (result, consumed) = self._buffer_decode(data, self.errors, final) 246 | UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte 247 | 248 | Build Failed 249 | 2021-01-05 01:01:33,667 | Sending Telemetry: {‘metrics’: [{‘commandRun’: {‘awsProfileProvided’: False, ‘debugFlagProvided’: True, ‘region’: ‘’, ‘commandName’: ‘sam build’, ‘duration’: 514, ‘exitReason’: ‘WorkflowUnknownError’, ‘exitCode’: 1, ‘requestId’: ‘17116347-e3d5-4f81-81f6-b1f3fec2bd1f’, ‘installationId’: ‘803a2f2c-cc5a-4b15-8523-89c5813dcfe4’, ‘sessionId’: ‘82d9f0a9-ae73-452e-8f23-2079de999482’, ‘executionEnvironment’: ‘CLI’, ‘pyversion’: ‘3.8.1’, ‘samcliVersion’: ‘1.15.0’}}]} 250 | 2021-01-05 01:01:33,708 | Telemetry response: 200 251 | Error: PythonPipBuilder:ResolveDependencies - ‘utf-8’ codec can’t decode byte 0xff in position 0: invalid start byte 252 | 253 | [Container] 2021/01/05 01:01:33 Command did not exit successfully sam build --debug exit status 1 254 | [Container] 2021/01/05 01:01:33 Phase complete: BUILD State: FAILED 255 | [Container] 2021/01/05 01:01:33 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: sam build --debug. Reason: exit status 1 256 | [Container] 2021/01/05 01:01:33 Entering phase POST_BUILD 257 | [Container] 2021/01/05 01:01:33 Running command sam package --s3-bucket $PACKAGE_BUCKET --output-template-file packaged.yaml 258 | 259 | Uploading to 69df360ce7669188fe81ab76fc7a9056 7644 / 7644.0 (100.00%) 260 | Successfully packaged artifacts and wrote output template to file packaged.yaml. 261 | Execute the following command to deploy the packaged template 262 | sam deploy --template-file /codebuild/output/src453670849/src/packaged.yaml --stack-name <YOUR STACK NAME>
Expected result:
sam build Running PythonPipBuilder:ResolveDependencies Running PythonPipBuilder:CopySource
Build Succeeded
Built Artifacts : .aws-sam\build Built Template : .aws-sam\build\template.yaml
Commands you can use next
[] Invoke Function: sam local invoke [] Deploy: sam deploy --guided
This is the expected output I get when I run it locally
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Windows 10 for local and I am using the
Ubuntu 18.04 | aws/codebuild/standard:3.0 for when I push to the container environment
sam --version
: aws-sam-cli-1.15.0
Add --debug flag to command you are running
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Hello! Not sure if anyone else has gotten the change to provide or look into this issue. I will say I fixed the problem with the build. It turns out my file was not in the correct UTF-8 format. Something with git or other repository mechanism must have changed. It was weird because I was pair programming with someone and they had also seen that it was set to UTF-8 prior to testing things out. Nonetheless, this issue can be closed.
Thanks for confirming!