Skip to content

rustpkg: Failing on rename between cross-device #9887

Closed
@dpc

Description

@dpc
Contributor

I've found what could be the reason why rustpkg does not work on my system that I've reported in the comments to: http://tim.dreamwidth.org/1820526.html

[pid 25620] stat("/home/dpc/lab/rust/.rust/src/github.com/steveklabnik", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
[pid 25620] rename("/tmp/jYDYGA3OTuHfMQwLrustpkg/rustpkg_temp", "/home/dpc/lab/rust/.rust/src/github.com/steveklabnik/hello") = -1 EXDEV (Invalid cross-device link)
[pid 25620] write(2, "task <unnamed> failed at 'Unhand"..., 381task <unnamed> failed at 'Unhandled condition: nonexistent_package: (package_id::PkgId{path: std::path::PosixPath{is_absolute: false, components: ~[~"github.com", ~"steveklabnik", ~"hello"]}, short_name: ~"hello", version: NoVersion}, ~"supplied path for package dir does not exist, and couldn't interpret it as a URL fragment")', /home/dpc/opt/src/rust/src/libstd/condition.rs:131) = 381

Activity

huonw

huonw commented on Oct 16, 2013

@huonw
Member

cc @catamorphism, seems similar to/the same as #9781.

dpc

dpc commented on Oct 16, 2013

@dpc
ContributorAuthor

BTW. My attempt to fix the issue:

diff --git a/src/librustpkg/package_source.rs b/src/librustpkg/package_source.rs
index c2fddaf..f693a49 100644
--- a/src/librustpkg/package_source.rs
+++ b/src/librustpkg/package_source.rs
@@ -202,7 +202,7 @@ impl PkgSrc {
             // Since the operation succeeded, move clone_target to local.
             // First, create all ancestor directories.
             if make_dir_rwx_recursive(&local.pop())
-                && os::rename_file(&clone_target, local) {
+                && os::copy_file(&clone_target, local) {
                  Some(local.clone())
             }
             else {

Does not work neither. It seems I'm getting empty file (size == 0).

[mutex:lab/rust]% ls -alh /home/dpc/lab/rust/.rust/src/github.com/steveklabnik/hello-0.1
-rwxrwxr-x 1 dpc dpc 0 paź 15 22:46 /home/dpc/lab/rust/.rust/src/github.com/steveklabnik/hello-0.1
dpc

dpc commented on Oct 19, 2013

@dpc
ContributorAuthor
diff --git a/src/librustpkg/package_source.rs b/src/librustpkg/package_source.rs
index c2fddaf..00a764b 100644
--- a/src/librustpkg/package_source.rs
+++ b/src/librustpkg/package_source.rs
@@ -170,7 +170,7 @@ impl PkgSrc {
         // We use a temporary directory because if the git clone fails,
         // it creates the target directory anyway and doesn't delete it

-        let scratch_dir = extra::tempfile::mkdtemp(&os::tmpdir(), "rustpkg");
+        let scratch_dir = extra::tempfile::mkdtemp(&Path(&"/home/dpc/lab/rust/tmp"), "rustpkg");
         let clone_target = match scratch_dir {
             Some(d) => d.push("rustpkg_temp"),
             None    => cond.raise(~"Failed to create temporary directory for fetching git sources")

This works, so it confirms the problem is using rename to move files between filesystems. This will not work with every system that has /tmp mounted eg. as ramfs.

catamorphism

catamorphism commented on Oct 19, 2013

@catamorphism
Contributor

Thanks for the update, @dpc -- another workaround is to set TMPDIR in the environment to something under your /home.

dpc

dpc commented on Oct 19, 2013

@dpc
ContributorAuthor

@catamorphism: Ah! Yes, I forgot about this.

ATM, I'm looking for why did copy_file fail. Am I right, that it should just work?

dpc

dpc commented on Oct 19, 2013

@dpc
ContributorAuthor

OK. I've figured it out. #9947 . Now that puzzle is solved, I might happily enjoy rustpkg command. :)

derekchiang

derekchiang commented on Jan 27, 2014

@derekchiang
Contributor

I see two ways to resolve this issue:

  1. Use something like ./.rust/tmp as the temporary directory by default.
  2. When seeing this IO error, degrade to copying and deleting the source folder, instead of renaming.

Thoughts?

derekchiang

derekchiang commented on Jan 27, 2014

@derekchiang
Contributor

Also, this actually is a libuv issue. The same error can be reproduced with Node, as described here.

alexcrichton

alexcrichton commented on Feb 5, 2014

@alexcrichton
Member

Closing, rustpkg was removed.

added a commit that references this issue on Jan 12, 2023

Auto merge of rust-lang#10141 - FoseFx:fosefx/9887, r=Jarcho

8b1ac45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @dpc@alexcrichton@catamorphism@huonw@derekchiang

        Issue actions

          rustpkg: Failing on rename between cross-device · Issue #9887 · rust-lang/rust