From 32155ec2dc203ec4b6b172db08757ce6c8ca6cec Mon Sep 17 00:00:00 2001 From: thinktankmachine Date: Thu, 7 Aug 2025 08:56:41 +1000 Subject: [PATCH] Fix Cursor update crashes and keymapping issues on NixOS --- README.md | 18 +++++++++++++++--- home.nix | 30 ++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0b1455b..145db09 100644 --- a/README.md +++ b/README.md @@ -223,9 +223,21 @@ cursor **Symptoms**: `Error: Cannot find module './build/Debug/keymapping'` -**Solution**: These are cosmetic errors and don't prevent Cursor from working. The enhanced wrapper should reduce these errors. +**Solution**: These are cosmetic errors and don't prevent Cursor from working. The enhanced wrapper includes additional environment variables to reduce these errors. -#### 3. Library Loading Issues +#### 3. Update Mechanism Crashes + +**Symptoms**: Cursor crashes when trying to update, shows "update available" but fails to install + +**Solution**: The enhanced wrapper disables Cursor's auto-update mechanism to prevent crashes. To update Cursor, use the flake's update process instead: + +```bash +# Update to a new version +./update-cursor-hash.sh +sudo nixos-rebuild switch --flake .#your-system +``` + +#### 4. Library Loading Issues **Symptoms**: Various library-related errors @@ -238,7 +250,7 @@ sudo nixos-rebuild switch --flake .#your-system rm -rf ~/.cache/appimage-run/* ``` -#### 4. Git Authentication Issues +#### 5. Git Authentication Issues **Symptoms**: `fatal: Authentication failed` diff --git a/home.nix b/home.nix index f5976d6..082a57b 100644 --- a/home.nix +++ b/home.nix @@ -1,13 +1,17 @@ { config, pkgs, lib, ... }: let - # Cursor 1.3.9 AppImage wrapper with enhanced compatibility + # Cursor 1.3.9 AppImage wrapper with enhanced compatibility and update handling cursorAppImage = pkgs.writeShellScriptBin "cursor" '' # Set up environment for better AppImage compatibility export APPDIR="" export ARGV0="" export OWD="" + # Disable Cursor's auto-update mechanism to prevent crashes + export CURSOR_DISABLE_UPDATE="1" + export CURSOR_SKIP_UPDATE_CHECK="1" + # Ensure proper library paths export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath [ pkgs.glib @@ -32,13 +36,27 @@ let pkgs.at-spi2-core pkgs.mesa pkgs.alsa-lib + pkgs.fuse ]}:$LD_LIBRARY_PATH" - # Run the AppImage with appimage-run - exec ${pkgs.appimage-run}/bin/appimage-run ${pkgs.fetchurl { - url = "https://downloads.cursor.com/production/54c27320fab08c9f5dd5873f07fca101f7a3e076/linux/x64/Cursor-1.3.9-x86_64.AppImage"; - sha256 = "076ijp033xjg09aqjhjm6sslvq0hsjga35840m3br722lqpi6jfj"; - }} "$@" + # Set additional environment variables to handle keymapping issues + export ELECTRON_DISABLE_SECURITY_WARNINGS="1" + export ELECTRON_NO_ATTACH_CONSOLE="1" + + # Create a temporary directory for Cursor's cache to avoid permission issues + export CURSOR_CACHE_DIR="/tmp/cursor-cache-$$" + mkdir -p "$CURSOR_CACHE_DIR" + + # Run the AppImage with appimage-run and additional flags + exec ${pkgs.appimage-run}/bin/appimage-run \ + --no-sandbox \ + ${pkgs.fetchurl { + url = "https://downloads.cursor.com/production/54c27320fab08c9f5dd5873f07fca101f7a3e076/linux/x64/Cursor-1.3.9-x86_64.AppImage"; + sha256 = "076ijp033xjg09aqjhjm6sslvq0hsjga35840m3br722lqpi6jfj"; + }} \ + --disable-updates \ + --no-update-check \ + "$@" ''; in {