Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript Layer Could not start tern server (On Windows) #5733

Closed
garvinguan opened this issue Apr 8, 2016 · 15 comments
Closed

Javascript Layer Could not start tern server (On Windows) #5733

garvinguan opened this issue Apr 8, 2016 · 15 comments

Comments

@garvinguan
Copy link

Description

From an initial installation of Spacemacs v.0.105.16 javascript layer, Emacs tries to find the tern server from the same directory the js file is in. (This is the same for js files in other projects it will look for tern in ./tern directory).

I tried putting the below code in my private layer and also in dotspacemacs/user-config so Emacs would be able to find tern and Tern for javascript was working pre-spacemacs (when I was using my normal evil+emacs). However with spacemacs javascript layer, completion in a js file results in this kind of error

(add-to-list 'load-path "D:/ProgramFiles/tern/emacs/")
(autoload 'tern-mode "tern.el" nil t)
(add-hook 'js2-mode-hook (lambda () (tern-mode t)))

I tried reinstalling node and npm and recloning tern (and npm install'd it) but still the error occurs so I think it may be something with the javascript layer.

Reproduction guide

  • Fresh install Spacemacs v.0.105.16 (on Windows, haven't tried with Linux yet)
  • Follow javascript layer installation rules (npm install -g tern)
  • Try completion in a js file

Note

  • I can get it working by starting the tern server in the root of project

  • Tern works with pre-spacemacs set up using company-tern

    (add-to-list 'company-backends 'company-tern)
    
@syl20bnr
Copy link
Owner

syl20bnr commented Apr 8, 2016

I think this is due to the default value of javascript-disable-tern-port-files https://github.com/syl20bnr/spacemacs/blob/develop/layers/+lang/javascript/config.el#L16-L17

If this is the issue I am ok the set the default to nil.

@garvinguan
Copy link
Author

Unfortunately, changing javascript-disable-tern-port-files to nil and restarting Emacs did not fix the issue. http://i.imgur.com/Nb4Lenn.png

@ghost
Copy link

ghost commented Apr 9, 2016

I have the same problem on windows.

@svatem1
Copy link

svatem1 commented Apr 15, 2016

add param tern-command in dotspacemacs-configuration-layers like this:

(javascript :variables tern-command '("node" "c:/users/someuser/appdata/roaming/npm/node_modules/tern/bin/tern"))

as a workaround

@garvinguan
Copy link
Author

@svatem1 @dotneter- @syl20bnr the workaround fixes it, it may be a good idea to possibly add that to the javascript layer README

@StreakyCobra
Copy link
Contributor

PR welcome 😉

@svatem1
Copy link

svatem1 commented Apr 18, 2016

it'd be better (& probably very easy for someone proficient with elisp & emacs) to solve the actuall problem , tern executable is visible & in PATH, there's no reason for any sw to expect anything more (or to behave dumber than DOS back then)..

@StreakyCobra
Copy link
Contributor

@svatem1 Probably, but this is an upstream issue, not something we should hack on Spacemacs side, right?

@svatem1
Copy link

svatem1 commented Apr 18, 2016

are they rejecting patches? do they feel they have a problem? doesn't seem so
does "spacemacs" want to work out of the box or does it want to have alibi for "feature a doesn't work"?
if i knew anything about elisp/emacs i guess this would be complete triviality to fix

@StreakyCobra
Copy link
Contributor

@svatem1 I'm not doing javascript, but I read the linked threads and this is what I understood:


First regarding the executable:

  • The tern executable is needed in order to have tern support in emacs.
  • The tern executable is not shipped through MELPA.

So as for other external tools, you have to install it first on your system before using it from emacs.


Second, regarding the problem of the executable not being found:

As it was reported, setting tern-command fixes the issue, so it's because the tern-command variable is not guessed correctly. This happens because upstream only supports installation via the same structure as the Github repository, not when tern and tern.el are installed separately. Hopefully they will accept help to fix this.

The code responsible for this is here. They are searching for the ../bin/tern program but are not trying to find it in the PATH for split installation.


To conclude:

Handling the tern-command variable correctly for splitted (MELPA) installation should ideally be fixed upstream. The fix would be the same than at Spacemacs level anyway, so it would be better to patch it upstream, it will allow other emacs users to profit of the improvement.

@svatem1
Copy link

svatem1 commented Apr 18, 2016

@StreakyCobra I don't think this problem has ever been about tern executable not being present on system.. not here, not in the other thread (their reasoning for closing the thread with "tern.el in MELPA is shipped without tern executable" is weird at best)

you're completery right about what you say regarding PATH (concept that's with us since ever, on DOS, on Linux, on Windows) & advantages of upstream being the one fixing it

what I'm trying to say is - adding those 2 lines (that'll handle PATH) to the code snippet you linked is a minute work for somebody who's speaking elisp & emacs; notifying them via referencing the thread might take a longer time and might end with the same conclusion as last time

@StreakyCobra
Copy link
Contributor

I don't think this problem has ever been about tern executable not being present on system.. not here, not in the other thread (their reasoning for closing the thread with "tern.el in MELPA is shipped without tern executable" is weird at best)

Yeah, I was writing my thoughts while reading about the problem, sorry for the noise.

what I'm trying to say is - adding those 2 lines (that'll handle PATH) to the code snippet you linked is a minute work for somebody who's speaking elisp & emacs;

I'm not sure it will requires only 2 lines 😉 but for sure it will require more than one minutes to do it properly and to be sure to handle all cases.

notifying them via referencing the thread might take a longer time and might end with the same conclusion as last time

The conclusion of the linked threads was "need help", so it's not a matter of time but of people tackling the problem. I don't really have time, I can't test the edges cases as I don't have windows and the default setup is working on my computer. So… wait for someone else tackling the problem now that it has been clearly stated, or try to work on it yourself :-)

@svatem1
Copy link

svatem1 commented Apr 18, 2016

@StreakyCobra i'm actually really happy someone shed light on this! the more polished Spacemacs experience is, the better

@corintho
Copy link

I think this is more related to the problem here: ternjs/tern#256
Not sure which version of tern plugin is used in the spacemacs layer, but if its updated and if you have tern globally installed, it should "just work" on windows.
As for a workaround, I'm currently using (setq tern-command '("tern")) which works with globally installed tern on any platform.

@TheBB
Copy link
Collaborator

TheBB commented Sep 22, 2016

Assuming due to the lack of movement here and the claims made in the linked issue that this is indeed fixed. If not, let us know.

@TheBB TheBB closed this as completed Sep 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants