Fix Cursor update crashes and keymapping issues on NixOS

This commit is contained in:
thinktankmachine
2025-08-07 08:56:41 +10:00
parent 035a280383
commit 32155ec2dc
2 changed files with 39 additions and 9 deletions
+15 -3
View File
@@ -223,9 +223,21 @@ cursor
**Symptoms**: `Error: Cannot find module './build/Debug/keymapping'` **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 **Symptoms**: Various library-related errors
@@ -238,7 +250,7 @@ sudo nixos-rebuild switch --flake .#your-system
rm -rf ~/.cache/appimage-run/* rm -rf ~/.cache/appimage-run/*
``` ```
#### 4. Git Authentication Issues #### 5. Git Authentication Issues
**Symptoms**: `fatal: Authentication failed` **Symptoms**: `fatal: Authentication failed`
+22 -4
View File
@@ -1,13 +1,17 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let 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" '' cursorAppImage = pkgs.writeShellScriptBin "cursor" ''
# Set up environment for better AppImage compatibility # Set up environment for better AppImage compatibility
export APPDIR="" export APPDIR=""
export ARGV0="" export ARGV0=""
export OWD="" 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 # Ensure proper library paths
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath [ export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath [
pkgs.glib pkgs.glib
@@ -32,13 +36,27 @@ let
pkgs.at-spi2-core pkgs.at-spi2-core
pkgs.mesa pkgs.mesa
pkgs.alsa-lib pkgs.alsa-lib
pkgs.fuse
]}:$LD_LIBRARY_PATH" ]}:$LD_LIBRARY_PATH"
# Run the AppImage with appimage-run # Set additional environment variables to handle keymapping issues
exec ${pkgs.appimage-run}/bin/appimage-run ${pkgs.fetchurl { 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"; url = "https://downloads.cursor.com/production/54c27320fab08c9f5dd5873f07fca101f7a3e076/linux/x64/Cursor-1.3.9-x86_64.AppImage";
sha256 = "076ijp033xjg09aqjhjm6sslvq0hsjga35840m3br722lqpi6jfj"; sha256 = "076ijp033xjg09aqjhjm6sslvq0hsjga35840m3br722lqpi6jfj";
}} "$@" }} \
--disable-updates \
--no-update-check \
"$@"
''; '';
in in
{ {