OmniSharp / omnisharp-sublime

C# IDE Plugin for Sublime Text 3
http://omnisharp-sublime.readthedocs.org/en/latest/
MIT License
551 stars 64 forks source link

Crash when changing directory in custom build system #246

Open MK-Alias opened 6 years ago

MK-Alias commented 6 years ago

OmniSharp: v1.9.7 Windows: 10 (BUILD: 1803) Sublime: 3.1.1 (BUILD: 3176)

After a short period (couple of minutes) OmniSharp stops working. It states in the status bar:

OmniSharp: Error Talking to http://localhost:50736/autocomplete

This shows up in the console:

HTTPConnectionPool(host='localhost', port=50736): Max retries exceeded with url: /autocomplete (Caused by ProtocolError('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061)))

If I would direct my browser to http://localhost:<port> when OmniSharp is still working, then a blank page shows. After the error I get: ERR_CONNECTION_REFUSED

So it seems that Node is having problems? Or, also i've noticed that the previous version send some kind of keep alive messages... This version does not! Perhaps just a timeout?

Rosalie241 commented 6 years ago

Odd, can you see if the console shows something else?

I did not change the way omnisharp-sublime interacts with omnisharp-roslyn.

virella2385 commented 6 years ago

I'm having the same issue, I'm running the latest stable Sublime build in OS 10.14 Mojave

Log:

======== request ======== 
 Url: http://localhost:50012/autocomplete 
 Data: {"line": "29", "wordToComplete": "", "buffer": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing Microsoft.AspNetCore.Builder;\nusing Microsoft.AspNetCore.Hosting;\nusing Microsoft.AspNetCore.Http;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Configuration;\n\nnamespace TestNetCoreWebApp\n{\n    public class Startup\n    {\n        // This method gets called by the runtime. Use this method to add services to the container.\n        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940\n        public void ConfigureServices(IServiceCollection services)\n        {\n        }\n\n        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.\n        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IConfiguration conf)\n        {\n            if (env.IsDevelopment())\n            {\n                app.UseDeveloperExceptionPage();\n            }\n            string teststr = null;\n            teststr.\n\n            app.Run(async (context) =>\n            {\n                var greeting = conf[\"Greeting\"];\n                await context.Response.WriteAsync(greeting);\n            });\n        }\n    }\n}\n", "WantMethodHeader": true, "WantSnippet": true, "column": "21", "filename": "/Users/alakratt/Documents/github/DotnetCoreFundamentals/TestNetCoreWebApp/Startup.cs", "WantReturnType": true}
HTTPConnectionPool(host='localhost', port=50012): Max retries exceeded with url: /autocomplete (Caused by ProtocolError('Connection aborted.', ConnectionRefusedError(61, 'Connection refused')))
project file %s found /Users/alakratt/Documents/github/DotnetCoreFundamentals/TestNetCoreWebApp/TestNetCoreWebApp.sublime-project
solution path: /Users/alakratt/Documents/github/DotnetCoreFundamentals/TestNetCoreWebApp/TestNetCoreWebApp.sln
MK-Alias commented 6 years ago

On my end part of the problem seems to be my buildsystem. Every time a do a build the .csproj gets overwritten. Sublime OmniSharp seems to not handle this correctly. (VScode version does not care)

I will try and investigate if not overwriting the .csproj file solves this.

I've removed all data, paths and names of the console output but notice this:

======== request ======== 
 Url: http://localhost:52076/addtoproject 
 Data: {/* removed */}
solution path: /* removed */
file changed
======== request ======== 

=============== CONSOLE OUTPUT ===============

solution path: /* removed */
======== request ======== 
 Url: http://localhost:52076/checkalivestatus 
 Data: {/* removed */}
======== response ======== 
 true
======== end ========
Running XXXXXXXXX /* Here I start a buildsystem which builds and runs my App */
solution path: /* remove */
======== request ======== 
 Url: http://localhost:52076/checkalivestatus 
 Data: {/* removed */ }
======== response ======== 
 true
======== end ========
solution path: /* removed */
======== request ======== 
 Url: http://localhost:52076/checkalivestatus 
 Data: {/* removed */}
already_bound_solution:/* removed */
solution path: /* removed */
======== request ======== 
 Url: http://localhost:52076/autocomplete 
 Data: {/* removed */}
solution path: /* removed */
======== request ======== 
 Url: http://localhost:52076/autocomplete 
 Data: {/* removed */}
solution path: /* removed */
======== request ======== 
 Url: http://localhost:52076/autocomplete 
 Data: {/* removed */}
solution path: /* removed */
======== request ======== 
 Url: http://localhost:52076/autocomplete 
 Data: {/* removed */}
solution path: /* removed */
======== request ======== 
 Url: http://localhost:52076/addtoproject 
 Data: {/* removed */}
solution path: /* removed */
file changed
======== request ======== 
 Url: http://localhost:52076/codecheck 
 Data: {/* removed */}
solution path: /* removed */
======== request ======== 
 Url: http://localhost:52076/autocomplete 
 Data: {/* removed */}
solution path: /* removed */
======== request ======== 
 Url: http://localhost:52076/autocomplete 
 Data: {/* removed */}
solution path: /* removed */
======== request ======== 
 Url: http://localhost:52076/autocomplete 
 Data: {/*removed */}
HTTPConnectionPool(host='localhost', port=52076): Max retries exceeded with url: /autocomplete (Caused by ProtocolError('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061)))
HTTPConnectionPool(host='localhost', port=52076): Max retries exceeded with url: /autocomplete (Caused by ProtocolError('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061)))
HTTPConnectionPool(host='localhost', port=52076): Max retries exceeded with url: /autocomplete (Caused by ProtocolError('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061)))
HTTPConnectionPool(host='localhost', port=52076): Max retries exceeded with url: /autocomplete (Caused by ProtocolError('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061)))
HTTPConnectionPool(host='localhost', port=52076): Max retries exceeded with url: /addtoproject (Caused by ProtocolError('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061)))
file added to project
None
HTTPConnectionPool(host='localhost', port=52076): Max retries exceeded with url: /codecheck (Caused by ProtocolError('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061)))
handling Errors
no data
HTTPConnectionPool(host='localhost', port=52076): Max retries exceeded with url: /autocomplete (Caused by ProtocolError('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061)))
HTTPConnectionPool(host='localhost', port=52076): Max retries exceeded with url: /autocomplete (Caused by ProtocolError('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061)))
HTTPConnectionPool(host='localhost', port=52076): Max retries exceeded with url: /autocomplete (Caused by ProtocolError('Connection aborted.', ConnectionRefusedError(10061, 'No connection could be made because the target machine actively refused it', None, 10061)))
/* etc */
Rosalie241 commented 6 years ago

@virella2385 verify that you have all the requirements installed

@Alias-777 odd, can you try to manually execute omnisharp.cmd -s /path/to/solution/directory in OmniSharp/prebuilt-omnisharp-roslyn/ ? then just do the same thing(overwriting the csproj) and see if the same thing happens

virella2385 commented 6 years ago

Turned out I missed installing mono. That fixed it, thanks!

@virella2385 verify that you have all the requirements installed

@Alias-777 odd, can you try to manually execute omnisharp.cmd -s /path/to/solution/directory in OmniSharp/prebuilt-omnisharp-roslyn/ ? then just do the same thing(overwriting the csproj) and see if the same thing happens

MK-Alias commented 6 years ago

Found the culprit... It's really the weirdest thing. After doing lots of test and finding out the running my build from outside Sublime worked just fine and keeps OmniSharp going, I've tested an other scenario. My build system uses cd and popd a lot and that's the problem. If you change directory in a Sublime build system then the problem occurs - omnisharp plugin reacts to this. Here is repro.

test.cmd: Put this in the root of the folder you are opening.

@echo off
echo Going to CD
cd ..

MyBuild.sublime-build: Put this in \Sublime Text 3\Packages\User

{
    "working_dir": "$folder",
    "cmd": ["test.cmd"],
    "shell": true
}

Set MyBuild as default build system by checking it on in: Tools -> Build System -> MyBuild ... And then execute the build: Tools -> Build

This will crash OmniSharp. For now I will just workaround this by building from a console or AutoHokeys Script until this gets fixed.

virella2385 commented 6 years ago

While my omnisharp server is running fine now, whenever I try to build a dotnet core app using the asp.net profile it fails (it's looking for a project.json instead of the .csproj file) the server doesn't start back up. It stays on the "Server Starting" message until I make a code change or start typing and the calls to autocomplete and codecheck fail like before. Not a deal breaker though, I normally use the cli for building.

Rosalie241 commented 6 years ago

Thank you for figuring it out! I'll research the code and see if it's the fault of this plugin or sublime.

Thank you very much! :)

On 02.10 03:44, Alias-777 wrote:

Found the culprit... It's really the weirdest thing. After doing lots of test and finding out the running my build from outside Sublime worked just fine and keeps OmniSharp going, I've tested an other scenario. My build system uses cd and popd a lot and that's the problem. If you change directory in a Sublime build system then the problem occurs - omnisharp plugin reacts to this. Here is repro.

test.cmd: Put this in the root of the folder you are opening.

@echo off
echo Going to CD
cd ..

MyBuild.sublime-build: Put this in \Sublime Text 3\Packages\User

{
  "working_dir": "$folder",
  "cmd": ["test.cmd"],
  "shell": true
}

Set MyBuild as default build system by checking it on in: Tools -> Build System -> MyBuild ... And then execute the build: Tools -> Build

This will crash OmniSharp. For now I will just workaround this by building from a console or AutoHokeys Script until this gets fixed.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/OmniSharp/omnisharp-sublime/issues/246#issuecomment-426228875

Rosalie241 commented 6 years ago

@Alias-777 I looked at it, doesn't seem like something I can fix sadly https://github.com/OmniSharp/omnisharp-sublime/blob/6adda0521748c6d644f94cd6955f9f68f6593643/lib/helpers.py#L34-L58

MK-Alias commented 6 years ago

@tim241 I'm not familair with python nor the internals of the sublime plugin system, but can you not just query the path the first time the function is called and store it in a variable instead of re-querying it on each call.... Does that fix it? (or perhaps in an init function?). Or is there maybe an hook (callback) when a new "project folder" opens? Then query it there and then store it.

These are obviously not the most prettiest ways of doing it. but the only things changing the working directory seem to be build-systems anyways.

To be honest, in my opinion sublime+omnisharp is not a great combination at this point. I'ts just unstable and frustrating to use. I will check it out in the future, perhaps things are better then. For now I will stick with VScode. (which Omnisharp impenmentation is very decent)

Thanks for all your help though!

cfg630 commented 6 years ago

I met same issue, status bar always show "OmniSharp: Server Starting", open the console, display like this: WARNING:OmniSharp.lib.urllib3.connectionpool:Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionRefusedError(10061, '由于目标计算机积极拒绝,无法连接。', None, 10061))': /checkreadystatus

is a bug ? when to fix ?

Rosalie241 commented 6 years ago

@cfg630 read the requirements and install everything.

cfg630 commented 6 years ago

@tim241 I checked, I make sure that install all requires, but same error accur still. am i missing something , both path "C:\Program Files (x86)\MSBuild\14.0\Bin" and "C:\Program Files (x86)\MSBuild" were set already, thank you for help!

Rosalie241 commented 6 years ago

@cfg630 please open a new issue for this with logs, it's not related to this one and I really dislike mixing 2 issues.

CarlosJader commented 5 years ago

Any solution for this already? I'm having the same problem, I 'm trying to use Sublime Text 3 with Unity, I followed this tutorial: http://makegamessa.com/discussion/2879/tutorial-using-sublime-text-3-in-unity-with-intellisense-autocomplete and I'm getting this error on console: ======== request ======== Url: http://localhost:51767/autocomplete Data: {"WantMethodHeader": true, "line": "37", "buffer": "using TMPro;\nusing UnityEngine;\n\npublic class PlayerMovement : MonoBehaviour\n{\n\tpublic float speed = 6f;\n\tVector3 movement;\n\tAnimator anim;\n\tRigidbody playerRigidbody;\n\tint floorMask;\n\tfloat camRayLength = 100f;\n\n\tvoid Awake()\n\t{\n\t\tfloorMask = LayerMask.GetMask (\"Floor\");\n\t\tanim = GetComponent();\n\t\tplayerRigidbody = GetComponent();\n\t}\n\t\n\tvoid FixedUpdate()\n\t{\n\t\tfloat h = Input.GetAxisRaw(\"Horizontal\");\n\t\tfloat v = Input.GetAxisRaw(\"Vertical\");\n\t}\n\n\tvoid Move (float h, float v)\n\t{\n\t\tmovement.Set(h,0f,v);\n\t\tmovement = movement.normalized speed Time.deltaTime;\n\n\t\tplayerRigidbody.MovePosition(transform.position+movement);\n\t}\n\n\tvoid Turning()\n\t{\n\t\tRay camRay = Camera.main.ScreenPointToRay(Input.mousePosition);\n\t\tRay\n\t}\n}\n", "WantReturnType": true, "WantSnippet": true, "column": "6", "wordToComplete": "Ray", "filename": "C:\Unity\Projects\Survival Shooter\Survival Shooter\Assets\Scripts\Player\PlayerMovement.cs"} HTTPConnectionPool(host='localhost', port=51767): Max retries exceeded with url: /autocomplete (Caused by ProtocolError('Connection aborted.', ConnectionRefusedError(10061, 'Nenhuma conexão pôde ser feita porque a máquina de destino as recusou ativamente', None, 10061))) Error description is in portuguese but it means exactly the same thing. I know the tutorial is quite old but I didn't found anything as easilly explained, could anyone help plz?

Asmor commented 5 years ago

I'm running into same problem. Trying to use OmniSharp with Sublime for Unity, getting connection refused.