Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
26 changes: 23 additions & 3 deletions packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1274,9 +1274,29 @@ export async function copyTracedFiles(
if (symlink) {
try {
await fs.symlink(symlink, fileOutputPath)
} catch (e: any) {
if (e.code !== 'EEXIST') {
throw e
} catch (err: any) {
// Windows doesn't support creating symlinks without elevated privileges, unless
// "Developer Mode" is turned on. If we failed to crate a symlink due to EPERM, try
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo in comment: "crate" should be "create". While this is just a comment, it should be fixed for clarity.

Fix:

// Windows doesn't support creating symlinks without elevated privileges, unless
// "Developer Mode" is turned on. If we failed to create a symlink due to EPERM, try
Suggested change
// "Developer Mode" is turned on. If we failed to crate a symlink due to EPERM, try
// "Developer Mode" is turned on. If we failed to create a symlink due to EPERM, try

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

// creating a junction point instead.
//
// Ideally we'd just preserve the input file type (junction point or symlink), but
// there's no API in node.js to differentiate between a junction point and a symlink,
// so we just try making a symlink first. Symlinks are preferred because they support
// relative paths and non-directory (file) targets.
if (
process.platform === 'win32' &&
err.code === 'EPERM' &&
path.isAbsolute(symlink)
) {
try {
await fs.symlink(symlink, fileOutputPath, 'junction')
} catch (junctionErr: any) {
if (junctionErr.code !== 'EEXIST') {
throw junctionErr
}
}
} else if (err.code !== 'EEXIST') {
throw err
}
}
} else {
Expand Down
5 changes: 4 additions & 1 deletion turbopack/crates/turbo-tasks-fs/src/attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ impl FileSystem for AttachedFileSystem {
path: FileSystemPath,
target: Vc<LinkContent>,
) -> Result<Vc<()>> {
Ok(self.get_inner_fs_path(path).await?.write_link(target))
Ok(self
.get_inner_fs_path(path)
.await?
.write_symbolic_link_dir(target))
}

#[turbo_tasks::function]
Expand Down
Loading
Loading