Skip to content

Difficult errors when no appropriate GHC is found #541

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

Closed
hasufell opened this issue Mar 13, 2022 · 4 comments
Closed

Difficult errors when no appropriate GHC is found #541

hasufell opened this issue Mar 13, 2022 · 4 comments

Comments

@hasufell
Copy link
Member

hasufell commented Mar 13, 2022

If HLS is managed by the extension, but there is no ghc in PATH and no ghc-<project-version> either, then the error is:

nhFdDx7


If HLS is managed by the extension and only a project-incompatible ghc is in PATH, hie-bios seems to detect a wrong project GHC version (with-compiler: ghc-8.10.7 is set in this project):

https://user-images.githubusercontent.com/1241845/158057243-dffe75f1-9351-4d8e-94ce-14df428126dc.png

Apparently this is fixed in master hie-bios, see new error below

@fendor

@hasufell hasufell changed the title Difficult errors when no approrpiate GHC is found Difficult errors when no appropriate GHC is found Mar 13, 2022
@hasufell
Copy link
Member Author

haskell/hie-bios#340

@hasufell
Copy link
Member Author

Alright, latest hie-bios doesn't have the second error, but it's still not very informative:

Screenshot_2022-03-13_12-51-13

@hasufell
Copy link
Member Author

There appears to be some code:

class MissingToolError extends Error {
public readonly tool: string;
constructor(tool: string) {
let prettyTool: string;
switch (tool) {
case 'stack':
prettyTool = 'Stack';
break;
case 'cabal':
prettyTool = 'Cabal';
break;
case 'ghc':
prettyTool = 'GHC';
break;
default:
prettyTool = tool;
break;
}
super(`Project requires ${prettyTool} but it isn't installed`);
this.tool = prettyTool;
}
public installLink(): Uri | null {
switch (this.tool) {
case 'Stack':
return Uri.parse('https://docs.haskellstack.org/en/stable/install_and_upgrade/');
case 'Cabal':
case 'GHC':
return process.platform === 'win32'
? Uri.parse('https://www.haskell.org/platform/index.html#windows')
: Uri.parse('https://www.haskell.org/ghcup/');
default:
return null;
}
}
}

But we deleted some of the try-catch:

} catch (error) {
if (error instanceof MissingToolError) {
const link = error.installLink();
if (link) {
if (await window.showErrorMessage(error.message, `Install ${error.tool}`)) {
env.openExternal(link);
}
} else {
await window.showErrorMessage(error.message);
}
} else if (error instanceof NoBinariesError) {
window.showInformationMessage(error.message);
} else if (error instanceof Error) {
// We couldn't figure out the right ghc version to download
window.showErrorMessage(`Couldn't figure out what GHC version the project is using: ${error.message}`);
}

I'm not entirely sure what this object hierarchy does.

@hasufell
Copy link
Member Author

Fixed in #543

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

No branches or pull requests

1 participant