DisposaBoy / GoSublime

A Golang plugin collection for SublimeText 3, providing code completion and other IDE-like features.
MIT License
3.42k stars 299 forks source link

GoSublime freezes Sublime Text on startup #592

Closed johanwikstrm closed 6 years ago

johanwikstrm commented 9 years ago

When installing GoSublime using package control on a fresh install of Sublime Text 3, it immediately gets stuck in an infinite loop and freezes sublime text. I really need gosublime, it's such a great tool. What could be causing this?

$ cat /proc/version 
Linux version 3.2.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.63-2+deb7u2

$ subl -v
Sublime Text Build 3065

$ go version
go version go1.4 linux/amd64

$ go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/johan/fb/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
johanwikstrm commented 9 years ago

I also tried gosublime on sublime text 2 with the same results. It immediately hangs sublime text.

DisposaBlackSwan commented 9 years ago

First thing to try is to delete all traces of GS from your Packages and Installed Packages directories, then install using git: git clone --depth 1 https://github.com/DisposaBoy/GoSublime ~/.config/sublime-text-3/Packages/GoSublime

johanwikstrm commented 9 years ago

Yes did it now, got the same result. sublime text completely freezes on startup screenshot from 2015-01-09 15 21 09

DisposaBlackSwan commented 9 years ago

The only thing I can think of is that there are multiple copies of the plugin on your system. After you delete traces of GS the command find ~/.config/sublime-text-3 -name '*GoSublime*' should not output anything. Also to be sure, try again:

johanwikstrm commented 9 years ago

Did it again and more carefully, unfortunately with no better result. I also uninstalled PC so it wouldn't interfere.

$ killall sublime_text
$ cd ~
$ find ~/.config/sublime-text-3 -name '*GoSublime*'
/home/johan/.config/sublime-text-3/Cache/GoSublime
/home/johan/.config/sublime-text-3/Cache/GoSublime/GoSublime.tmLanguage.cache
/home/johan/.config/sublime-text-3/Cache/GoSublime/syntax/GoSublime-9o.tmLanguage.cache
/home/johan/.config/sublime-text-3/Cache/GoSublime/syntax/GoSublime-Go.tmLanguage.cache
/home/johan/.config/sublime-text-3/Cache/GoSublime/syntax/GoSublime-HTML.tmLanguage.cache
/home/johan/.config/sublime-text-3/Cache/GoSublime/syntax/GoSublime-Template.tmLanguage.cache
/home/johan/.config/sublime-text-3/Cache/GoSublime/GoSublime-next.tmLanguage.cache
/home/johan/.config/sublime-text-3/Packages/GoSublime
/home/johan/.config/sublime-text-3/Packages/GoSublime/GoSublime.py
/home/johan/.config/sublime-text-3/Packages/GoSublime/GoSublime.tmLanguage.json
/home/johan/.config/sublime-text-3/Packages/GoSublime/GoSublime-next.tmLanguage
/home/johan/.config/sublime-text-3/Packages/GoSublime/GoSublime.sublime-commands
/home/johan/.config/sublime-text-3/Packages/GoSublime/GoSublime.tmLanguage
/home/johan/.config/sublime-text-3/Packages/GoSublime/settings/GoSublime-Go.sublime-settings
/home/johan/.config/sublime-text-3/Packages/GoSublime/syntax/GoSublime-HTML.tmLanguage
/home/johan/.config/sublime-text-3/Packages/GoSublime/syntax/GoSublime-Template.tmLanguage
/home/johan/.config/sublime-text-3/Packages/GoSublime/syntax/GoSublime-9o.tmLanguage
/home/johan/.config/sublime-text-3/Packages/GoSublime/syntax/GoSublime-9o.tmLanguage.json
/home/johan/.config/sublime-text-3/Packages/GoSublime/syntax/GoSublime-HTML.tmLanguage.json
/home/johan/.config/sublime-text-3/Packages/GoSublime/syntax/GoSublime-Go.tmLanguage.json
/home/johan/.config/sublime-text-3/Packages/GoSublime/syntax/GoSublime-Template.tmLanguage.json
/home/johan/.config/sublime-text-3/Packages/GoSublime/syntax/GoSublime-Go.tmLanguage
/home/johan/.config/sublime-text-3/Packages/GoSublime/GoSublime.sublime-build
/home/johan/.config/sublime-text-3/Packages/GoSublime/GoSublime.sublime-settings
/home/johan/.config/sublime-text-3/Packages/User/GoSublime
$rm -r -f .config/sublime-text-3/Packages/GoSublime/
$rm -r -f .config/sublime-text-3/Packages/User/GoSublime/
$rm -r -f .config/sublime-text-3/Cache/GoSublime/
$ find ~/.config/sublime-text-3 -name '*GoSublime*'
$ git clone --depth 1 https://github.com/DisposaBoy/GoSublime ~/.config/sublime-text-3/Packages/GoSublime
Cloning into '/home/johan/.config/sublime-text-3/Packages/GoSublime'...
p11-kit: invalid config filename, will be ignored in the future: /etc/pkcs11/modules/gnome-keyring-module
remote: Counting objects: 170, done.
remote: Compressing objects: 100% (158/158), done.
remote: Total 170 (delta 13), reused 123 (delta 7)
Receiving objects: 100% (170/170), 321.84 KiB | 195 KiB/s, done.
Resolving deltas: 100% (13/13), done.

And I could not find anything special in the sublime text console before pulling from git.

DPI scale: 1
startup, version: 3065 linux x64 channel: stable
executable: /opt/sublime_text/sublime_text
working dir: /
packages path: /home/johan/.config/sublime-text-3/Packages
state path: /home/johan/.config/sublime-text-3/Local
hardware concurrency: 4
zip path: /opt/sublime_text/Packages
zip path: /home/johan/.config/sublime-text-3/Installed Packages
found 3 files for base name Default.sublime-keymap
found 1 files for base name Default.sublime-mousemap
found 1 files for base name Main.sublime-menu
generating syntax summary
generating meta info summary
loading bindings
loading pointer bindings
found 1 files for base name Default.sublime-theme
theme loaded
app ready
wrote startup cache, added files: 2 orphaned files: 7 total files: 167 cache hits: 165
pre session restore time: 0.115643
using gamma: 1 (err: 0)
startup time: 0.21307
first paint time: 0.241006
launching: /opt/sublime_text/plugin_host
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_file_settings
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
plugins loaded
loaded 837 snippets
DisposaBlackSwan commented 9 years ago

Is that same file always being opened? try

cd ~/.config/sublime-text-3/Packages/GoSublime
rm *.py

Open ST3. If it still freezes it's likely something to do with the syntax files, settings files, or some setting in your ST3 session. In this case remove/rename ~/.config/sublime-text-3, re-clone/copy GoSublime back to ~/.config/sublime-text-3/Packages/GoSublime and try again. If that works, we know it's something to do with the session.

If it doesn't crash after deleting the python files try disabling loading of the modules.

restore the files

git checkout .

Open GoSublime.py and add a return to the to the top of the plugin_loaded() function so it looks like below, save and re-open ST3

def plugin_loaded():
    return
    from gosubl import about
johanwikstrm commented 9 years ago

Yes, sublime text doesn't hang when I remove all .py files and it doesn't hang when I add

def plugin_loaded():
    return
    from gosubl import about
johanwikstrm commented 9 years ago

This for loop appears to be the problem. If I place the return after this loop, sublime text hangs

 for mod_name, mod in mods:
    print('GoSublime %s: init mod(%s)' % (VERSION, mod_name))

    try:
        mod.gs_init({
            'version': VERSION,
            'ann': ANN,
            'margo_exe': MARGO_EXE,
        })
    except TypeError:
        # old versions didn't take an arg
        mod.gs_init()
johanwikstrm commented 9 years ago

And when I comment out this line, it also stops hanging

mods = [
    ('gs', gs),
    #('sh', sh),
    ('mg9', mg9),
]
DisposaBlackSwan commented 9 years ago

That would prevent calling gs_init function in gosubl/sh.py. I don't see anything in there that stands out, unless calling the shell function hangs

johanwikstrm commented 9 years ago

Indeed, it seems this function hangs

cr = ShellCommand(cmd_str).run()

I assume it runs the string as a command on some shell? If I replace the row with

cr = ShellCommand('').run()

it doesn't hang, but if I replace it with

cr = ShellCommand('ls').run()

it still hangs. So I suppose it will hang on any command but the empty string...

zane-techempower commented 9 years ago

Any further word on this? GoSublime broke my Sublime text, I've tried installing it in fresh copies of Sublime Text 2 and 3 with the same result. Tried limited depth clone as well.

Really upsetting as Sublime+GoSublime is the best way to edit Go code...

asergeyev commented 9 years ago

Well... Not sure if it'll help anyone but I observed similar freezing today and apparently it has something to do about gocode being in your PATH and/or other dependencies needed for gosublime's configuration

kummerer94 commented 9 years ago

I experience the same thing on Win 7 when trying to go run or any other command via ctrl + b.

It always appears right after I start to write the m in go run m (for I have a main.go file).

There is nothing in the logs.

This is my startup output:

GoSublime init r14.12.06-1 (0.001s)
|   install margo: no
|   install state: done
| sublime.version: 3083
| sublime.channel: stable
|       about.ann: a14.02.25-1
|   about.version: r14.12.06-1
|         version: r14.12.06-1
|        platform: windows-x64
|            ~bin: ~\AppData\Roaming\Sublime Text 3\Packages\User\GoSublime\windows-x64\bin
|       margo.exe: ~bin\gosublime.margo_r14.12.06-1_go1.5.1.exe (ok)
|          go.exe: C:\Go\bin\go.exe (ok)
|      go.version: go1.5.1
|          GOROOT: C:\Go\
|          GOPATH: C:\Go\
|           GOBIN: (not set) (should usually be `(not set)`)
|       set.shell: []
|       env.shell:
|       shell.cmd: ['C:\\Windows\\system32\\cmd.exe', '/C', '${CMD}']
--------------------------------
pietv commented 8 years ago

I'm experiencing the same freezing with ST3 3103 and the latest GoSublime (installed with git clone https://github.com/DisposaBoy/GoSublime today) on Mac OS X 10.11.3.

Commenting out the #('sh', sh) line helped, thanks @johanwikstrm! But that doesn't seem to be the proper solution. What would the proper solution be? Or are you welcoming a PR?

I suspect this might have something to do with that many of my shell utilities (like cat or ls) are links, but I haven't investigate it yet.