Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Conversation

@toyama0919
Copy link

This plugin not works sls invoke local.

Traceback (most recent call last):
  File "/usr/local/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/invoke.py", line 72, in <module>
    module = import_module(args.handler_path.replace('/', '.'))
  File "/Users/hiroshi.toyama/.pyenv/versions/3.6.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./ec2.py", line 1, in <module>
    import unzip_requirements
  File "./unzip_requirements.py", line 20, in <module>
    zipfile.ZipFile(zip_requirements, 'r').extractall(tempdir)
  File "/Users/hiroshi.toyama/.pyenv/versions/3.6.6/lib/python3.6/zipfile.py", line 1090, in __init__
    self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: '/var/task/.requirements.zip'

Because LAMBDA_TASK_ROOT set serverless main code, os.getcwd() not work.
https://github.com/serverless/serverless/blob/master/lib/plugins/aws/invokeLocal/index.js#L102

Copy link
Contributor

@dschep dschep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that really all that's needed? or do you have to run sls package before calling sls invoke local?

@toyama0919
Copy link
Author

or do you have to run sls package before calling sls invoke local?

of course do it.
before sls requirements install checked too.

@dschep dschep merged commit 4733483 into serverless:master Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants