-
Notifications
You must be signed in to change notification settings - Fork 23
sublack can't start blackd #35
Comments
hi , sorry for trouble. |
No worries. (FWIW, just changing the log level didn't do anything until I disabled/enabled the package to force it to reload.)
|
Hi, About logging indeed, logging is set in the load_plugin function. I know how to watch for setting change but I do not know the command to reload the plugin on change. If you have any opinion on it, you're welcome ;-) |
I guess something in macos mojave or another dependency shift has resurfaced #2? I checked the Click doc mentioned there to see if there was something painfully obvious I should do. My LANG env is |
I tried formatall, but it claimed it ran fine. I saw nothing in the console after running it. I pulled master and it looks like it managed to start the server, though it did produce an additional error:
|
Hi,
checker.py is a small script which watch if sublime is still running to shutdown blackd server when exiting sublimetext. I do not use On your system maybe due to mojave or anaconda, there is no python3 in the path. I'll think to it. thank you for all your feedback |
Hmm. I do have python3 on the system path:
But I guess it's not the same within ST3's local python. In the ST3 console:
Running the same in an external python returns the full system path. |
hi, |
I'll start at the end: We're getting somewhere! It looks like this is a common issue lately, and it doesn't seem like there's anything wrong with how you're trying to use subprocess here. (On the downside, it looks like these edits were mostly a waste of your time.) I tried your master and still had the same no-such-file-or-directory issue. I've been feeling bad about sending you on a wild goose chase (I know how frustrating it is to try and debug something only cropping up on a platform you don't have access to), so I spent a while searching github and ST3 forums and eventually stumbled into a GH issue (SublimeLinter/SublimeLinter#1508) for SublimeLinter that started to peel back what seems to be going on. Since then, I've found quite a lot of these threads around. While supposedly these macos path issues had been fixed in an earlier release, it seems like that fix depends on your shell startup running in under 1s. The common workaround cited in these threads is launching ST3 from the command line (i.e., with I suppose it may help to document the issue. If you get more issues on the topic, I guess you could also detect when the path is the default and log to console or open a dialog pointing the user toward a fix that doesn't waste more of your time :). I'm tempted to close this, but I'll defer to whether you feel like leaving it open will help avoid others opening similar issues. |
Hi, Anyway the only thing which hurts me is that the last fix should have worked: def get_python3_executable(config=None):
# First check for python3/python in path
for version in ["python3", "python"]:
if is_python3_executable(version):
return version
# Then find one via shell
python_exec = find_python3_executable()
if python_exec:
return python_exec
# Third: guess from black_command
if config:
if config["black_command"] != "black":
python_exec = str(Path(config["black_command"]).parent / "python")
print(python_exec)
if is_python3_executable(python_exec):
return python_exec
return False After the 2 first parts fail on your system, the last one should have guess after checking, the second part might raise an exception I didn't catch. I fixed it and reordered it (now the black_command way comes second. I really like this work since It would be, I think, easier to say to users : "there is a problem with your path, please enter the full path of black_command to fix it" and that's it. |
Ok. I don't mind trying more versions if you'd like to keep searching for a fix. Here's_ the current stack:
I do wonder if it's possible to reproduce the problem in a CI run, since that might shorten the experiment loop. I guess since it's running from command line it probably inherits the env set by travis-ci and the .travis.yml; maybe it's as simple as fiddling with the path. |
no, I don't mind asking you to do it 😄 indeed my curiosity might bring me some pain in CI soon 😆 I let it open for now, I'll close it if i'm sure to have a fix. nice sunday |
should be fixed in 2.1.0 🤞 |
Gave this a try today, figured I should post in case it's useful. Log:
Not sure about the python3 interpreter test above:
|
It never ends, damn.... I'm really sorry I really thought I would work. The log seems to say that the following return True :
which is strange : how version_out could be False ? The only thing I could reproduce is on a python2 interpreter if is a different behavior between python2 and 3 :
I changed version detection to
I let it opened for now |
Also possible that Sublime's internal 3.3 python is complicating things if there are any differences. I'm not certain why this is mattering, but I fiddled with those statements a bit in ST3 console. I'll show a few things that didn't work, and the first one that did. :)
I haven't gotten curious enough to dig into how and why they differ, but I've noticed I often run into subprocess examples that use a full command with flags in a single string, but the current python docs use an array, so I tried this first:
Since it seemed to run but produced no output, I was curious if there would be an error message on stderr...
|
That said, I think the statement you ended on is probably a better approach. I didn't notice it at first, but I was about to suggest the same thing. I tried this in ST3 console as well: This wouldn't work:
But this does:
|
to use plain string in subprocess instead of list, you have to use shell=True. |
Aha; I didn't realize shell had an effect beyond the env issues. Good to know. :) |
I pushed 2.1.1 with the fix |
OS: macos 10.14
sublack: 2.0.1
ST3: build 3180
blackd: 18.9b0
Sublack encounters an error trying to start blackd (regardless of whether it tries to autostart or start via command). If I start blackd externally, sublack is able to use it correctly.
Config in case it helps:
The text was updated successfully, but these errors were encountered: