Skip to content

opam pin fails on Windows #6472

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

Open
cometkim opened this issue Apr 13, 2025 · 6 comments
Open

opam pin fails on Windows #6472

cometkim opened this issue Apr 13, 2025 · 6 comments

Comments

@cometkim
Copy link

I trying to pin a package to a specific commit hash

opam pin add flow_parser git+https://github.com/rescript-lang/flow.git#d35a6f5c0cc219e85bbcb822d6f19ed9b2ec3448

This works well on my Linux/MacOS machine. But fails on Windows (GitHub actions)

opam pin add flow_parser https://github.com/rescript-lang/flow.git#d35a6f5c0cc219e85bbcb822d6f19ed9b2ec3448
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
Error:  Could not synchronize C:\Users\runneradmin\AppData\Local\opam\default\.opam-switch\sources\flow_parser from "git+https://github.com/rescript-lang/flow.git#d[3](https://github.com/cometkim/windows-action-test/actions/runs/14424847341/job/40452212688#step:6:3)5a6f5c0cc219e85bbcb822d6f19ed9b2ec3448":
        Git error: refs/remotes/opam-ref-d35a6f5c0cc219e85bbcb822d6f19ed9b2ec3[4](https://github.com/cometkim/windows-action-test/actions/runs/14424847341/job/40452212688#step:6:5)48 not found.
Error:  Error getting source from git+https://github.com/rescript-lang/flow.git#d35a6f5c0cc219e85bbcb822d6f19ed9b2ec3448:
          - git+https://github.com/rescript-lang/flow.git#d35a6f5c0cc219e85bbcb822d6f19ed9b2ec3448
[flow_parser.0.246.0] fetching sources failed: git+https://github.com/rescript-lang/flow.git#d3[5](https://github.com/cometkim/windows-action-test/actions/runs/14424847341/job/40452212688#step:6:6)a6f5c0cc219e85bbcb822d6f19ed9b2ec3448

https://github.com/cometkim/windows-action-test/actions/runs/14424847341/job/40452212688

@dra27
Copy link
Member

dra27 commented Apr 14, 2025

It's unfortunately obvious what's wrong when looking at the debug output:

+ C:\Program Files\Git\cmd\git.exe "reset" "--hard" "refs/remotes/opam-ref-d35a6f5c0cc219e85bbcb822d6f19ed9b2ec3448" "--" (CWD=C:\Users\DRA\AppData\Local\opam\issue6472\.opam-switch\sources\flow_parser)
fatal: cannot create directory at 'tests/long_directory_names/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path': Filename too long

@dra27
Copy link
Member

dra27 commented Apr 14, 2025

I don't think this has anything to do with pinning a sha - the issue is the path at https://github.com/rescript-lang/flow/tree/rescript/tests/long_directory_names/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path/really_long_path.

The fix here needs to be in the repo - committing a path that long is a bit like including non-Windows characters (e.g. filenames with : in them). I'd suggest it'd be better to generate that long path in the test harness

The repo is just cloneable on Windows - it's just that the opam root and where the repo is then cloned to makes it too long.

@dra27
Copy link
Member

dra27 commented Apr 14, 2025

We should probably surface the error message from Git more clearly, though!

@cometkim
Copy link
Author

Huh, I never expected that long path in the flow repository. Thank you for pointing it out!

@cometkim
Copy link
Author

Maybe it is dangerous for Windows users that opam enables core.longpaths=true in the current shell/project? Or it would be better if it at least prints a warning about it.

@cometkim
Copy link
Author

It's the same problem during the install process. This is the only error message I got

#=== ERROR while compiling flow_parser.0.267.0 ================================#
C:\hostedtoolcache\windows\opam\2.3.0\x86_64\opam.exe: "opendir" failed: No such file or directory

This has been resolved by removing the problematic directory.

I think it happened while scanning the dune file by dune build, which is configured as build: in the opam's manifest.

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

2 participants