elm-community / SublimeElmLanguageSupport

Elm language syntax highlighting and tool integration for ST2/3.

Home Page:https://packagecontrol.io/packages/Elm%20Language%20Support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to build from Sublime 3 : TypeError: expected bytes, bytearray or buffer compatible object

rtxm opened this issue · comments

Platform:

Linux

Sublime version

Sublime Text 3, build 3156 (latest)

Description

When trying to build with Elm build System, nothing happens. The sublime console shows this error:

Exception in thread Thread-92:
Traceback (most recent call last):
  File "./python3.3/threading.py", line 901, in _bootstrap_inner
  File "./python3.3/threading.py", line 858, in run
  File "exec in /opt/sublime_text/Packages/Default.sublime-package", line 152, in read_fileno
  File "/home/romuald/.config/sublime-text-3/Packages/Elm Language Support/elm_make.py", line 56, in on_finished
    super(ElmMakeCommand, self).on_data(proc, output_data)
  File "exec in /opt/sublime_text/Packages/Default.sublime-package", line 364, in on_data
TypeError: expected bytes, bytearray or buffer compatible object

If I try to "make run", I get another error, of the same kind:

Exception in thread Thread-28:
Traceback (most recent call last):
  File "./python3.3/threading.py", line 901, in _bootstrap_inner
  File "./python3.3/threading.py", line 858, in run
  File "exec in /opt/sublime_text/Packages/Default.sublime-package", line 148, in read_fileno
  File "/home/romuald/.config/sublime-text-3/Packages/Elm Language Support/elm_make.py", line 49, in on_data
    self.buffer += data
TypeError: can't concat bytes to str

@rtxm My best guess without drilling into the code too deeply is that Sublime Text is failing to find elm-make on your system. On Linux, Sublime uses this path to search for it (from Elm Make.sublime-build):

        "path": "$HOME/.cabal/bin:/usr/local/bin:$PATH"

Can you check where elm-make is installed on your system? Also, can you confirm that you installed Elm with npm -g i elm as instructed in the README for this package?

Thanks for answering.
My path seems ok: elm-oracle (autocomplete) and elm-format work from sublime 3, build building with elm-make does not. They're all in the same location. elm-make works on the command line.

I've found the problem in elm_make.py: the data received by the on_data method is already decoded by sublime, so the buffer must be str not bytes. I can submit a PR if you wish.

@rtxm A PR would be much appreciated, thanks!

Fixed in 0.22.1 🎉