Sublime Forum

Modern Instalation - snap package

#1

Hi

I am using Sublime for last three years. I was recently playing with vscode/atom and I would love to see some ideas to be ported into Sublime Text. In particular installation process could be streamlined.

In VSCode:

sudo snap install --classic vscode
code --install-extension Shan.code-settings-sync

In Atom

sudo snap install atom --classic
apm install sync-settings

In Sublime

wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
echo "deb https://download.sublimetext.com/ apt/dev/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update -qq
sudo apt-get install sublime-text -y

PACKAGE_MANAGER_URL="https://packagecontrol.io/Package%20Control.sublime-package"
PACKAGE_MANAGER_DIR="/home/$USER/.config/sublime-text-3/Installed Packages/"
wget "${PACKAGE_MANAGER_URL}" -P "${PACKAGE_MANAGER_DIR}"
ln -sfv $DIR/../sublime/Package\ Control.sublime-settings ~/.config/sublime-text-3/Packages/User/Package\ Control.sublime-settings
2 Likes

When will the snap package be released for Linux?
#2

We were contacted by Canonical about snaps, but it seemed that originally they weren’t designed for commercial software. I’m not sure if this has been resolved or changed? There was also the issue that snaps were pushing sandboxed environments, which would completely change how Sublime Text sees the file system, and communicates with the outside world. I don’t know if those are still being pushed, but interest in pursuing snaps declined because it was trying to be much more than packaging.

Instead we built out a robust set of repositories that cover more distros than snapcraft does, with the exception of Gentoo. However, it appears the snapcraft system for Gentoo is outdated anyway.

If you are using a modern .deb-based system, I think you can skip manually adding the apt-key, as I think it should prompt you when you update after adding our apt repo. I didn’t want to write instructions for all different versions of Ubuntu and Debian, hence the least common denominator instructions.

You can remove the three lines including wget for installing Package Control by just running the “Install Package Control” command from the command palette.

I think in the end this leaves:

  1. Add the repo
  2. Update
  3. Install
  4. Link your settings
  5. Install Package Control

Using snap would mean:

  1. Install a snap
  2. Link your settings
  3. Install Package Control

I don’t know if adding another package management system that is mostly third-party is worth the effort right now. I think snapcraft needs some more time to mature to see if it will be another Canonical project that goes away when it doesn’t become the de-facto solution.

Some other side effects include no longer have control over the distribution of our software since Canonical needs to approve updates. I presume also that means that binaries are not served from our server. The documentation alludes to the ability of running your own snap Store instead of being ties to Canonical, but it leads to https://github.com/noise/snapstore/.

1 Like

#3

snap with --classic flag has more access to file system. Both vscode and atom work using “classic” snaps.
Snaps also aim to work across different distributions. You can have the single snap that can be installed pretty much everywhere. I can see JetBrains products as snaps as well, I do not know if there any comercial limitation.

I agree that snap needs more time to mature but the user experience is already better.
Maybe you can put snap package in roadmap after Ubuntu 18.10. You will see how serious Ubuntu is about snap.

Another thing, build in package manager and installation packages from the command line.
Currently, almost all text editors have package manager included. I do not understand why Sublime is different.

I would be willing to pay an extra dollar per year if my licence key would cover autosync my settings.
Since this is commercial software anyway and every license holder already have an account, why not?
I do not want to work with a brittle symlink, Dropbox backup or git merge conflicts on my settings.

Perfect flow for Sublime:

snap install sublime-text --classic

Insert license key or login, everything is synced.

0 Likes

#4

I put together the initial snap packaging for Sublime Text and published that under the account snapcrafters which is a community effort, a stop-gap, until things get integrated upstream.

The current approach downloads the officially released tar.gz file and puts that in a snap. With classic confinement, the app is able to read everything on the file system (something that is definitely required by a text editor).

I did a ‘call for testing’ and the results were great (basically no withstanding issues).

you can try:
$ snap install sublime-text-3 --classic --edge

@wbond I am willing to help in anyway possible to get sublime-text officially released as snap.

The packaging lives here: https://github.com/snapcrafters/sublime-text/blob/master/snap/snapcraft.yaml

Note: I am not associated with Canonical and doing that voluntarily.

1 Like

#5

A few advantages of using snaps as we stand today.

  • Installing developer builds becomes very easy, for example
    $ snap install sublime-text --classic --channel=edge
    will give us latest dev build.
  • We can make use of ‘tracks’ that will give us access to older version of sublime, for example
    $ snap install sublime-text --classic --channel=2/stable
    will install stable release of the 2 series.

Also a sidenote: I believe we don’t really need to get reviews from Canonical each time a new release is uploaded, its just a one-time effort to

  1. Claim the name sublime-text (I can help with that)
  2. Request classic confinement (So that this snap can read/write system-wide filesystem as it does currently in non-snap installs. I can help with that as well.)
  3. Get a ‘track’ named 2 created so that we can have parallel releases under a single name.
0 Likes

#6

On a practical level, these things are things that would have to be figured out:

  1. What software has to be installed/configured on an Ubuntu 16.04 server to generate a snap file?
  2. If we have a directory of files that make up Sublime Text, what would be a shell script that would generate a snap?
  3. How are snaps distributed? Is this something we can serve from our own download server?
  4. All of our linux distribution channels have parallel stable/dev configurations, which leaves the software package as just sublime-text in all situations. How would users subscribe to different snap channels for the dev/stable releases?
  5. And the elephant in the room: what about flatpak? Is it expected linux software should support deb, rpm, pkg.xz, tar.bz2, snap and flatpak?
0 Likes

#7

We need the tool snapcraft to produce a snap build. On Ubuntu 16.04 server(assuming all updates are installed) just run
$ snap install snapcraft --classic[quote=“wbond, post:6, topic:31123”]
If we have a directory of files that make up Sublime Text, what would be a shell script that would generate a snap?
[/quote]
Once we have the snap packaging in place i.e. snap/snapcraft.yaml on the root of the project source, the shell script could just be as simple as
$ cd sublime_text_source_root $ snapcraft

The bigger question however is what should that yaml file look like. Access to the source code would of course be the easiest way BUT since that is not an option, access to debian packaging would be helpful, especially the debian control file, so that we can update the snapcraft.yaml file accordingly (dependencies etc).

Another option is to just put this snapcraft.yaml inside a snap directory of the root of prebuilt source and run command snapcraft[quote=“wbond, post:6, topic:31123”]
How are snaps distributed? Is this something we can serve from our own download server?
[/quote]

My knowledge on that subject is limited will check with upstream and report back here.

Though I do know that some commercial and closed-source softwares like PyCharm professional (and almost all the tools from jetbrains), Skype and Spotify are already releasing on the default, Canonical provided store.[quote=“wbond, post:6, topic:31123”]
All of our linux distribution channels have parallel stable/dev configurations, which leaves the software package as just sublime-text in all situations. How would users subscribe to different snap channels for the dev/stable releases?
[/quote]
At a given time we can have a single copy of the software installed, so if I installed from the stable channel using below command
$ snap install sublime-text --classic --channel=stable
and later wanted to switch to the daily/nighly build, I can just do
$ snap refresh sublime-text --classic --channel=edge[beta, candidate]

In an ideal world there would be a single linux package but we are not there yet, (difference of opinion, politics etc). But I do see things going in a better direction in the coming years and the traction I have seen regarding snaps in encouraging (biased ?).

EDIT
seems I can’t create a new comment, just wanted to highlight that sublime-text is now published as a snap to the stable channel.
$ sudo snap install sublime-text --classic

I hope this becomes “official” snap soon.

2 Likes

#8

Why do the executables in the snaps differ from the executables in the tarballs that the snap creation (according to snapcraft.yaml) extracts them from?

0 Likes

#9

@wbond It seems that Ubuntu would continue with snap. Any chance for official snap support ?

2 Likes