Sublime Forum

Opening file from Linux cmd line always opens new window

#1

I’ve used sublime for about a year. I’m currently using version 3.1.1 in Fedora 26.

I usually open files for editing by using "subl ". Until recently, this would usually open them in the same window that was already open (the same “instance”). Now, no matter what I’ve tried, every time I use the command, it opens another window (instance) of Sublime.

Things I’ve tried:

  • Use “subl -a”
  • Use “subl -n”
  • Set “open_files_in_new_window” to False (even though that says for Mac only)
  • Set “hot_exit” to False
  • Set “remember_open_files” to False

None of those things make a difference…it keeps opening files into a new instance of Sublime.

Again, it USED to work as I wanted. But now it has stopped and I don’t understand why. Thanks for any help.

I’ll note, upon further testing, that when subl does open a new window, it contains the previously opened files as well. So if I’m already editing file “x.txt” in Sublime, and I execute “subl y.txt”, then a new instance of Sublime is created which contains tabs for both x.txt and y.txt.

1 Like

Running from command line always opens new window
#2

My understanding is that when you invoke Sublime (e.g. using subl) and it’s not currently running, a new instance is launched. From that point forward invocations communicate with the existing process to get them to perform the appropriate operation.

As such, seeing a new full instance launch when you run it (as evidenced by each window containing the previous session) when Sublime is already running would seem to be an indication that the communication to the existing instance is not working as expected.

My investigations lead me to believe that Sublime is using dbus as the communication method (at least under Linux), and in particular it uses the dbus session bus for this.

As seen here via qdbusviewer, when I have Sublime 2 and Sublime 3 running, there are two services listed on the session bus; terminating either one drops that particular service from the list as one would expect.

This said, one possible vector to check out would be if dbus is operating properly:

tmartin:dart:~> qdbus com.sublimetext.three
Service 'com.sublimetext.three' does not exist.
tmartin:dart:~> subl
tmartin:dart:~> qdbus com.sublimetext.three
/
/cmdline
4 Likes

A new session restored for each sublime_text command
Open files in new tab rather than new window
#5

Well ok…I was wrong. It’s not Fedora. My local computer is Fedora but then I ssh into the computer I run sublime on, and it is RHEL 6.10.

On my local computer (Fedora), then executing subl twice with two different files does open them both in the same window. In the remote computer (RHEL 6) it still opens a new window.

Executing the qdbus command you suggested on the remote server gave me this:
Could not connect to D-Bus server: org.freedesktop.DBus.Error.Spawn.ExecFailed: /bin/dbus-launch terminated abnormally without any error message

That is perhaps the problem?

0 Likes

#6

Ha, that was it! I googled that error message and saw someone mentioning explicitly installing dbus-x11. I did that, and it now works! They all open into the same sublime window.

I couldn’t have found this without your dbus info, so thank you very much!

This explains why it USED to work. The machine I run sublime on was rebuilt recently and clearly dbus-x11 isn’t a part of the base image. At some point in the past it must have been installed, and that’s why it used to work. I’ll make sure to add it as a standard install item.

1 Like

#7

Ok, there might still be something going on, because occasionally I’ll still run into this problem and when I run the qdbus command I get something about not running on boot was built at compile time, or something like that (not the same error I got originally). Either way…I’m going to say it’s not a Sublime problem. Thanks for the help!

0 Likes