Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when changing directory in custom build system #246

Open
MK-Alias opened this issue Oct 2, 2018 · 16 comments
Open

Crash when changing directory in custom build system #246

MK-Alias opened this issue Oct 2, 2018 · 16 comments

Comments

@MK-Alias
Copy link

MK-Alias commented Oct 2, 2018

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
Copy link
Contributor

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

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

@virella2385

This comment has been minimized.

@MK-Alias
Copy link
Author

MK-Alias commented Oct 2, 2018

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
Copy link
Contributor

Rosalie241 commented Oct 2, 2018

@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

This comment has been minimized.

@MK-Alias
Copy link
Author

MK-Alias commented Oct 2, 2018

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 <ST3_userdir>\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

This comment has been minimized.

@Rosalie241
Copy link
Contributor

Rosalie241 commented Oct 2, 2018 via email

@Rosalie241
Copy link
Contributor

@ALIAS-777 I looked at it, doesn't seem like something I can fix sadly

def current_solution_filepath_or_project_rootpath(view):
project_file = project_file_name(view)
if project_file is not None:
print('project file %s found' % project_file)
data = project_data(view)
if 'solution_file' not in data:
raise ValueError('Please specify a path to the solution file in your sublime-project file or delete it')
project_dir = os.path.dirname(project_file)
solution_file_name = data['solution_file']
solution_file_path = os.path.join(project_dir, solution_file_name)
return os.path.abspath(solution_file_path)
else:
active_window = sublime.active_window()
if len(active_window.folders()) > 0:
return active_window.folders()[
0] # assume parent folder is opened that contains all project folders eg/Web,ClassLib,Tests
try:
return os.path.dirname(active_window.active_view().file_name())
except Exception:
print("New file not saved. Can't find path.")
return None

@MK-Alias
Copy link
Author

MK-Alias commented Oct 4, 2018

@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

This comment has been minimized.

@Rosalie241

This comment has been minimized.

@Rosalie241 Rosalie241 changed the title Error talking to localhost. Crash when changing directory in custom build system Oct 10, 2018
@cfg630

This comment has been minimized.

@Rosalie241

This comment has been minimized.

@CarlosJader
Copy link

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
Copy link

Asmor commented Feb 27, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants