Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions turbopack/crates/turbo-tasks-fs/src/attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,15 @@ impl FileSystem for AttachedFileSystem {
}

#[turbo_tasks::function(fs)]
async fn write_link(
async fn write_symbolic_link_dir(
self: Vc<Self>,
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
6 changes: 5 additions & 1 deletion turbopack/crates/turbo-tasks-fs/src/embed/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ impl FileSystem for EmbeddedFileSystem {
}

#[turbo_tasks::function]
fn write_link(&self, _path: FileSystemPath, _target: Vc<LinkContent>) -> Result<Vc<()>> {
fn write_symbolic_link_dir(
&self,
_path: FileSystemPath,
_target: Vc<LinkContent>,
) -> Result<Vc<()>> {
bail!("Writing is not possible to the embedded filesystem")
}

Expand Down
Loading
Loading