ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
803 stars 54 forks source link

Not working for Sublime Text 3 #22

Closed mrtnbroder closed 10 years ago

mrtnbroder commented 11 years ago

Installed this via Packages Control ( Also tried manually ) but it always says "It appears Tern has not been installed...".

I think it's because how ST3 handles packages now.

jkroso commented 11 years ago

working fine for me with a manual install. on OSX

mrtnbroder commented 11 years ago

Not for me. Maybe because I symlinked my Packages Folder to Dropbox.

varemenos commented 11 years ago

Not working for me either using latest ST3 build on Windows 8 x64 trying to install it via package manager.

mrtnbroder commented 11 years ago

any updates on this? I find this plugin pretty useful.

marijnh commented 11 years ago

Well, um, did you try not symlinking to dropbox, but doing a manual install checkout and npm install somewhere local?

wtw commented 10 years ago

Had some problems myself using ST3 on OS X, partly because there is no real "success" indicator (other then tern working of course), e.g. no dedicated package settings file showing up in the menu that reassures you that the plugin is installed and working. There are basically two ways I got it working (I prefer the second one):

Use Package Control and a globally installed tern

Clone tern manually into your Packages folder (preferred)

marijnh commented 10 years ago

What happened with the automatic installation that the plugin tries to do the first time it starts without being able to find Tern? It simply npm installs Tern in your packages folder, much like your second set of instructions.

wtw commented 10 years ago

Didn't work for me, clicking „Yes, install“ gave no feedback and some time later on the same window appeared. However, I did not look into that further but tried to configure it by hand. Is the automatic installation supposed to work with the default tern_command setting, so you can omit that setting completely? Just wondering, as installing the package via Package Control doesn't create a tern_for_sublime folder in the Packages folder but instead install the package to Installed Packages.

Edit: Tried it out and no folder was created inside Packages (got node and npm installed and available). After a restart, the dialog was shown again.

marijnh commented 10 years ago

The Python code uses os.path.abspath(os.path.dirname(__file__)) to figure out where it's installed, so I don't think the difference between Packages and Installed Packages should matter.

jkroso commented 10 years ago

if there is a file in "installed packages" called tern something I would try deleting it. I've done that with other plugins with success. I think I reinstalled the plugins afterwards or something too but yea..

varemenos commented 10 years ago

Automatic installation doesn't work for me either (though I gave up trying due to final exam period) There is nothing named in the "installed packages" that's either called or contains tern

wtw commented 10 years ago

If you install via Package Control, there should be a file called tern_for_sublime.sublime-package. Those are ZIP archives, you can (rename and) extract them. Could very well be that the automatic installation of tern fails in this situation.

marijnh commented 10 years ago

Package control zips the package? Well, yes, that'll obviously cause trying to run npm install in the package directory to fail. Is there a way to turn that behavior off?

wtw commented 10 years ago

It seems you can drop a .no-sublime-package file in your project:

Author of package control on this matter.

marijnh commented 10 years ago

That's useful. Added in attached commit.

varemenos commented 10 years ago

npm install still doesn't run after installing the package that includes .no-sublime-package (Windows 8 x64, npm is in PATH)

wtw commented 10 years ago

For me the installation via Package Control including npm installing tern works as expected now (I'm on OS X though, could be a Windows specific bug).

orenmizr commented 10 years ago

tried manually\auto installing - failed on win7/st2. even when all the files are in the package and npm installs tern - sublime just doesn't want to complete anything.

marijnh commented 10 years ago

Any python error messages in the ctrl-backtick console?

orenmizr commented 10 years ago

i did a lot of steps to make it work: 1) manually insall via git & npm install 2) changed the folder name 3) auto install via package manager 4) copy all files from the manual install to the new folder 4) run the cmd file that runs the port

--> i got the autocompletion to work. it was a lot slower that TernJS and didn't seem to contribute more --> uninstalled it.

what i really wanted is adobe's brackets editor tern implementation. it is flawless. why doesn't tern complete $("x"). expressions?

marijnh commented 10 years ago

why doesn't tern complete $("x").

It does, if you tell it to load the jQuery definitions.

Anyway, yes, the Sublime Text plugin needs an experienced Sublime Text user to properly maintain and polish it. I put it out there as a rough draft, but I use Emacs, so I have neither the expertise nor the personal involvement to really perfect this.

OliverJAsh commented 10 years ago

In my console I’m getting the following error:

Traceback (most recent call last):
  File "/opt/homebrew-cask/Caskroom/sublime-text3/3047/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 157, in on_api_ready
    m.plugin_loaded()
  File "/Users/Oliver/Library/Application Support/Sublime Text 3/Packages/tern_for_sublime/tern.py", line 495, in plugin_loaded
    subprocess.check_output(["npm", "install"], cwd=plugin_dir)
  File "X/subprocess.py", line 571, in check_output
  File "X/subprocess.py", line 818, in __init__
  File "X/subprocess.py", line 1416, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: 'npm'

npm is installed.

marijnh commented 10 years ago

But is it also in your the $PATH that sublime text sees?

OliverJAsh commented 10 years ago

It's in my $PATH, but I'm not sure if Sublime uses the $PATH defined in my shell setup.

❯ which npm
/usr/local/bin/npm
marijnh commented 10 years ago

If you go to the console (ctrl-backtick) in ST and run this, you should be able to check:

import os
os.getenv("PATH")
OliverJAsh commented 10 years ago

Ended up needing https://github.com/int3h/SublimeFixMacPath. Thanks.

marijnh commented 10 years ago

Oh, that's good to know. I'll keep it in mind next time someone has this problem.

mladenuzelac commented 9 years ago

I have the same problem with Sublime text 3 and windows 7 x64

SAnDAnGE commented 9 years ago

@mladenuzelac add (adjusting path) "tern_command":["node", "C:/Users/blabla/AppData/Roaming/npm/node_modules/tern/bin/tern", "--no-port-file"] to your Preferences -> Settings - User file.

OliverJAsh commented 9 years ago

Is it worth adding a step for Mac users to install https://github.com/int3h/SublimeFixMacPath in the README? It's just caught me out again, reinstalling.

marijnh commented 9 years ago

Attached patch adds a short note about this.

ourmaninamsterdam commented 9 years ago

:+1: SublimeFixMacPath fixes it for me. Cheers

todor2810 commented 8 years ago

Still having trouble making autocomplete to work (I'm using Linux Mint 17.2 Cinnamon and ST3 Build 3114).

I tried installing it both manually and via the Package Manager. I added "auto_complete_triggers": [ {"selector": "text.html", "characters": "<"}, {"selector": "source.js", "characters": "."} ] to my Preferences file. I set:

"tern_argument_hints",
"tern_argument_completion",
"auto_complete"

to true. I followed @wtw's advice by adding a .tern-port file all to no avail.

I also cleaned npm's cache and then updated both npm and minimatch.

Edit: Autocompletion wasn't working for me because I was missing the .tern-config file in my home directory. Here are contents of the file:

{
  "libs": ["browser", "ecmascript"]
}
noxecane commented 7 years ago

By the way I think this fixes the path issue for those not on Mac