Only add ruby in $PATH, do not overwrite /usr/bin/ruby
* Fixes https://github.com/actions/setup-ruby/issues/18 * The symlink never worked on macOS, and there was a missing `await`. * No tool should hardcode `/usr/bin/ruby`, but instead executables should use `#!/usr/bin/env ruby`. * If a specific tool needs the symlink, then it can of course be added as part of the steps of that CI.
This commit is contained in:
@@ -16,10 +16,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const exec = __importStar(require("@actions/exec"));
|
|
||||||
const tc = __importStar(require("@actions/tool-cache"));
|
const tc = __importStar(require("@actions/tool-cache"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
|
||||||
function findRubyVersion(version) {
|
function findRubyVersion(version) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const installDir = tc.find('Ruby', version);
|
const installDir = tc.find('Ruby', version);
|
||||||
@@ -27,13 +25,6 @@ function findRubyVersion(version) {
|
|||||||
throw new Error(`Version ${version} not found`);
|
throw new Error(`Version ${version} not found`);
|
||||||
}
|
}
|
||||||
const toolPath = path.join(installDir, 'bin');
|
const toolPath = path.join(installDir, 'bin');
|
||||||
if (!IS_WINDOWS) {
|
|
||||||
// Ruby / Gem heavily use the '#!/usr/bin/ruby' to find ruby, so this task needs to
|
|
||||||
// replace that version of ruby so all the correct version of ruby gets selected
|
|
||||||
// replace the default
|
|
||||||
const dest = '/usr/bin/ruby';
|
|
||||||
exec.exec('sudo ln', ['-sf', path.join(toolPath, 'ruby'), dest]); // replace any existing
|
|
||||||
}
|
|
||||||
core.addPath(toolPath);
|
core.addPath(toolPath);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
|
||||||
|
|
||||||
export async function findRubyVersion(version: string) {
|
export async function findRubyVersion(version: string) {
|
||||||
const installDir: string | null = tc.find('Ruby', version);
|
const installDir: string | null = tc.find('Ruby', version);
|
||||||
|
|
||||||
@@ -14,13 +11,5 @@ export async function findRubyVersion(version: string) {
|
|||||||
|
|
||||||
const toolPath: string = path.join(installDir, 'bin');
|
const toolPath: string = path.join(installDir, 'bin');
|
||||||
|
|
||||||
if (!IS_WINDOWS) {
|
|
||||||
// Ruby / Gem heavily use the '#!/usr/bin/ruby' to find ruby, so this task needs to
|
|
||||||
// replace that version of ruby so all the correct version of ruby gets selected
|
|
||||||
// replace the default
|
|
||||||
const dest: string = '/usr/bin/ruby';
|
|
||||||
exec.exec('sudo ln', ['-sf', path.join(toolPath, 'ruby'), dest]); // replace any existing
|
|
||||||
}
|
|
||||||
|
|
||||||
core.addPath(toolPath);
|
core.addPath(toolPath);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user