Can't start localstack on macOS

Viewed 2426

Using Python 3.7.10 and pip 21.1.2

Installed localstack by pip install localstack.

Ran command localstack start to start, got

WARNING:localstack.services.plugins: Service "s3" not yet available, retrying...

On the document, there is a notice like

(Note that on MacOS you may have to run TMPDIR=/private$TMPDIR localstack start --docker if $TMPDIR contains a symbolic link that cannot be mounted by Docker.)

But I ran this command again:

TMPDIR=/private$TMPDIR localstack start --docker

got this error:

Traceback (most recent call last):
  File "/opt/code/localstack/localstack/services/plugins.py", line 102, in check_infra
    check_service_health(api=name, print_error=print_error)
  File "/opt/code/localstack/localstack/services/plugins.py", line 121, in check_service_health
    raise e
  File "/opt/code/localstack/localstack/services/plugins.py", line 117, in check_service_health
    plugin.check(expect_shutdown=expect_shutdown, print_error=print_error)
  File "/opt/code/localstack/localstack/services/plugins.py", line 45, in check
    return self.check_function(expect_shutdown=expect_shutdown, print_error=print_error)
  File "/opt/code/localstack/localstack/services/s3/s3_starter.py", line 44, in check_s3
    assert isinstance(out['Buckets'], list)
TypeError: 'NoneType' object is not subscriptable

On the office issue, somebody said remove HOSTNAME from environment. I didn't set it, is it the key reason?

Why this famous issue happened? (And always?)


output errors when use docker-compose

localstack    | During handling of the above exception, another exception occurred:
localstack    |
localstack    | Traceback (most recent call last):
localstack    |   File "/opt/code/localstack/localstack/services/plugins.py", line 102, in check_infra
localstack    |     check_service_health(api=name, print_error=print_error)
localstack    |   File "/opt/code/localstack/localstack/services/plugins.py", line 121, in check_service_health
localstack    |     raise e
localstack    |   File "/opt/code/localstack/localstack/services/plugins.py", line 117, in check_service_health
localstack    |     plugin.check(expect_shutdown=expect_shutdown, print_error=print_error)
localstack    |   File "/opt/code/localstack/localstack/services/plugins.py", line 45, in check
localstack    |     return self.check_function(expect_shutdown=expect_shutdown, print_error=print_error)
localstack    |   File "/opt/code/localstack/localstack/services/s3/s3_starter.py", line 44, in check_s3
localstack    |     assert isinstance(out['Buckets'], list)
localstack    | TypeError: 'NoneType' object is not subscriptable
localstack    |
localstack    | During handling of the above exception, another exception occurred:
localstack    |
localstack    | Traceback (most recent call last):
localstack    |   File "/opt/code/localstack/localstack/utils/cli.py", line 223, in main
localstack    |     subcommand['function'](argv, args)
localstack    |   File "/opt/code/localstack/localstack/utils/cli.py", line 61, in cmd_infra
localstack    |     start_infra_locally()
localstack    |   File "/opt/code/localstack/localstack/utils/bootstrap.py", line 377, in start_infra_locally
localstack    |     return infra.start_infra()
localstack    |   File "/opt/code/localstack/localstack/services/infra.py", line 388, in start_infra
localstack    |     raise e
localstack    |   File "/opt/code/localstack/localstack/services/infra.py", line 374, in start_infra
localstack    |     thread = do_start_infra(asynchronous, apis, is_in_docker)
localstack    |   File "/opt/code/localstack/localstack/services/infra.py", line 460, in do_start_infra
localstack    |     thread = start_api_services()
localstack    |   File "/opt/code/localstack/localstack/utils/analytics/profiler.py", line 156, in wrapped
localstack    |     return f(*args, **kwargs)
localstack    |   File "/opt/code/localstack/localstack/services/infra.py", line 449, in start_api_services
localstack    |     check_infra(apis=apis)
localstack    |   File "/opt/code/localstack/localstack/services/plugins.py", line 111, in check_infra
localstack    |     check_infra(retries - 1, expect_shutdown=expect_shutdown, apis=apis, additional_checks=additional_checks)
localstack    |   File "/opt/code/localstack/localstack/services/plugins.py", line 111, in check_infra
localstack    |     check_infra(retries - 1, expect_shutdown=expect_shutdown, apis=apis, additional_checks=additional_checks)
localstack    |   File "/opt/code/localstack/localstack/services/plugins.py", line 111, in check_infra
localstack    |     check_infra(retries - 1, expect_shutdown=expect_shutdown, apis=apis, additional_checks=additional_checks)
localstack    |   [Previous line repeated 7 more times]
localstack    |   File "/opt/code/localstack/localstack/services/plugins.py", line 109, in check_infra
localstack    |     raise e
localstack    |   File "/opt/code/localstack/localstack/services/plugins.py", line 102, in check_infra
localstack    |     check_service_health(api=name, print_error=print_error)
localstack    |   File "/opt/code/localstack/localstack/services/plugins.py", line 121, in check_service_health
localstack    |     raise e
localstack    |   File "/opt/code/localstack/localstack/services/plugins.py", line 117, in check_service_health
localstack    |     plugin.check(expect_shutdown=expect_shutdown, print_error=print_error)
localstack    |   File "/opt/code/localstack/localstack/services/plugins.py", line 45, in check
localstack    |     return self.check_function(expect_shutdown=expect_shutdown, print_error=print_error)
localstack    |   File "/opt/code/localstack/localstack/services/s3/s3_starter.py", line 44, in check_s3
localstack    |     assert isinstance(out['Buckets'], list)
localstack    | TypeError: 'NoneType' object is not subscriptable
localstack    |
localstack    | ERROR: 'NoneType' object is not subscriptable
localstack    | (. .venv/bin/activate; exec bin/localstack start --host)
localstack    | make: *** [Makefile:55: infra] Error 1
localstack    | Waiting for all LocalStack services to be ready
localstack    | Starting local dev environment. CTRL-C to quit.
localstack    | 2021-10-06 06:09:13,229 INFO success: infra entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
localstack    |
localstack    | LocalStack version: 0.12.12
localstack    | LocalStack Docker container id: 388ad2388117
localstack    | LocalStack build date: 2021-06-07
localstack    | LocalStack build git hash: ea4dcf40
1 Answers

Alternatively, You can start localstack using docker-compose. Create docker-compose.yml file as given below and use this command docker-compose up to get started with localstack perfectly. Once localstack is up and running, you can also check the health of all the services by hitting url as http://localhost:4566/health

Prerequisites:

  • Have Docker installed, if you haven’t already.
version: "3.8"
services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack}"
    image: localstack/localstack
    hostname: localstack
    networks:
      - test-net
    ports:
      - "4566:4566"
    environment:
      - SERVICES=s3,sqs,cloudformation,iam,cloudwatch
      - DEBUG=1
      - DATA_DIR=/tmp/localstack/data
      - LAMBDA_EXECUTOR=docker-reuse
      - LAMBDA_REMOTE_DOCKER=false
      - LAMBDA_REMOVE_CONTAINERS=true
      - DOCKER_HOST=unix:///var/run/docker.sock
      - HOST_TMP_FOLDER=${TMPDIR}
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
networks:
  test-net:
    external: false
    driver: bridge
    name: test-net

Follow this guide to know more

Related