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

File lock dependency on AsRawFd #10

Open
ravisha2396 opened this issue Sep 30, 2023 · 10 comments
Open

File lock dependency on AsRawFd #10

ravisha2396 opened this issue Sep 30, 2023 · 10 comments

Comments

@ravisha2396
Copy link

When one of my repositories requires file-lock as a dependency, the build always fails with the error below:

error[E0432]: unresolved import `std::os::fd::AsRawFd`
  --> /home/xxxxxx/.cargo/registry/src/github.com-1ecc6299db9ec823/file-lock-2.1.10/src/lib.rs:44:5
   |
44 | use std::os::fd::AsRawFd;
   |     ^^^^^^^^^^^^^^^^^^^^ no `AsRawFd` in `os::fd`

error[E0603]: module `fd` is private
   --> /home/xxxxxx/.cargo/registry/src/github.com-1ecc6299db9ec823/file-lock-2.1.10/src/lib.rs:44:14
    |
44  | use std::os::fd::AsRawFd;
    |              ^^ private module

I went ahead and checked my rust version which was 1.64.0 and in my sources I had only std::os::unix::io::fd::AsRAwFd available. Is this usual? I patched the lib.rs with this and it works fine but is this the intention? Does the import need to be updated? Or do I have the wrong version of Rust std library?

@alfiedotwtf
Copy link
Owner

Thanks for the issue. That's weird...

Ok, I'll have a look at this tonight.

@alfiedotwtf
Copy link
Owner

I've just compiled it successfully on Mac OS and Linux. As this crate is for POSIX advisory record locks, I have to ask - are you trying to build this on Windows? If so, it's not going to work there because Windows isn't a POSIX platform.

@ravisha2396
Copy link
Author

ravisha2396 commented Oct 3, 2023 via email

@alfiedotwtf
Copy link
Owner

Even more weird because that should have definitely worked then.

My Linux machine, rustc and cargo are both at 1.70.0, and Mac OS has them on 1.72.0.

How did you install Rust on that machine? If you used rustup, then we'll have to dive deeper because that's what I'm running and have been since file-lock was made 8 years ago.

@ravisha2396
Copy link
Author

ravisha2396 commented Oct 3, 2023 via email

@concatime
Copy link

Same issue on my side. 2.1.9 works, but not 2.1.10 with rustc 1.63.0:

   Compiling file-lock v2.1.10
error[E0432]: unresolved import `std::os::fd::AsRawFd`
  --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/file-lock-2.1.10/src/lib.rs:44:5
   |
44 | use std::os::fd::AsRawFd;
   |     ^^^^^^^^^^^^^^^^^^^^ no `AsRawFd` in `os::fd`

error[E0603]: module `fd` is private
  --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/file-lock-2.1.10/src/lib.rs:44:14
   |
44 | use std::os::fd::AsRawFd;
   |              ^^ private module
   |
note: the module `fd` is defined here

error[E0599]: no method named `as_raw_fd` found for struct `File` in the current scope
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/file-lock-2.1.10/src/lib.rs:105:42
    |
105 |         let errno = unsafe { c_lock(file.as_raw_fd(), is_blocking as i32, is_writeable as i32) };
    |                                          ^^^^^^^^^ method not found in `File`
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
39  | use std::os::unix::io::AsRawFd;
    |

error[E0599]: no method named `as_raw_fd` found for struct `File` in the current scope
   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/file-lock-2.1.10/src/lib.rs:144:49
    |
144 |         let errno = unsafe { c_unlock(self.file.as_raw_fd()) };
    |                                                 ^^^^^^^^^ method not found in `File`
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
39  | use std::os::unix::io::AsRawFd;
    |

Some errors have detailed explanations: E0432, E0599, E0603.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `file-lock` due to 4 previous errors

@concatime
Copy link

concatime commented Jan 26, 2024

@alfiedotwtf To help you reproduce the issue, I setuped a CI run on GitLab. As you can see, it fails on .10, and not on .9. I hope it helps.

@alfiedotwtf
Copy link
Owner

Hmm... I've been staring at this problem for a while now and I just can't work it out.

As of 1.66.0 std::os::fd is now stable, so there shouldn't be any reason this would fail?

https://github.com/rust-lang/rust/pull/98368
https://github.com/rust-lang/rust/issues/98699

And here's the canonical example:

https://doc.rust-lang.org/std/os/fd/trait.AsRawFd.html

If someone can cargo new --bin broken which does the bare minimum to make this break on their inux machine, I'll try to replicate it my side and then not sleep until this is resolved. Sorry for the long delay!

@alfiedotwtf
Copy link
Owner

Oh... scratch that, I just inspected your CI file. Ok cool, I'll run with this.

@alfiedotwtf
Copy link
Owner

hmm.. no matter what I did locally, I couldn't break it.

If @concatime could create a Dockerfile that I could run locally, I may be able to replicate it locally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants