Skip to content

Commit 3bb852f

Browse files
authored
Merge pull request #308 from jpogran/GH-307-fix-path-resolution-on-nix-and-mac
(GH-307) Fix path resolution on mac and *nix
2 parents 36809e3 + 32a4a6b commit 3bb852f

File tree

3 files changed

+40
-41
lines changed

3 files changed

+40
-41
lines changed

src/configuration.ts

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class ConnectionConfiguration implements IConnectionConfiguration {
2626
this.debugFilePath = this.config['languageserver']['debugFilePath'];
2727
}
2828

29-
get puppetAgentDir(): string {
29+
get puppetBaseDir(): string {
3030
if (this.config['puppetAgentDir'] !== null) {
3131
return this.config['puppetAgentDir'];
3232
}
@@ -37,9 +37,12 @@ export class ConnectionConfiguration implements IConnectionConfiguration {
3737
if (process.env['PROCESSOR_ARCHITEW6432'] === 'AMD64') {
3838
programFiles = process.env['ProgramW6432'] || 'C:\\Program Files';
3939
}
40+
// On Windows we have a subfolder called 'Puppet' that has
41+
// every product underneath
4042
return path.join(programFiles, 'Puppet Labs', 'Puppet');
4143
default:
42-
return '/opt/puppetlabs/puppet';
44+
// On *nix we don't have a sub folder called 'Puppet'
45+
return '/opt/puppetlabs';
4346
}
4447
}
4548

@@ -61,34 +64,45 @@ export class ConnectionConfiguration implements IConnectionConfiguration {
6164
}
6265

6366
get puppetDir(): string {
64-
return path.join(this.puppetAgentDir, 'puppet');
67+
return path.join(this.puppetBaseDir, 'puppet');
6568
}
6669

6770
get facterDir(): string {
68-
return path.join(this.puppetAgentDir, 'facter');
71+
return path.join(this.puppetBaseDir, 'facter');
6972
}
7073

7174
get hieraDir(): string {
72-
return path.join(this.puppetAgentDir, 'hiera');
75+
return path.join(this.puppetBaseDir, 'hiera');
7376
}
7477

7578
get mcoDir(): string {
76-
return path.join(this.puppetAgentDir, 'mcollective');
79+
return path.join(this.puppetBaseDir, 'mcollective');
7780
}
7881

7982
get rubydir(): string {
80-
return path.join(this.puppetAgentDir, 'sys', 'ruby');
83+
switch(process.platform){
84+
case 'win32':
85+
return path.join(this.puppetBaseDir, 'sys', 'ruby');
86+
default:
87+
return path.join(this.puppetBaseDir, 'lib', 'ruby');
88+
}
89+
}
90+
91+
get sslCertDir(): string {
92+
return path.join(this.puppetDir, 'ssl', 'certs');
8193
}
8294

95+
get sslCertFile(): string {
96+
return path.join(this.puppetDir, 'ssl', 'cert.pem');
97+
}
98+
99+
// RUBYLIB=%PUPPET_DIR%\lib;%FACTERDIR%\lib;%HIERA_DIR%\lib;%RUBYLIB%
83100
get rubylib(): string {
84-
var p =
85-
path.join(this.puppetDir, 'lib') +
86-
this.pathEnvSeparator() +
87-
path.join(this.facterDir, 'lib') +
88-
this.pathEnvSeparator() +
89-
path.join(this.hieraDir, 'lib') +
90-
this.pathEnvSeparator() +
91-
path.join(this.mcoDir, 'lib');
101+
var p = new Array(
102+
path.join(this.puppetDir, 'lib'),
103+
path.join(this.facterDir, 'lib'),
104+
// path.join(this.hieraDir, 'lib'),
105+
).join(this.pathEnvSeparator());
92106

93107
if (process.platform === 'win32') {
94108
// Translate all slashes to / style to avoid puppet/ruby issue #11930
@@ -98,31 +112,16 @@ export class ConnectionConfiguration implements IConnectionConfiguration {
98112
return p;
99113
}
100114

101-
get sslCertDir(): string {
102-
return path.join(this.puppetDir, 'ssl', 'certs');
103-
}
104-
105-
get sslCertFile(): string {
106-
return path.join(this.puppetDir, 'ssl', 'cert.pem');
107-
}
108-
115+
// PATH=%PUPPET_DIR%\bin;%FACTERDIR%\bin;%HIERA_DIR%\bin;%PL_BASEDIR%\bin;%RUBY_DIR%\bin;%PL_BASEDIR%\sys\tools\bin;%PATH%
109116
get environmentPath(): string {
110-
return (
111-
path.join(this.puppetDir, 'bin') +
112-
this.pathEnvSeparator() +
113-
path.join(this.facterDir, 'bin') +
114-
this.pathEnvSeparator() +
115-
path.join(this.hieraDir, 'bin') +
116-
this.pathEnvSeparator() +
117-
path.join(this.mcoDir, 'bin') +
118-
this.pathEnvSeparator() +
119-
path.join(this.puppetAgentDir, 'bin') +
120-
this.pathEnvSeparator() +
121-
path.join(this.rubydir, 'bin') +
122-
this.pathEnvSeparator() +
123-
path.join(this.puppetAgentDir, 'sys', 'tools', 'bin') +
124-
this.pathEnvSeparator()
125-
);
117+
return new Array(
118+
path.join(this.puppetDir, 'bin'),
119+
path.join(this.facterDir, 'bin'),
120+
// path.join(this.hieraDir, 'bin'),
121+
path.join(this.puppetBaseDir, 'bin'),
122+
path.join(this.rubydir, 'bin'),
123+
path.join(this.puppetBaseDir, 'sys', 'tools', 'bin')
124+
).join(this.pathEnvSeparator());
126125
}
127126

128127
get languageServerPath(): string {

src/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface IConnectionConfiguration {
3030
timeout: number;
3131
enableFileCache: boolean;
3232
debugFilePath: string;
33-
puppetAgentDir: string;
33+
puppetBaseDir: string;
3434
languageServerPath: string;
3535
rubydir: string;
3636
rubylib: string;

src/rubyHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class RubyHelper {
5252
result.options.env.RUBYLIB = '';
5353
}
5454
result.options.env.RUBY_DIR = connectionConfiguration.rubydir;
55-
result.options.env.PATH =connectionConfiguration.environmentPath + result.options.env.PATH;
55+
result.options.env.PATH =connectionConfiguration.environmentPath + this.pathEnvSeparator() + result.options.env.PATH;
5656
result.options.env.RUBYLIB = connectionConfiguration.rubylib + this.pathEnvSeparator() + result.options.env.RUBYLIB;
5757
result.options.env.RUBYOPT = 'rubygems';
5858
result.options.env.SSL_CERT_FILE = connectionConfiguration.sslCertFile;

0 commit comments

Comments
 (0)