Skip to content

Commit 5d9207b

Browse files
authored
Merge pull request #302 from jpogran/GH-201-fail-fast-without-agent
(GH-301) Fail fast if no agent installed
2 parents ae9126d + 2da91a6 commit 5d9207b

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ get notified automatically about any future extension updates!
140140

141141
## Experience a Problem?
142142

143+
### Puppet Agent Install
144+
145+
A commonly encountered problem is not having Puppet Agent installed on the computer you are running VSCode on. As noted in the [Requirements section](https://github.com/lingua-pupuli/puppet-vscode/blob/master/README.md#requirements), you will need to have Puppet Agent installed in order to fully use this extension, as the extension uses the Puppet binaries and the Ruby language bundled into the agent install in order to function.
146+
147+
If you are receiving an error right after opening a Puppet file saying that a Puppet Agent install could not be found, ensure that Puppet is installed on the system. The VSCode extension attempts to find a valid Puppet install if a path is not configured in `puppet.puppetAgentDir` in `User Settings`, so if Puppet is installed but not in a default path please check that your setting points to the correct path.
148+
149+
### Reloading the Puppet VSCode extension
150+
143151
If you haven't see the Problems Pane update in awhile, or hover and intellisense doesn't seem to showing up, and you might not know what to do. Sometimes the Puppet extension can experience problems which cause the language server to crash or not respond. The extension has a way of logging the crash, but there is something you can do to get right back to working: reload the Puppet Language Server.
144152

145153
You can reload the Puppet Lanuguage Server by opening the command palette and starting to type `Puppet`. A list of Puppet commands will appear, select `Puppet: Restart Current Session`. This will restart the Puppet Language Server without reloading VSCode or losing any work currently open in the editor.

src/extension.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
import * as vscode from 'vscode';
4+
import * as fs from 'fs';
45

56
import { ConnectionManager } from './connection';
67
import { ConnectionConfiguration } from './configuration';
@@ -25,20 +26,44 @@ export function activate(context: vscode.ExtensionContext) {
2526
var logger = new OutputChannelLogger();
2627
var statusBar = new PuppetStatusBar(langID);
2728
var configSettings = new ConnectionConfiguration(context);
28-
29-
connManager = new ConnectionManager(context, logger, statusBar, configSettings);
3029

30+
if (!fs.existsSync(configSettings.puppetDir)) {
31+
logger.error('Could not find a valid Puppet installation at ' + configSettings.puppetDir);
32+
vscode.window
33+
.showErrorMessage(
34+
`Could not find a valid Puppet installation at '${
35+
configSettings.puppetDir
36+
}'. While syntax highlighting and grammar detection will still work, intellisense and other advanced features will not.`,
37+
{ modal: false },
38+
{ title: 'Troubleshooting Information' }
39+
)
40+
.then(item => {
41+
if (item === undefined) {
42+
return;
43+
}
44+
if (item.title === 'Troubleshooting Information') {
45+
vscode.commands.executeCommand(
46+
'vscode.open',
47+
vscode.Uri.parse('https://github.com/lingua-pupuli/puppet-vscode#experience-a-problem')
48+
);
49+
}
50+
});
51+
return null;
52+
} else {
53+
logger.debug('Found a valid Puppet installation at ' + configSettings.puppetDir);
54+
}
55+
56+
connManager = new ConnectionManager(context, logger, statusBar, configSettings);
3157

3258
if (!commandsRegistered) {
3359
logger.debug('Configuring commands');
3460

3561
setupPuppetCommands(langID, connManager, context, logger);
3662

3763
terminal = vscode.window.createTerminal('Puppet PDK');
38-
terminal.processId.then(
39-
pid => {
40-
logger.debug("pdk shell started, pid: " + pid);
41-
});
64+
terminal.processId.then(pid => {
65+
logger.debug('pdk shell started, pid: ' + pid);
66+
});
4267
setupPDKCommands(langID, connManager, context, logger, terminal);
4368
context.subscriptions.push(terminal);
4469

0 commit comments

Comments
 (0)