sde icon indicating copy to clipboard operation
sde copied to clipboard

The Swift server crashed 5 times in the last 3 minutes. The server will not be restarted

Open gperdomor opened this issue 7 years ago β€’ 78 comments

Using macOS Sierra

/Users/gustavoperdomo/.vscode/extensions/jinmingjian.sde-1.0.20170112/out/src/server/server.js:157
        throw err; //FIXME more friendly prompt
        ^

Error: spawn /usr/bin/sourcekitd-repl ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
[Info  - 3:40:48 PM] Connection to server got closed. Server will restart.
/Users/gustavoperdomo/.vscode/extensions/jinmingjian.sde-1.0.20170112/out/src/server/server.js:157
        throw err; //FIXME more friendly prompt
        ^

Error: spawn /usr/bin/sourcekitd-repl ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
[Info  - 3:40:49 PM] Connection to server got closed. Server will restart.
/Users/gustavoperdomo/.vscode/extensions/jinmingjian.sde-1.0.20170112/out/src/server/server.js:157
        throw err; //FIXME more friendly prompt
        ^

Error: spawn /usr/bin/sourcekitd-repl ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
[Info  - 3:40:49 PM] Connection to server got closed. Server will restart.
/Users/gustavoperdomo/.vscode/extensions/jinmingjian.sde-1.0.20170112/out/src/server/server.js:157
        throw err; //FIXME more friendly prompt
        ^

Error: spawn /usr/bin/sourcekitd-repl ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
[Info  - 3:40:49 PM] Connection to server got closed. Server will restart.
/Users/gustavoperdomo/.vscode/extensions/jinmingjian.sde-1.0.20170112/out/src/server/server.js:157
        throw err; //FIXME more friendly prompt
        ^

Error: spawn /usr/bin/sourcekitd-repl ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
[Error - 3:40:49 PM] Connection to server got closed. Server will not be restarted.

gperdomor avatar Jan 12 '17 18:01 gperdomor

You don't have the sourcekitd-repl tool in this location (/usr/bin/sourcekitd-repl ENOENT).

mna avatar Jan 12 '17 22:01 mna

@PuerkitoBio do you know where it is located on macOS?

vknabel avatar Jan 12 '17 22:01 vknabel

I'm trying to figure this out atm, looks like it isn't built by default (it's a test tool or something). I checked /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin and it's not there.

mna avatar Jan 12 '17 23:01 mna

online just now. really thanks for all report. The choose of 'sourcekitd-repl' is not accident. It is a tool made by official Swift team. So it should work in all platform which Swift supports. It is great.

The tool is also not built by default. I use a build preset file way (customized @ ~/.swift-build-presets) in my Linux which modified from the official preset file.

jinmingjian avatar Jan 12 '17 23:01 jinmingjian

please wait a moment. I will share you a build preset in Linux which give you some hints.

jinmingjian avatar Jan 13 '17 00:01 jinmingjian

this preset file now lives here.

the "secretβ€œ may be this:

... extra-cmake-options="-DSWIFT_BUILD_SOURCEKIT:BOOL=ON -DSWIFT_TOOL_SOURCEKITD_REPL_BUILD=1"

dash-dash

swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;sdk-overlay;license;sourcekit-inproc;tools ...

at OSX, you may change:

sourcekit-inproc -> sourcekit-xpc-service

and component "tools" should corresponds to sourcekit side gen.

extra-cmake-options is must for Linux. but I guess no harm for OSX.

And it needs two passes in Linux: First, disable "sourcekit-inproc" comopnent for libdispatch, and second enable "sourcekit-inproc" for itself.

@alblue recently introduce a PR to solve this problem, but seemly reverted...

jinmingjian avatar Jan 13 '17 00:01 jinmingjian

Add if some successfully, it may be possible to only ship the binary for macOS in that the sourcekit lib should already have existed which used by xcode. Great.

jinmingjian avatar Jan 13 '17 00:01 jinmingjian

I just pushed new version into VSCode Marketplace which fixs #14 for macOS

jinmingjian avatar Jan 13 '17 01:01 jinmingjian

I'm having the same problem on Ubuntu 16.04. I'm using https://github.com/norio-nomura/docker-sourcekit-builder provides sourcekitd-repl.

fwgreen avatar Jan 13 '17 01:01 fwgreen

and note: we need SPM 3.1 for the info of project which is not available for 3.0.

In macOS, it has fancy tool swiftenv for use.

More notes: It can be hard coded by assumption with Sources or src by ablue. But this is too special. One workaround is to use build.yaml. However, this is a internal generated build file. It is better to based on "swfit package"(which is official interface to reflect Pacakge.swift itself)

jinmingjian avatar Jan 13 '17 02:01 jinmingjian

@fwgreen do you have sourcekitd-repl in path? How about you execute the following cmd in shell:

which sourcekitd-repl

sourcekitd-repl

jinmingjian avatar Jan 13 '17 02:01 jinmingjian

@fwgreen thanks for report for Linux.

More note: sourcekitd-repl even can not be executed in my Arch default. Because the linked library name is not correct. The following workaround this:

sudo ln -s /usr/lib/sourcekitdInProc.framework/sourcekitdInProc /usr/lib/sourcekitdInProc

But the ubuntu release is officially supported, so I guess the problem should not be there...

jinmingjian avatar Jan 13 '17 02:01 jinmingjian

@fwgreen could you like to try some binary from my own build? :smile:

jinmingjian avatar Jan 13 '17 02:01 jinmingjian

@jinmingjian I'll have to try and build it myself: I tried running sourcekitd-repl and got an error. Maybe the a complete language server written in TypeScript would save us πŸ˜„. I'll try to build it and report back.

fwgreen avatar Jan 13 '17 02:01 fwgreen

@jinmingjian I managed to get sourcekitd-repl working, but the error persists 😞

fwgreen avatar Jan 13 '17 03:01 fwgreen

@fwgreen if sourcekitd-repl works, then it almost becomes working for all.

what is your exact error output?

and still show you output of the following cmd in shell:

which sourcekitd-repl

jinmingjian avatar Jan 13 '17 04:01 jinmingjian

you add a sym link to /usr/bin/sourcekitd-repl. or use override configurations. You can see all configurable constants in Extensions's page in vscode:

configs

jinmingjian avatar Jan 13 '17 05:01 jinmingjian

ok, more detail config like this:

sk_repl_path

jinmingjian avatar Jan 13 '17 05:01 jinmingjian

@PuerkitoBio I know this is not the place to ask, but I didn't manage to find the required info anywhere :( Any idea how to build the sourcekitd-repl / sourcekit on a mac?

rolandleth avatar Jan 13 '17 08:01 rolandleth

which sourcekitd-repl returns

/usr/bin/sourcekitd-repl

sourcekitd-repl returns

Welcome to SourceKit.  Type ':help' for assistance.
(SourceKit) 

The output from vscode is

/home/fwgreen/.vscode/extensions/jinmingjian.sde-1.0.20170113/out/src/server/server.js:64
        throw err; //FIXME more friendly prompt
        ^

Error: spawn /usr/bin/sh ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
[Info  - 6:20:37 AM] Connection to server got closed. Server will restart.
/home/fwgreen/.vscode/extensions/jinmingjian.sde-1.0.20170113/out/src/server/server.js:64
        throw err; //FIXME more friendly prompt
        ^

Error: spawn /usr/bin/sh ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
[Info  - 6:20:38 AM] Connection to server got closed. Server will restart.
/home/fwgreen/.vscode/extensions/jinmingjian.sde-1.0.20170113/out/src/server/server.js:64
        throw err; //FIXME more friendly prompt
        ^

Error: spawn /usr/bin/sh ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
[Info  - 6:20:38 AM] Connection to server got closed. Server will restart.
/home/fwgreen/.vscode/extensions/jinmingjian.sde-1.0.20170113/out/src/server/server.js:64
        throw err; //FIXME more friendly prompt
        ^

Error: spawn /usr/bin/sh ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
[Info  - 6:20:38 AM] Connection to server got closed. Server will restart.
/home/fwgreen/.vscode/extensions/jinmingjian.sde-1.0.20170113/out/src/server/server.js:64
        throw err; //FIXME more friendly prompt
        ^

Error: spawn /usr/bin/sh ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
[Error - 6:20:39 AM] Connection to server got closed. Server will not be restarted.

fwgreen avatar Jan 13 '17 11:01 fwgreen

@jinmingjian Thanks I got it to work on macOS πŸŽ‰

@rolandleth I needed to compile it manually.

$ mkdir swift-sources && cd swift-sources
# Probably other swift versions will work too
$ git clone --branch swift-DEVELOPMENT-SNAPSHOT-2017-01-05-a --depth 1 https://github.com/apple/swift
$ brew install cmake ninja
$ swift/utils/update-checkout --clone
# This will end with an error about master not found or so, just ignore it

# Now I edited `swift/utils/build-presets.init` according to @jinmingjian
# As follows https://gist.github.com/vknabel/170caee6b5883624f55c4d7f1b0b259c/revisions
# On the line starting with: 'swift-install-components='
# I replaced 'sourcekit-xpc-service' with 'sourcekit-inproc'
$ swift/utils/build-script # This takes a while

# sourcekitd-repl is now at
# build/Ninja-DebugAssert/swift-macosx-x86_64/bin/sourcekitd-repl

Now you can either link it to /usr/bin or set "swift.path.sourcekitd_repl" in Code to the appropriate path.

vknabel avatar Jan 13 '17 11:01 vknabel

@vknabel Cool!

jinmingjian avatar Jan 13 '17 11:01 jinmingjian

@vknabel Awesome, thanks a lot! πŸŽ‰

rolandleth avatar Jan 13 '17 12:01 rolandleth

@fwgreen You are using the docker container, right? Did you execute which sourcekitd_repl in docker run bash or so? I guess the problem is that only your docker has sourcekitd_repl, whereas the rest of your computer (including VS Code) doesn't. Maybe you need to create a bash script that passes all Inputs to docker run sourcekitd_repl and link that file to /usr/bin/sourcekitd_repl outside docker.

vknabel avatar Jan 13 '17 12:01 vknabel

@fwgreen you met issue #14 in Linux... you have not sh in /usr/bin/sh, find your sh, do a sym link to /usr/bin/sh. I will add config option later for you.

which sh

jinmingjian avatar Jan 13 '17 12:01 jinmingjian

@vknabel thanks for contributing ideas!

@rolandleth If you still have not build sourcekitd-repl successfully, you may wait for serveral days. I am considering add a simpler solution in #9. The implementation itself is trivial. But I hope to leave a space for further extension. So just wait several days.

After #9 fixed, I plan to ship the binary in the package. For Linux, we still need sourcekitd library to build:( For macOS, the state may be better, I guess sourcekitd have existed in that xcode, but we need to test. You can also help in this if interesting:)

jinmingjian avatar Jan 13 '17 12:01 jinmingjian

@jinmingjian Oooh, that's great news! I already started building it, but I'll probably just delete everything after you release an update. Thanks!

rolandleth avatar Jan 13 '17 12:01 rolandleth

Should be nice having sourcekitd-repl as a homebrew formula :D

gperdomor avatar Jan 13 '17 12:01 gperdomor

@jinmingjian The symlink from /bin/sh to /usr/bin/sh did the trick! Thanks.

fwgreen avatar Jan 13 '17 12:01 fwgreen

@fwgreen #15 done. And I have published a new version. You can delete the sym link /usr/bin/sh now!

jinmingjian avatar Jan 13 '17 12:01 jinmingjian