Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corepack "EACCES": Clearer Errors #343

Merged
merged 7 commits into from
Dec 29, 2023
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sources/folderUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import process from 'process';

import type {NodeError} from './nodeUtils';
import {UsageError} from 'clipanion';

export function getInstallFolder() {
if (process.env.COREPACK_HOME == null) {
Expand Down Expand Up @@ -52,6 +53,8 @@
} catch (error) {
if ((error as NodeError).code === `EEXIST`) {
continue;
} else if ((error as NodeError).code === `EACCES`) {
throw new UsageError(`Failed to create cache directory. Please ensure the user has write access to the target directory (${target}). If the user's home directory does not exist, create it first.`, {cause: error});

Check failure on line 57 in sources/folderUtils.ts

View workflow job for this annotation

GitHub Actions / Testing chores

Expected 1 arguments, but got 2.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arcanis it would maybe make sense to add support for this in Clipanion, no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new UsageError(`Failed to create cache directory. Please ensure the user has write access to the target directory (${target}). If the user's home directory does not exist, create it first.`, {cause: error});
// @ts-expect-error UsageError expects one argument
throw new UsageError(`Failed to create cache directory. Please ensure the user has write access to the target directory (${target}). If the user's home directory does not exist, create it first.`, {cause: error});

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now should we remove the cause: error?

} else {
throw error;
}
Expand Down
Loading