Tuesday, September 27, 2022

AWS SAM fails on Windows 11 Home while trying to create an AWS Serverless project in PyCharm with AWS Toolkit

PyCharm shows an exception like this: 

java.lang.RuntimeException: Could not execute `sam init`!: [Cloning from https://github.com/aws/aws-sam-cli-app-templates (process may take a moment), Error: Unstable state when updating repo. Check that you have permissions to create/delete files in C:\Users\user\AppData\Roaming\AWS SAM directory or file an issue at https://github.com/aws/aws-sam-cli/issues] at software.aws.toolkits.jetbrains.services.lambda.wizard.SamInitRunner.execute$lambda-1(SamInitRunner.kt:55) 


This happens because the PATH variable on Windows 11 is limited to 260 chars (no idea why).

The fix is easy: Open Registry Editor (type "regedit" in Windows Search box)

and go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem



then change the value for "LongPathsEnabled" from 0 to 1.


You need a Docker on your computer to run a Local SAM build. Install it and run Docker Desktop at least once to accept T&C's and to start the docker service.

Unfortunately, the latest v4.12.0 Docker for Windows  (as of 2022-09-27) does not work well with the latest AWS SAM 1.57.0. 
AWS SAM "Local" build throughs an error. Downgrading to Docker 4.11.1 solves this issue as discussed here.

Python 3.9 is the latest version currently supported by AWS Lambda. Assuming this is what you have selected for your AWS Lambda project, you need to make sure that SAM can find in your path python 3.9 executable' folder. SAM refuses to continue if it knows the path to e.g. python 3.10 but not to python 3.9.

Monday, August 29, 2022

Runing Ubuntu with full GUI on Windows 10 WSL

 While I did not find the way to run a full-blown ubuntu-desktop I ended up with a nice lightweight LXDE Ubuntu GUI.


If Ubuntu app is not already installed on your computer download it from Microsoft Store.

Run the app and type in the terminal:

sudo apt update

sudo apt upgrade -y

sudo apt install lxde


Now you have to install X server for Windows to make it work. Install VcXsrv freeware.

Set DISPLAY and LIBGL_ALWAYS_INDIRECT values in your Ubuntu terminal. You can later add them both to ~/.bashrc to make this change permanent:

export DISPLAY="$(grep nameserver /etc/resolv.conf | sed 's/nameserver //'):0"

export LIBGL_ALWAYS_INDIRECT=1


DISPLAY=:0 is not enough! (here is some more info) Ubuntu app and Windows have different IP addresses so we have to specify the correct IP for the X-server.


Run X-server on Windows: VcSrv installs as XLaunch. Select "One Large Window" and "Display": 0.


Keep the default "No client"


IMPORTANT: Select "Disable access control" checkbox


Click Next and then Finish buttons. You should get a blank window. Now in your Ubuntu terminal run:

startlxde &


You will get a "No session" dialog. It is fine, just hit "OK" button. And voila! - the full desktop appears



You can now run a terminal, Firefox, and install any Ubuntu app you want.