defuz / RustAutoComplete

A SublimeText binding for RACER (Rust auto completion tool)
MIT License
105 stars 20 forks source link

"Unable to find racer executable (check settings)" with unsaved files #12

Closed porglezomp closed 9 years ago

porglezomp commented 9 years ago

My RustAutoComplete consistently fails on files set to "Rust" language but not yet saved.

golddranks commented 9 years ago

I changed the error checking code a little bit with the newest merged commit. Earlier it actually displayed that error every time when any error is thrown by the racer running code. Now it shows that error only when it actually can't locate the file. Does it still say the same error, or display a stack trace with different error message?

porglezomp commented 9 years ago

It's still displaying Unable to find racer executable (check settings). I'm using the Package Control version right now, so I'll try getting it straight from git, but the Package Control version needs to be updated.

porglezomp commented 9 years ago

Indeed, I get an error with a stack trace when I use the version cloned from git.

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 358, in on_query_completions
    res = callback.on_query_completions(v, prefix, locations)
  File "/Users/caleb/Library/Application Support/Sublime Text 3/Packages/RustAutoComplete/RustAutoComplete.py", line 128, in on_query_completions
    raw_results = run_racer(view, ["complete", str(row), str(col)])
  File "/Users/caleb/Library/Application Support/Sublime Text 3/Packages/RustAutoComplete/RustAutoComplete.py", line 70, in run_racer
    current_path = os.path.dirname(view.file_name())
  File "./posixpath.py", line 151, in dirname
AttributeError: 'NoneType' object has no attribute 'rfind'
porglezomp commented 9 years ago

I've located the problem, view.file_name() is None, and it's trying to use that to build a path. If some standard path is picked when the default one is missing, then it works. If I replace line 70:

current_path = os.path.dirname(view.file_name())

with

    if view.file_name() is not None:
        current_path = os.path.dirname(view.file_name())
    else:
        current_path = "/tmp/"

Then mine works. On Mac OS X using /tmp/ as the fallback path makes sense, but it wouldn't work on Windows, etc. I think this is the right kind of solution, but what should the default be?

golddranks commented 9 years ago

https://docs.python.org/2/library/tempfile.html <- I think this provides one solution, it's part of the Python standard library. But I don't know whether Sublime plugin API has some recommended temp path...

porglezomp commented 9 years ago

Okay, I'll work on integrating that.