Skip to content

Commit f31190c

Browse files
committed
Use a different default path for esy prefix
On Windows, we ran into EXDEV issues when the cache drive and working directory drive is different. When $HOME is changed to D:/ on Windows, cache restore fails too ``` ../../../.esy/3____________________________________________________________________________/i/esy_openssl-20afd0e0/share/man/man7/Ed448.7: Can't create '\\\\?\\D:\\a\\dream-web-server-sessions\\dream-web-server-sessions\\..\\..\\..\\.esy\\3____________________________________________________________________________\\i\\esy_openssl-20afd0e0\\share\\man\\man7\\Ed448.7' ../../../.esy/3____________________________________________________________________________/i/esy_openssl-20afd0e0/share/man/man7/X448.7: Can't create '\\\\?\\D:\\a\\dream-web-server-sessions\\dream-web-server-sessions\\..\\..\\..\\.esy\\3____________________________________________________________________________\\i\\esy_openssl-20afd0e0\\share\\man\\man7\\X448.7' ../../../.esy/3____________________________________________________________________________/i/esy_openssl-20afd0e0/share/man/man3/ACCESS_DESCRIPTION_free.3: Can't create '\\\\?\\D:\\a\\dream-web-server-sessions\\dream-web-server-sessions\\..\\..\\..\\.esy\\3____________________________________________________________________________\\i\\esy_openssl-20afd0e0\\share\\man\\man3\\ACCESS_DESCRIPTION_free.3' ../../../.esy/3____________________________________________________________________________/i/esy_openssl-20afd0e0/share/man/man3/ACCESS_DESCRIPTION_new.3: Can't create '\\\\?\\D:\\a\\dream-web-server-sessions\\dream-web-server-sessions\\..\\..\\..\\.esy\\3____________________________________________________________________________\\i\\esy_openssl-20afd0e0\\share\\man\\man3\\ACCESS_DESCRIPTION_new.3' ../../../.esy/3____________________________________________________________________________/i/esy_openssl-20afd0e0/share/man/man3/ADMISSIONS_free.3: Can't create '\\\\?\\D:\\a\\dream-web-server-sessions\\dream-web-server-sessions\\..\\..\\..\\.esy\\3____________________________________________________________________________\\i\\esy_openssl-20afd0e0\\share\\man\\man3\\ADMISSIONS_free.3' ../../../.esy/3____________________________________________________________________________/i/esy_openssl-20afd0e0/share/man/man3/ADMISSIONS_get0_admissionAuthority.3: Can't create '\\\\?\\D:\\a\\dream-web-server-sessions\\dream-web-server-sessions\\..\\..\\..\\.esy\\3____________________________________________________________________________\\i\\esy_openssl-20afd0e0\\share\\man\\man3\\ADMISSIONS_get0_admissionAuthority.3' ```
1 parent e8e6672 commit f31190c

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

dist/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -176095,7 +176095,10 @@ function main() {
176095176095
esyPrefix =
176096176096
esyPrefix && esyPrefix !== ""
176097176097
? esyPrefix
176098-
: external_path_.join(external_os_.homedir(), ".esy");
176098+
: external_path_.join(external_path_.dirname(process.env.GITHUB_WORKSPACE ||
176099+
process.env.HOME ||
176100+
process.env.HOMEPATH ||
176101+
"~"), ".esy");
176099176102
const installPath = [`${esyPrefix}/source`];
176100176103
const installKey = `source-${index_platform}-${arch}-${sourceCacheKey}`;
176101176104
core.startGroup("Restoring install cache");

index.ts

+20-20
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ async function main() {
4747
process.env.GITHUB_WORKSPACE ||
4848
process.env.HOME ||
4949
process.env.HOMEPATH ||
50-
"~",
50+
"~"
5151
),
52-
".esy",
52+
".esy"
5353
);
5454
const installPath = [`${esyPrefix}/source`];
5555
const installKey = `source-${platform}-${arch}-${sourceCacheKey}`;
5656
core.startGroup("Restoring install cache");
5757
const installCacheKey = await cache.restoreCache(
5858
installPath,
5959
installKey,
60-
[],
60+
[]
6161
);
6262
if (installCacheKey) {
6363
console.log("Restored the install cache");
@@ -84,7 +84,7 @@ async function main() {
8484
const buildCacheKey = await cache.restoreCache(
8585
depsPath,
8686
buildKey,
87-
restoreKeys,
87+
restoreKeys
8888
);
8989
if (buildCacheKey) {
9090
console.log("Restored the build cache");
@@ -120,15 +120,15 @@ async function main() {
120120
async function uncompress(
121121
dest: string,
122122
tarFile: string,
123-
strip?: number,
123+
strip?: number
124124
): Promise<void> {
125125
return new Promise((resolve, reject) => {
126126
fs.createReadStream(tarFile)
127127
.pipe(
128128
tar.x({
129129
strip: strip,
130130
C: dest, // alias for cwd:'some-dir', also ok
131-
}),
131+
})
132132
)
133133
.on("close", () => resolve())
134134
.on("error", reject);
@@ -147,7 +147,7 @@ async function prepareNPMArtifacts() {
147147
const statusCmd = manifestKey ? `esy ${manifestKey} status` : "esy status";
148148
try {
149149
const manifestFilePath = JSON.parse(
150-
cp.execSync(statusCmd).toString(),
150+
cp.execSync(statusCmd).toString()
151151
).rootPackageConfigPath;
152152
const manifest = JSON.parse(fs.readFileSync(manifestFilePath).toString());
153153
if (manifest.esy.release) {
@@ -172,7 +172,7 @@ async function prepareNPMArtifacts() {
172172
// optional: how long to retain the artifact
173173
// if unspecified, defaults to repository/org retention settings (the limit of this value)
174174
retentionDays: 10,
175-
},
175+
}
176176
);
177177

178178
console.log(`Created artifact with id: ${id} (bytes: ${size}`);
@@ -203,19 +203,19 @@ async function bundleNPMArtifacts() {
203203
});
204204
await uncompress(folderPath, path.join(folderPath, "npm-tarball.tgz"), 1);
205205
return folderName;
206-
}),
206+
})
207207
);
208208
const artifactFolders = artifactFoldersList.reduce(
209209
(acc: string[], folderName: string) => {
210210
acc.push(folderName);
211211
return acc;
212212
},
213-
[],
213+
[]
214214
);
215215
const esyInstallReleaseJS = "esyInstallRelease.js";
216216
fs.cpSync(
217217
path.join(releaseFolder, artifactFoldersList[0], esyInstallReleaseJS),
218-
path.join(releaseFolder, esyInstallReleaseJS),
218+
path.join(releaseFolder, esyInstallReleaseJS)
219219
);
220220
console.log("Creating package.json");
221221
const possibleEsyJsonPath = path.join(workingDirectory, "esy.json");
@@ -229,21 +229,21 @@ async function bundleNPMArtifacts() {
229229
process.exit(1);
230230
}
231231
const mainPackageJson = JSON.parse(
232-
fs.readFileSync(`${mainPackageJsonPath}`).toString(),
232+
fs.readFileSync(`${mainPackageJsonPath}`).toString()
233233
);
234234
const bins = Array.isArray(mainPackageJson.esy.release.bin)
235235
? mainPackageJson.esy.release.bin.reduce(
236236
(acc: any, curr: string) =>
237237
Object.assign({ [curr]: "bin/" + curr }, acc),
238-
{},
238+
{}
239239
)
240240
: Object.keys(mainPackageJson.esy.release.bin).reduce(
241241
(acc, currKey) =>
242242
Object.assign(
243243
{ [currKey]: "bin/" + mainPackageJson.esy.release.bin[currKey] },
244-
acc,
244+
acc
245245
),
246-
{},
246+
{}
247247
);
248248
const rewritePrefix =
249249
mainPackageJson.esy &&
@@ -276,7 +276,7 @@ async function bundleNPMArtifacts() {
276276
].concat(artifactFolders),
277277
},
278278
null,
279-
2,
279+
2
280280
);
281281

282282
fs.writeFileSync(path.join(releaseFolder, "package.json"), packageJson, {
@@ -287,7 +287,7 @@ async function bundleNPMArtifacts() {
287287
console.log("Copying LICENSE");
288288
fs.copyFileSync(
289289
path.join(workingDirectory, "LICENSE"),
290-
path.join(releaseFolder, "LICENSE"),
290+
path.join(releaseFolder, "LICENSE")
291291
);
292292
} catch (e) {
293293
console.warn("No LICENSE found");
@@ -297,7 +297,7 @@ async function bundleNPMArtifacts() {
297297
console.log("Copying README.md");
298298
fs.copyFileSync(
299299
path.join(workingDirectory, "README.md"),
300-
path.join(releaseFolder, "README.md"),
300+
path.join(releaseFolder, "README.md")
301301
);
302302
} catch {
303303
console.warn("No LICENSE found");
@@ -308,7 +308,7 @@ async function bundleNPMArtifacts() {
308308
console.log("Copying postinstall.js from", releasePostInstallJS);
309309
fs.copyFileSync(
310310
releasePostInstallJS,
311-
path.join(releaseFolder, "postinstall.js"),
311+
path.join(releaseFolder, "postinstall.js")
312312
);
313313

314314
console.log("Creating placeholder files");
@@ -345,7 +345,7 @@ ECHO You need to have postinstall enabled`;
345345
// optional: how long to retain the artifact
346346
// if unspecified, defaults to repository/org retention settings (the limit of this value)
347347
retentionDays: 10,
348-
},
348+
}
349349
);
350350

351351
core.endGroup();

0 commit comments

Comments
 (0)