-
Notifications
You must be signed in to change notification settings - Fork 675
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
Add option to run with a custom mono installation #2425
Conversation
When `useGlobalMono` is set to `always` or `auto`, the launcher uses whatever mono it finds in the path, which may or may not be a usable mono version for omnisharp. The user may have a suitable mono installation for omnisharp somewhere else, but not set as the default system one, or they may want to have omnisharp launched with a specific mono for omnisharp for debugging purposes. This adds a `monoPath` configuration option, and changes the launcher so that the environment variables PATH and MONO_GAC_PREFIX are changed to include the `monoPath` value, if set, when launching mono.
@shana Thank you for taking the time to contribute to the repo. |
@shana Thanks for your contribution! Looks good to me, once tests pass. |
… made other comparisons fail :/
Codecov Report
@@ Coverage Diff @@
## master #2425 +/- ##
==========================================
- Coverage 63.73% 63.68% -0.05%
==========================================
Files 88 88
Lines 3998 4007 +9
Branches 564 567 +3
==========================================
+ Hits 2548 2552 +4
- Misses 1290 1292 +2
- Partials 160 163 +3
Continue to review full report at Codecov.
|
Thanks for the review! Looks like the return value from the settings file was null instead of undefined, which meant the block overriding the env vars was always running, and I imagine screwing up the environment for spawning omnisharp in the process. I ran the integration tests locally with an up to date default system mono with no monoPath override, and with an older system mono and the monoPath override, and everything passes locally. Can't really add much coverage for the integration tests though, not without bundling mono just for that purpose :/ |
src/omnisharp/launcher.ts
Outdated
@@ -306,14 +312,15 @@ function launchNix(launchPath: string, cwd: string, args: string[]): LaunchResul | |||
}; | |||
} | |||
|
|||
function launchNixMono(launchPath: string, monoVersion: string, cwd: string, args: string[]): LaunchResult { | |||
function launchNixMono(launchPath: string, monoVersion: string, cwd: string, args: string[], environment: NodeJS.ProcessEnv): LaunchResult { | |||
let argsCopy = args.slice(0); // create copy of details args | |||
argsCopy.unshift(launchPath); | |||
argsCopy.unshift("--assembly-loader=strict"); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add some logging here, like printing the mono launch path, just like we print the version?
We create the log event here from the launch result: https://github.com/OmniSharp/omnisharp-vscode/blob/master/src/omnisharp/server.ts#L324. We might also return a monoLaunchPath in the launch result and display it here: https://github.com/OmniSharp/omnisharp-vscode/blob/master/src/observers/OmnisharpLoggerObserver.ts#L58. We will have to add the appropriate property to OmnisharpLaunch
event here: https://github.com/OmniSharp/omnisharp-vscode/blob/master/src/omnisharp/loggingEvents.ts#L30.
Basically to do logging in omnisharp-vscode, we post the events into an event stream to which some observers subscribe. Whenever we post an event to the event stream, all the observers are invoked and take action appropriately. Does that make sense ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I hacked up some manual logging directly to a separate window just so I could see what was going on while I was putting this together, but adding some more information to the event stream probably makes sense, I can give that a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akshita31 I added some logging and in the process tweaked the test method a bit to avoid growing the if block, let me know if that's what you had in mind.
src/omnisharp/server.ts
Outdated
@@ -321,7 +321,7 @@ export class OmniSharpServer { | |||
|
|||
try { | |||
let launchResult = await launchOmniSharp(cwd, args, launchInfo, this.platformInfo, options); | |||
this.eventStream.post(new ObservableEvents.OmnisharpLaunch(launchResult.monoVersion, launchResult.command, launchResult.process.pid)); | |||
this.eventStream.post(new ObservableEvents.OmnisharpLaunch(launchResult.monoVersion, launchResult.command, launchResult.process.pid, options.monoPath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better if the LaunchResult returned the monoLaunchPath(if any) that it used, instead of passing the options.monoPath here. That is because the launcher is the one that must decide whatever mono launch path should be used and here we are always assuming that if a monoPath is set that will be the one used by the launcher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, that makes way more sense, not sure how I missed that. ☕️ ☕️ ☕️
Also no reason why the logging object should have optional arguments, fix that.
@akshita31 Logging fixed! 😄 |
@shana Thank you so much for patiently going through the feedback. |
@akshita31 Sorry, I didn't see your comment. Yay merge! I was not aware of the need to update the changelog manually, how does that work? It's just adding a new entry for the change? |
@shana Yes that is right. |
👋
When
useGlobalMono
is set toalways
orauto
, the launcher uses whatever mono it finds in the path, which may or may not be a usable mono version for omnisharp. The user may have a suitable mono installation for omnisharp somewhere else, but not set as the default system one, or they may want to have omnisharp launched with a specific mono for omnisharp for debugging purposes. In my case, I have:and I switch between them often, depending on what I need to do. Having vscode tied to whatever happens to be currently set on my system is really brittle, and if I need to have vscode use a particular mono version because of some mono bug, it's hard.
This PR adds a
monoPath
configuration option, and changes the launcher so that the environment variables PATH and MONO_GAC_PREFIX are changed to include themonoPath
value, if set, when launching mono. If themonoPath
option isn't set, it behaves as normal (also ifuseGlobalMono
is set tonever
). I figured maybe this is useful for other people out there too 😃