in rake-runner-agent/src/jetbrains/buildServer/agent/rakerunner/utils/RubySDKUtil.java [154:190]
public static void patchPathEnvForNonRvmOrSystemRvmSdk(@NotNull final RubySdk sdk,
@NotNull final ModifiableRunnerContext context)
throws RunBuildException, RakeTasksBuildService.MyBuildFailureException {
if (SdkUtil.isRvmSdk(sdk) && !sdk.isSystem()) {
// do nothing
return;
}
// Better to add sdk & gemsets bin folders to PATH. If bundler emulation is enabled
// and bundler overrides gem paths - these alternative paths should be used
final StringBuilder patchedPath = new StringBuilder();
// sdk bin folder
final File sdkBinFolder = sdk.getRubyExecutable().getParentFile();
if (sdkBinFolder != null) {
try {
patchedPath.append(jetbrains.buildServer.util.FileUtil.toSystemDependentName(sdkBinFolder.getCanonicalPath()));
} catch (IOException e) {
throw new RunBuildException(e);
}
}
// gempath bin folders
// use bundler gems root if it is defined! (i.e. we use bundle exec emulation with custom gem paths)
final String bundlerGemRoot = BundlerUtil.determineGemsRootsAccordingToBundlerSettings(sdk, context);
final String[] gemPaths = bundlerGemRoot == null ? sdk.getGemPaths() : new String[]{bundlerGemRoot};
// add to path
for (String gemPath : gemPaths) {
final String binFolderPath = jetbrains.buildServer.util.FileUtil.toSystemDependentName(gemPath + "/bin");
patchedPath.append(File.pathSeparatorChar).append(binFolderPath);
}
// add old $PATH
OSUtil.prependToPATHEnvVariable(patchedPath.toString(), context.getEnvParameters());
}