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

sendfile(): Invalid argument while installing #8041

Closed
spikeHollow opened this issue Jun 24, 2023 · 7 comments · Fixed by #8049 or ocaml/opam-repository#24007
Closed

sendfile(): Invalid argument while installing #8041

spikeHollow opened this issue Jun 24, 2023 · 7 comments · Fixed by #8049 or ocaml/opam-repository#24007
Assignees

Comments

@spikeHollow
Copy link

I'm starting to try ocaml by going through their installation process. I'm stuck here.

Expected Behavior

opam installs dune correctly

Actual Behavior

on invoking

#=== ERROR while compiling dune.3.8.2 =========================================#
# context     2.1.5 | linux/x86_64 | ocaml.5.0.0 | https://opam.ocaml.org#509ab4d9
# path        ~/.opam/default/.opam-switch/build/dune.3.8.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build ./_boot/dune.exe build dune.install --release --profile dune-bootstrap -j 7
# exit-code   1
# env-file    ~/.opam/log/dune-22736-950058.env
# output-file ~/.opam/log/dune-22736-950058.out
### output ###
# Error: sendfile(): Invalid argument
# -> required by _build/default/editor-integration/emacs/dune-flymake.el
# -> required by _build/install/default/share/emacs/site-lisp/dune-flymake.el
# -> required by _build/default/dune.install



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build dune 3.8.2
+- 
- No changes have been performed

Reproduction

I'm using Linux mint. This is my first time installation. I invoked these commands according to the docs from Ocaml website.
bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)"
opam init
opam install dune merlin ocaml-lsp-server odoc ocamlformat utop dune-release // here it gives error

@emillon
Copy link
Collaborator

emillon commented Jun 26, 2023

Hi,
Thanks for the report.

The following pieces of information will be useful:

  • can you try if it works with dune 3.7.1 (opam install dune.3.7.1). if it works, please also try 3.8.0 and 3.8.1
  • is your HOME directory a network mount like NFS?
  • can you install packages that do not use dune, for example you can try opam install fmt?
    Thanks

@emillon emillon self-assigned this Jun 26, 2023
@emillon emillon changed the title unable to install dune using opam sendfile(): Invalid argument while installing Jun 26, 2023
@emillon
Copy link
Collaborator

emillon commented Jun 26, 2023

Can you also report which version of mint you are using, as well as your kernel version (uname -a)? thanks

@emillon
Copy link
Collaborator

emillon commented Jun 26, 2023

I think what's happening is that in stdune/io, we detect that we're on linux, so we use the sendfile-based implementation, but the sendfile syscall returns EINVAL.

The manpage says:

Applications may wish to fall back to read(2) and write(2) in the case where sendfile() fails with EINVAL or ENOSYS.

So it's good to do that but I'm curious to see what's happening so that we can detect the situation more precisely.

@rgrinberg
Copy link
Member

@emillon Do you want to send a fix for this?

So it's good to do that but I'm curious to see what's happening so that we can detect the situation more precisely.

It can happen under many circumstances so I wouldn't worry about it. However, one example might be doing sendfile from an NFS mount.

emillon added a commit to emillon/dune that referenced this issue Jun 26, 2023
Signed-off-by: Etienne Millon <me@emillon.org>
@emillon
Copy link
Collaborator

emillon commented Jun 26, 2023

Yes. I added a test case in #8048. I was thinking of catching Unix_error here and calling copy_channels in the exception handler. Does that sound like a good fix?

emillon added a commit to emillon/dune that referenced this issue Jun 26, 2023
Signed-off-by: Etienne Millon <me@emillon.org>
@rgrinberg
Copy link
Member

Yes, that's the right way to do it.

@emillon emillon mentioned this issue Jun 26, 2023
16 tasks
emillon added a commit to emillon/dune that referenced this issue Jun 26, 2023
Fixes ocaml#8041

Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this issue Jun 26, 2023
Fixes ocaml#8041

Signed-off-by: Etienne Millon <me@emillon.org>
@emillon
Copy link
Collaborator

emillon commented Jun 26, 2023

I added a fix which should be available in the next version of dune. In the meantime, versions of dune before 3.8.0 should work.

emillon added a commit that referenced this issue Jun 26, 2023
Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this issue Jun 26, 2023
Fixes ocaml#8041

Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this issue Jun 27, 2023
Fixes ocaml#8041

Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit that referenced this issue Jun 27, 2023
Fixes #8041

Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this issue Jun 27, 2023
Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this issue Jun 27, 2023
Fixes ocaml#8041

Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this issue Jun 27, 2023
Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this issue Jun 27, 2023
Fixes ocaml#8041

Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/dune that referenced this issue Jun 27, 2023
Fixes ocaml#8041

Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit that referenced this issue Jun 27, 2023
* test: add repro for #8041 (#8048)

Signed-off-by: Etienne Millon <me@emillon.org>

* fix: sendfile: fall back to portable copy (#8049)

Fixes #8041

Signed-off-by: Etienne Millon <me@emillon.org>

---------

Signed-off-by: Etienne Millon <me@emillon.org>
emillon added a commit to emillon/opam-repository that referenced this issue Jun 27, 2023
CHANGES:

- Fix deadlock on Windows (ocaml/dune#8044, @nojb)

- When using `sendfile` to copy files on Linux, fall back to the portable
  version if it fails at runtime for some reason (NFS, etc).
  (ocaml/dune#8049, fixes ocaml/dune#8041, @emillon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants