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

LookupError: unknown encoding: with typescript #3101

Closed
12 tasks done
dhleong opened this issue Aug 3, 2018 · 1 comment · Fixed by ycm-core/ycmd#1075
Closed
12 tasks done

LookupError: unknown encoding: with typescript #3101

dhleong opened this issue Aug 3, 2018 · 1 comment · Fixed by ycm-core/ycmd#1075

Comments

@dhleong
Copy link
Contributor

dhleong commented Aug 3, 2018

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) before filing your issue:

  • I have read and understood YCM's [CONTRIBUTING][cont] document.
  • I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
  • I have read and understood YCM's [README][readme], especially the
    [Frequently Asked Questions][faq] section.
  • I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. ([Example Google
    search.][search])
  • If filing a bug report, I have included the output of vim --version.
  • If filing a bug report, I have included the output of :YcmDebugInfo.
  • If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • If filing a bug report, I have included a minimal test case that reproduces
    my issue, including what I expected to happen and what actually happened.
  • If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt gift of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

After the recent changes to typescript support, any YCM command just prints the error LookupError: unknown encoding:

  • What did you do?

    • I had previously installed typescript via npm in the same manner as described in the readme. I did update it from 2.8.3 to the latest when I first encountered this issue, but to no avail
    • Repro is simply to open any typescript file and see that none of the usual YCM features work
  • What did you expect to happen?

    • I expected YCM to work for typescript files
  • What actually happened?

    • Using YcmCompleter commands result in the error message noted above
  • Also

    • Commenting out the parts of TsserverCommand() that try to read from PATH_TO_TSSERVER fixes everything—YcmDebugInfo prints all the correct info about TSServer and everything.
    • Opening the tsserver file in a separate python repl (the same one pointed to by YcmDebugInfo) seems to work okay
    • I did recently install python3 from homebrew, which is somewhat new; I know MacVim has historically had some issues when trying to use both python3 and python2. But, echo has('python3') prints 0, for what it's worth. And, as mentioned, everything works fine if I just blindly suppress the error.

Wrapping that bit in a try...except and defaulting to return [ PATH_TO_TSSERVER ] also works as a bandaid for me.

Diagnostic data

Output of mvim --version

VIM - Vi IMproved 8.1 (2018 May 17, compiled Jun 17 2018 23:04:26)
macOS version
Included patches: 1-72
Compiled by travis@Traviss-Mac-1044.local
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl               +farsi             +mouse_netterm     +tag_binary
+arabic            +file_in_path      +mouse_sgr         +tag_old_static
+autocmd           +find_in_path      -mouse_sysmouse    -tag_any_white
-autoservername    +float             +mouse_urxvt       -tcl
+balloon_eval      +folding           +mouse_xterm       +termguicolors
+balloon_eval_term -footer            +multi_byte        +terminal
+browse            +fork()            +multi_lang        +terminfo
++builtin_terms    +fullscreen        -mzscheme          +termresponse
+byte_offset       -gettext           +netbeans_intg     +textobjects
+channel           -hangul_input      +num64             +timers
+cindent           +iconv             +odbeditor         +title
+clientserver      +insert_expand     +packages          +toolbar
+clipboard         +job               +path_extra        +transparency
+cmdline_compl     +jumplist          +perl/dyn          +user_commands
+cmdline_hist      +keymap            +persistent_undo   +vertsplit
+cmdline_info      +lambda            +postscript        +virtualedit
+comments          +langmap           +printer           +visual
+conceal           +libcall           +profile           +visualextra
+cryptv            +linebreak         +python/dyn        +viminfo
+cscope            +lispindent        +python3/dyn       +vreplace
+cursorbind        +listcmds          +quickfix          +wildignore
+cursorshape       +localmap          +reltime           +wildmenu
+dialog_con_gui    +lua/dyn           +rightleft         +windows
+diff              +menu              +ruby/dyn          +writebackup
+digraphs          +mksession         +scrollbind        -X11
+dnd               +modify_fname      +signs             -xfontset
-ebcdic            +mouse             +smartindent       +xim
+emacs_tags        +mouseshape        +startuptime       -xpm
+eval              +mouse_dec         +statusline        -xsmp
+ex_extra          -mouse_gpm         -sun_workshop      -xterm_clipboard
+extra_search      -mouse_jsbterm     +syntax            -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework AppKit   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE      

Output of YcmDebugInfo

Printing YouCompleteMe debug information...
-- Client logfile: /var/folders/9q/s674cplx7qv122xbwcchw3jm0000gn/T/ycm_DTVqsG.log
-- Server Python interpreter: /usr/bin/python
-- Server Python version: 2.7.10
-- Server has Clang support compiled in: True
-- Clang version: clang version 6.0.0 (tags/RELEASE_600/final)
-- No extra configuration file found
-- Server running at: http://127.0.0.1:61460
-- Server process ID: 29167
-- Server logfiles:
--   /var/folders/9q/s674cplx7qv122xbwcchw3jm0000gn/T/ycmd_61460_stdout_Hlf7BT.log
--   /var/folders/9q/s674cplx7qv122xbwcchw3jm0000gn/T/ycmd_61460_stderr__a94py.log  

Contents of YCM, ycmd and completion engine logfiles

ycm_*.log

2018-08-03 16:27:41,504 - ERROR - Unable to connect to server
Traceback (most recent call last):
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 79, in HandleFuture
    return _JsonFromFuture( future )
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 239, in _JsonFromFuture
    response = future.result()
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 404, in result
    return self.__get_result()
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/third_party/pythonfutures/concurrent/futures/_base.py", line 356, in __get_result
    raise self._exception
ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=60576): Max retries exceeded with url: /ready (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x1111c27d0>: Failed to establish a new connection: [Errno 61] Connection refused',))
2018-08-03 16:27:50,024 - ERROR - Error while handling server response
Traceback (most recent call last):
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 79, in HandleFuture
    return _JsonFromFuture( future )
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/autoload/../python/ycm/client/base_request.py", line 242, in _JsonFromFuture
    raise MakeServerException( response.json() )
ServerError: LookupError: unknown encoding: 

ycmd_stderr.log:

2018-08-03 16:29:38,151 - INFO - Received debug info request
2018-08-03 16:29:38,151 - INFO - Using node binary from /usr/local/bin/node
2018-08-03 16:29:38,151 - INFO - Using TSServer from /Users/dhleong/.npm-packages/bin/tsserver
2018-08-03 16:29:38,151 - ERROR - unknown encoding: 
Traceback (most recent call last):
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 238, in DebugInfo
    request_data ).DebugInfo( request_data )
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/handlers.py", line 302, in _GetCompleterForRequestData
    return _server_state.GetFiletypeCompleter( request_data[ 'filetypes' ] )
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/server_state.py", line 83, in GetFiletypeCompleter
    for filetype in current_filetypes ]
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/server_state.py", line 71, in _GetFiletypeCompleterForFiletype
    completer = module.GetCompleter( self._user_options )
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/completers/typescript/hook.py", line 33, in GetCompleter
    return TypeScriptCompleter( user_options )
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/completers/typescript/typescript_completer.py", line 151, in __init__
    self._tsserver_command = TsserverCommand()
  File "/Users/dhleong/.dotfiles/profile/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/../ycmd/completers/typescript/typescript_completer.py", line 86, in TsserverCommand
    with open( PATH_TO_TSSERVER ) as f:
LookupError: unknown encoding: 

ymcd_stdout.log:

serving on http://localhost:60576

OS version, distribution, etc.

macOS 10.13.6

@micbou
Copy link
Collaborator

micbou commented Aug 5, 2018

Thanks for the report. PR ycm-core/ycmd#1075 will fix the issue by dropping the nodejs workaround.

zzbot added a commit to ycm-core/ycmd that referenced this issue Aug 19, 2018
[READY] Remove nodejs workaround

Opening a file without setting the encoding may fail on Python 2. See issue ycm-core/YouCompleteMe#3101. We could use the `ReadFile` utility function to fix the issue but I think we are better off dropping the `nodejs` workaround altogether (looking for the `nodejs` executable before `node` because `nodejs` is the name of the Node binary on Debian-based distributions). Users should install the `nodejs-legacy` package on such distributions.

Fixes ycm-core/YouCompleteMe#3101.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/ycmd/1075)
<!-- Reviewable:end -->
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants