[Windows] Issue setting up Dev Environment

Hi all,
I’m wanting to start development of a small component. I have been trying to follow the documentation here to set up my environment (https://developers.home-assistant.io/docs/en/development_environment.html) but I am getting confused.

I am running windows and was hoping to be able to run from VS Code using the devcontainer solution but there’s obviously something I am not doing right…

Anyone has experience there and could assist?

One of the biggest problem I am facing is when running devcontainer, I don’t know where to find my “config” folder

I’m not super confident with Docker but familiar enough to think I should have a local folder mapped to it but don’t know where to look

Any help would be appreciated…

THanks

Hi @Guillaume_Corgnet,

I currently try running hass in devcontainer too. I could get it running with the following additional steps:

  1. open the repository with “reopen as container”
  2. after vscode has built and started the container there’s some error in the Terminal Console (Dev Containers):
ERROR: Command errored out with exit status 1: /usr/local/bin/python /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-wgnfv6rl/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=40.8.0' wheel Check the logs for full command output.
postCreateCommand "pip3 install -e ." failed.
  1. open a shell in the container (open the vscode panel, switch to terminal and choose ‘sh’. This should take you to the shell inside the container)
  2. run the following commands in the shell:
cd /workspaces/home-assistant
mkdir config # place your home-assistant configuration here, you should be able to map it on your local filesystem, too
pip uninstall typing # this will 'fix' the error above
script/setup
script/server
  1. If you did not copy your configuration over in step 4 home-assistant should now be running with the default configuration
  2. access the frontend by opening http://localhost:8123 in your favorite browser
1 Like

Same problem here with devcontainer on Windows. Opening as Remote Container works in VSCode. No errors. Also started task ‘Install all Requirements’.
However starting Hass with command:
hass
will startup the application. I can browse to it on ‘http://127.0.0.1:8123’. Registering user, password and setting location is fine. The step after that fails with message.

2019-08-18 15:37:21 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/workspaces/home-assistant/homeassistant/components/http/real_ip.py", line 40, in real_ip_middleware
    return await handler(request)
  File "/workspaces/home-assistant/homeassistant/components/http/ban.py", line 73, in ban_middleware
    return await handler(request)
  File "/workspaces/home-assistant/homeassistant/components/http/auth.py", line 231, in auth_middleware
    return await handler(request)
  File "/workspaces/home-assistant/homeassistant/components/http/view.py", line 128, in handle
    result = await result
  File "/workspaces/home-assistant/homeassistant/components/config/config_entries.py", line 73, in get
    and handler.async_get_options_flow
AttributeError: type object 'MetFlowHandler' has no attribute 'async_get_options_flow'

Using Task ‘Remote Container: Attach to running container’ I could select one container. Connection to that one showed me the contents of the Home Assistant application. Including the configuration.yaml.

Maybe can tell us how to use this devcontainer on Windows. As the documenation on page https://developers.home-assistant.io/docs/en/development_environment.html#developing-with-devcontainer looks a bit of duplicate to me. As the devcontainer already has all stuff present. We again create a seperate environment using commands like:

$ python3 -m venv venv
$ source venv/bin/activate

Any pointer would be much appreciated.

issue with ‘async_get_options_flow’ was fixed in https://github.com/home-assistant/home-assistant/issues/26047

Also got it working by taking the following steps.

  • clone Home Assistant code
    $ git clone https://github.com/home-assistant/home-assistant.git

  • Open home-assistant with Visual Studio Code.

  • Open folder in Remote Container.

  • Get into a shell and create config directory and start Hass
    mkdir config
    hass

  • Start a browser and open http://127.0.0.1:8123/

If onboarding fails change config/configuration.yaml. Uncomment the http: with baseurl. I changed my configuration to:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
http:
  base_url: 127.0.0.1:8123

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

PS: when running (Visual Studio) Task: ‘Preview’ it will also start hass, but I get errors like:
2019-08-22 18:05:15 ERROR (Recorder) [homeassistant.components.recorder.util] Error executing query: (sqlite3.OperationalError) unable to open database file (Background on this error at: http://sqlalche.me/e/e3q8)

Hi guys

I did a search of the forums for a problem I am having, and I came across this thread.

I am seeking to be able to use my Windows 10 laptop with WSL Debian installed, for homeassistant development, using native VS Code on Windows, running dev containers in the remote linux WSL Debian.

I cannot get a working setup following the guide linked above (https://developers.home-assistant.io/docs/en/development_environment.html)

What I did:-

  • I already had Windows 10 HOME installed.

  • I joined the MS Insider programme and got updates to Win10.
    It is now Version 10.0.19041.208]

  • installed Debian buster (10) from MS Store.

  • I applied the kernel update package (wsl_update_x64.msi)

  • I enabled WSL 2 and then I installed Docker Desktop Edge

$ docker --version
Docker version 19.03.8, build afacb8b

$ wsl -l -v
  NAME                   STATE           VERSION
* Debian                 Running         2
  docker-desktop         Running         2
  docker-desktop-data    Running         2
  • I installed Visual Studio Code
C:\users\daz> code --version
1.44.2
ff915844119ce9485abfe8aa9076ec76b5300ddd
x64
  • then I installed the remote-development-extension-pack

  • then in git I forked home assistant

  • then in SWL Debian, I cloned the home assistant repository

$ git clone https://github.com/myaccount/home-assistant.git

So, this is where I am confused.
Am I supposed to be able to open the home assistant repo on my WSL Debian, using VS Code starting it from within the WSL, such as:

$ code .

…because when code fires up, it does not build the devcontainer. The option Remote-Containers: Reopen file in Container is NOT available. I do have the remote connection enabled icon (bottom left of code window)


As I say, pressing F1 and typing Remote-Containers: does not bring up the Reopen folder in container
Should it?

  • So then I tried opening VS Code from Windows, and now pressing F1 does bring up the Reopen Folder in Container so I select it and then Windows File Explorer opens. Of course the cloned repo is in my WSL Debian and not on the native Windows 10.
  • So if I type \wsl$ in the folder bar, now I can navigate to the cloned repo.
  • Then VS Code does indeed build the container but now it doesnt run , here is the output from the Terminal within VS code:
[1 ms] Start: Resolving remote
[8 ms] Setting up container for folder or workspace: \\wsl$\Debian\home\daz\home-assistant

[263 ms] Start: Check Docker is running
[265 ms] Start: Run: docker info
[2982 ms] Start: Run: docker ps -q -a --filter 
label=vsch.local.folder=\\wsl$\Debian\home\daz\home-assistant --filter label=vsch.quality=stable
[4404 ms] Start: Run: docker build -f /home/daz/home-assistant/Dockerfile.dev -t vsc-home-assistant-86765831bccf30b8a2d46179719fb5c0 /home/daz/home-assistant
Sending build context to Docker daemon  27.43MB
Step 1/8 : FROM python:3.8
3.8: Pulling from library/python
90fe46dd8199: Extracting  41.42MB/50.38MB
35a4f1977689: Download complete
bbc37f14aded: Download complete
74e27dc593d4: Download complete
4352dcff7819: Downloading  121.5MB/192.2MB
deb569b08de6: Download complete
98fd06fa8c53: Download complete
7b9cc4fdefe6: Download complete
512732f32795: Download complete
context canceled
[475856 ms] Command failed: docker build -f /home/daz/home-assistant/Dockerfile.dev -t vsc-home-assistant-86765831bccf30b8a2d46179719fb5c0 /home/daz/home-assistant

Where am I going wrong?

EDIT:

If , in my WSL , I move the repo folder /home/daz/homeassistant to /mnt/c/Users/daz/homeassistant then, now if I open VS Code from windows, and use F1 Remote-Containers: Open folder in Container, explorer appears and I can of course open the repo AND it builds the dev-container.
BUT
I read on the Dev guide that putting files in /mnt/c/ is slow and not good practice, but for me its the only way it all works.