getcursor / cursor

The AI Code Editor
https://cursor.com
20.65k stars 1.38k forks source link

Add RPM and DEB packages for Linux #933

Open mysticaltech opened 10 months ago

mysticaltech commented 10 months ago

Hey folks, cursor is amazing but currently the linux version is a .AppImage. Yes, this is simpler for you devs, but for us users it's suboptimal.

AppImages do not ingreate deeply into the OS, we don't get a proper VSCode replacement with nice Icons, possibility to have mutiple instances running etc. It's super limited.

You will need to create two packages on top of AppImage, .rpm, and .deb. That should cover most Linux OSes.

Personally I just need the .rpm as I'm on Fedora but am also thinking about others.

AlexCRX commented 10 months ago

yeah, so many bug met by using Appimages. Many AI engineers use linux as their main work env. so i think .deb and .rpm is needed. By the way , I need .deb....

truell20 commented 10 months ago

This is totally fair. We're a small eng team and are trying to balance new features/bug fixes with supporting more platforms. Agree deb/rpm is better and hope to have these available sometime in the near future.

clayrisser commented 10 months ago

Looking forward to a deb.

ephemeralrogue commented 10 months ago

+1 to this. I've tried a number of ways to execute the AppImage on my machine and no dice. I'm looking forward to using Cursor when it's available via .deb.

mysticaltech commented 10 months ago

@nonsensetwice You just need to give it exec permissions with chmod +x cusor-xxx.AppImage, then you can execute either via terminal, or by double clicking. I ended up creating an alias in my shell, so I just execute cursor . in the project I want to open (this is needed because the cursor cli itself won't install via AppImage). It works, but you cannot run multiple instances, and no deep OS integration, so definitely not an ideal long term solution.

kristopolous commented 10 months ago

this is trivial just do something like this.

#!/bin/bash
VER=0.10.4
./cursor-${ver}.AppImage --appimage-extract
mv squashfs-root cursor-${ver}
mkdir -p cursor-${ver}/usr/local/cursor cursor-${ver}/usr/local/bin
mv cursor-${ver}/{*,.*} cursor-${ver}/usr/local/cursor
( cd cursor-${ver}/usr/local/bin/ && ln -s ../cursor/cursor . )
mkdir cursor-${ver}/DEBIAN
cat > cursor-${ver}/DEBIAN/control << ENDL
Package: cursor
Version: ${ver}
Architecture: all
Maintainer: nobody@nobody.com
Installed-Size: 158812254
Section: misc
Priority: optional
Description: cursor app
ENDL
dpkg-deb --build cursor-${ver}
# sudo dpkg -i cursor-${ver}.deb

there you go.

MobiCode48 commented 10 months ago

Does the AppImage version autoupdate ?

mysticaltech commented 10 months ago

Does the AppImage version autoupdate ?

Sadly no, it's not managed by a package manager.

mysticaltech commented 10 months ago

this is trivial just do something like this.

#!/bin/bash
VER=0.10.4
./cursor-${ver}.AppImage --appimage-extract
mv squashfs-root cursor-${ver}
mkdir -p cursor-${ver}/usr/local/cursor cursor-${ver}/usr/local/bin
mv cursor-${ver}/{*,.*} cursor-${ver}/usr/local/cursor
( cd cursor-${ver}/usr/local/bin/ && ln -s ../cursor/cursor . )
mkdir cursor-${ver}/DEBIAN
cat > cursor-${ver}/DEBIAN/control << ENDL
Package: cursor
Version: ${ver}
Architecture: all
Maintainer: nobody@nobody.com
Installed-Size: 158812254
Section: misc
Priority: optional
Description: cursor app
ENDL
dpkg-deb --build cursor-${ver}
# sudo dpkg -i cursor-${ver}.deb

there you go.

@kristopolous That's a cool trick, but not ideal to do everytime. And in a perfect world, there would be both an apt and yum repo.

mysticaltech commented 10 months ago

This is totally fair. We're a small eng team and are trying to balance new features/bug fixes with supporting more platforms. Agree deb/rpm is better and hope to have these available sometime in the near future.

@truell20 Really appreciate the positive outlook on this. I made a quick research on how to best host yum (for rpm) and apt (for deb) repository and found someone on reddit mentioning sonartype.com.

https://help.sonatype.com/repomanager3/nexus-repository-administration/formats/apt-repositories https://help.sonatype.com/repomanager3/nexus-repository-administration/formats/yum-repositories

If those packages are going to be build automatically then it's ideal to have linux package repos for them, it's how vscode does it for instance. That way the app gets updated automatically (for those that turn on automatic updates at the OS level), and everything stays evergreen!

kristopolous commented 9 months ago

this is trivial just do something like this.

#!/bin/bash
VER=0.10.4
./cursor-${ver}.AppImage --appimage-extract
mv squashfs-root cursor-${ver}
mkdir -p cursor-${ver}/usr/local/cursor cursor-${ver}/usr/local/bin
mv cursor-${ver}/{*,.*} cursor-${ver}/usr/local/cursor
( cd cursor-${ver}/usr/local/bin/ && ln -s ../cursor/cursor . )
mkdir cursor-${ver}/DEBIAN
cat > cursor-${ver}/DEBIAN/control << ENDL
Package: cursor
Version: ${ver}
Architecture: all
Maintainer: nobody@nobody.com
Installed-Size: 158812254
Section: misc
Priority: optional
Description: cursor app
ENDL
dpkg-deb --build cursor-${ver}
# sudo dpkg -i cursor-${ver}.deb

there you go.

@kristopolous That's a cool trick, but not ideal to do everytime. And in a perfect world, there would be both an apt and yum repo.

You put it in the build script...

I'm a debian maintainer btw, I can get it inside of apt if you're really serious about it.

kristopolous commented 9 months ago

oh you're just a reporter ... right ... so you'd need to side-load it into the autoUpdater.on('update-downloaded' electron event in the js ... you won't break debian since its self-contained.

mysticaltech commented 9 months ago

this is trivial just do something like this.

#!/bin/bash
VER=0.10.4
./cursor-${ver}.AppImage --appimage-extract
mv squashfs-root cursor-${ver}
mkdir -p cursor-${ver}/usr/local/cursor cursor-${ver}/usr/local/bin
mv cursor-${ver}/{*,.*} cursor-${ver}/usr/local/cursor
( cd cursor-${ver}/usr/local/bin/ && ln -s ../cursor/cursor . )
mkdir cursor-${ver}/DEBIAN
cat > cursor-${ver}/DEBIAN/control << ENDL
Package: cursor
Version: ${ver}
Architecture: all
Maintainer: nobody@nobody.com
Installed-Size: 158812254
Section: misc
Priority: optional
Description: cursor app
ENDL
dpkg-deb --build cursor-${ver}
# sudo dpkg -i cursor-${ver}.deb

there you go.

@kristopolous That's a cool trick, but not ideal to do everytime. And in a perfect world, there would be both an apt and yum repo.

You put it in the build script...

I'm a debian maintainer btw, I can get it inside of apt if you're really serious about it.

Ok, very good to know, thanks! I'm on Fedora, so used gpt-4 to convert that script to rpm, did not try it yet but will report back.

#!/bin/bash

# Define version
VER=0.10.4

# Extract the AppImage
./cursor-${VER}.AppImage --appimage-extract

# Move and rename the directory
mv squashfs-root cursor-${VER}

# Create directories
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
mkdir -p ~/rpmbuild/BUILDROOT/cursor-${VER}-1.x86_64/usr/local/cursor
mkdir -p ~/rpmbuild/BUILDROOT/cursor-${VER}-1.x86_64/usr/local/bin

# Move files
mv cursor-${VER}/{*,.*} ~/rpmbuild/BUILDROOT/cursor-${VER}-1.x86_64/usr/local/cursor/

# Create symbolic link
ln -s ../cursor/cursor ~/rpmbuild/BUILDROOT/cursor-${VER}-1.x86_64/usr/local/bin/cursor

# Create RPM spec file
cat > ~/rpmbuild/SPECS/cursor.spec << EOF
Name: cursor
Version: ${VER}
Release: 1%{?dist}
Summary: cursor app

License: Unknown
URL: http://example.com

%description
cursor app

%prep

%build

%install
cp -a \$RPM_BUILD_DIR/* \$RPM_BUILD_ROOT/

%files
/usr/local/cursor/*
/usr/local/bin/cursor

%changelog
EOF

# Build the RPM package
rpmbuild -bb ~/rpmbuild/SPECS/cursor.spec

# The RPM will be generated in ~/rpmbuild/RPMS/x86_64/
mysticaltech commented 9 months ago

I tried with a modified version of the above:

#!/bin/bash

# Define version
VER=0.10.4

# Clean up any previous extraction or build attempts
rm -rf squashfs-root cursor-${VER}
rm -rf ~/rpmbuild

# Extract the AppImage
./cursor-${VER}.AppImage --appimage-extract

# Move and rename the directory
mv squashfs-root cursor-${VER}

# Create directories
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}

# Move files to ~/rpmbuild/BUILD/ for alignment with RPM conventions
mv cursor-${VER} ~/rpmbuild/BUILD/cursor-${VER}

# Create RPM spec file
cat > ~/rpmbuild/SPECS/cursor.spec << EOF
Name: cursor
Version: ${VER}
Release: 1%{?dist}
Summary: cursor app

License: Cursor
URL: https://www.cursor.so/

%description
cursor app

%prep
# Unpack or prepare your files here, if applicable.

%build
# Build process here, if applicable.

%install
# Debugging output
echo "Listing BUILD directory:"
ls -la %{_builddir}

# Actual install commands
mkdir -p %{buildroot}/usr/local/cursor
mkdir -p %{buildroot}/usr/local/bin

cp -a %{_builddir}/cursor-${VER}/* %{buildroot}/usr/local/cursor/
ln -s ../cursor/cursor %{buildroot}/usr/local/bin/cursor

%files
/usr/local/cursor/*
/usr/local/bin/cursor

%changelog
* Wed Sep 27 2023 Karim Nuafal <rimkashox@gmail.com> - 0.10.4-1
- Initial RPM release
EOF

# Build the RPM package
rpmbuild -bb ~/rpmbuild/SPECS/cursor.spec

# If all goes well, the RPM should be generated in ~/rpmbuild/RPMS/x86_64/

It did succeed in building the RPM, but sadly, it's not using the same C lib, and it seems there is no easy way around this.

Wrote: /home/karim/rpmbuild/RPMS/x86_64/cursor-0.10.4-1.fc38.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.x2Ry6n
+ umask 022
+ cd /home/karim/rpmbuild/BUILD
+ /usr/bin/rm -rf /home/karim/rpmbuild/BUILDROOT/cursor-0.10.4-1.fc38.x86_64
+ RPM_EC=0
++ jobs -p
+ exit 0
Executing(rmbuild): /bin/sh -e /var/tmp/rpm-tmp.CHN717
+ umask 022
+ cd /home/karim/rpmbuild/BUILD
+ RPM_EC=0
++ jobs -p
+ exit 0

03:21:40 in ~/Downloads/cursor took 1m 55s 
➜ sudo dnf install /home/karim/rpmbuild/RPMS/x86_64/cursor-0.10.4-1.fc38.x86_64.rpm    
[sudo] password for karim: 
Last metadata expiration check: 3:06:56 ago on Fri 29 Sep 2023 12:15:31 AM CEST.
Error: 
 Problem: conflicting requests
  - nothing provides libc.musl-x86_64.so.1()(64bit) needed by cursor-0.10.4-1.fc38.x86_64 from @commandline
(try to add '--skip-broken' to skip uninstallable packages)

So it's a dead end for me now. Will wait for the official implementation that compiles from source properly to various targets.

mysticaltech commented 9 months ago

@truell20 FYI the above failed attempt. The key remains in your hands, as the package should be compiled from source. There seem to be no easy way around this. 🙏

mysticaltech commented 9 months ago

@truell20 Good news, there is an automatic way to do Source -> ALL DISTROS packages. Just use https://en.opensuse.org/Portal:Build_Service, it's distributed under a GPL license, meaning you can host the build service yourself without hassles.

Screenshot from 2023-09-29 03-46-40

mysticaltech commented 9 months ago

Here's the link to the project, they even provide an ISO to get started right away on any cloud instance: https://github.com/openSUSE/open-build-service

Here's the latest at the time of posting: https://download.opensuse.org/repositories/OBS:/Server:/2.10/images/iso/obs-server.x86_64-oem.iso

mysticaltech commented 9 months ago

Last but not least, when those packages are built, they will need hosting to be used by the various Linux package managers. For that, you can use: OpenRepo https://github.com/openkilt/openrepo

clayrisser commented 8 months ago

This is my install script I created that I've been using.

https://gitlab.com/bitspur/community/cody/-/blob/main/installers/cursor/linux-install.sh?ref_type=heads

IliaMManolov commented 5 months ago

Based on the above posts I wrote a slightly more complicated script that downloads and updates Cursor automatically (on x64 Linux systems). You can download it here. Let me know if there are any issues with it.

Note: I have hardcoded a lot of the links so the script is very unstable but it's better than having to manually update every other day. Hopefully we get official packages soon.

mysticaltech commented 5 months ago

Honestly, now the fact that the AppImage auto updates, I'm quite happy, better even than RPM.

ilhamprabuzakys commented 3 months ago

Hopefully we get deb and rpm package before GTA 6

mysticaltech commented 3 months ago

@ilhamprabuzakys I'm happy to report that the AppImage works decently enough for me, especially if you create a shortcut in your shell to launch it from the command line. I have an alias called cursor, I just write this in my shell and it opens, as many instances as you want and best of all it proposes you to update when a new update is here. I'm actually quite happy now.