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

opam init using the wrong wget #5597

Closed
runeimp opened this issue Jul 8, 2023 · 5 comments · Fixed by #5607 or #5606
Closed

opam init using the wrong wget #5597

runeimp opened this issue Jul 8, 2023 · 5 comments · Fixed by #5607 or #5606

Comments

@runeimp
Copy link

runeimp commented Jul 8, 2023

If your issue concerns a package not building, please report to
https://github.com/ocaml/opam-repository/issues or to the package maintainer
unless you are confident it is an issue in the opam tool itself.

$ opam config report
# opam config report
# opam-version         2.1.5 
# self-upgrade         no
# system               arch=x86_64 os=macos os-distribution=homebrew os-version=13.3
[ERROR] No switch is currently set. Please use 'opam switch' to set or install a switch
# read-state           OpamStd.OpamSys.Exit(50)

When I tried installing opam via Homebrew the initial installation seemed to go fine but when I tried to init...

$ opam init
No configuration file found, using built-in defaults.
Checking for available remotes: rsync and local, git, mercurial.
  - you won't be able to use darcs repositories unless you install the darcs command on your system.


<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><>  🐫 
Fatal error:
/usr/local/bin/opam: "create_process" failed on /usr/local/opt/wget: Permission denied

I have both wget and curl installed. Why is opam trying to use /usr/local/opt/wget, which is just a directory, instead of /usr/local/bin/wget which is in the PATH? Also if it is actually doing a check why doesn't it check if the path is an executable binary instead of just for existence?

I renamed the .opam directory for a "clean start" and tried OPAMFETCH=curl opam init on the command line. I also tried setting environment variables in my Bash config, restarting my terminal (KiTTY), checking my environment variables before testing, and I still get the same error.

1st config

export OPAMFETCH=curl

2nd Config

export OPAMFETCH=/usr/local/bin/wget

3rd Config

export OPAMFETCH=curl
export OPAMCURL=/usr/bin/curl

Each time I get the same error trying to execute /usr/local/opt/wget.

@rjbou
Copy link
Collaborator

rjbou commented Jul 18, 2023

Can you share the content of your path ? If opam looks at /usr/local/opt, it should be because it is in your path.
There is an issue that there is no check on directory vs file before doing permission check.

@runeimp
Copy link
Author

runeimp commented Jul 18, 2023

Yes, /usr/local/opt is in the PATH before /usr/local/bin. To be honest I should probably remove it from my PATH as it no longer seems to be a repository for binaries as it had been in the past for Homebrew. None-the-less, shouldn't the OPAM... environment variables take priority? What is the point of their existence if the system just checks the path and ignores them?

@rjbou
Copy link
Collaborator

rjbou commented Jul 19, 2023

I was responding to the first issue: the directory that is found as a command.
I didn't look yet at the second one, the OPAMFETCH one.

@rjbou
Copy link
Collaborator

rjbou commented Jul 19, 2023

On OPAMFETCH/OPAMCURL:

  • The 1st config should have worked. Can you share the output of your command with -vv? to see what is the tool used and its error.
  • The 2nd config doesn't work as you give only the full path to wget, and by default opam applies curl arguments, that are not understood by wget.
+ /usr/bin/wget "--write-out" "%{http_code}\\n" "--retry" "3" "--retry-delay" "2" "--user-agent" "opam/2.2.0~alpha" "-L" "-o" "opamroot/.opam-switch/sources/ago.0.4/ago-0.4.tar.gz.part" "--" "https://github.com/lindig/ocaml-ago/archive/0.4/ago-0.4.tar.gz"
- /usr/bin/wget: unrecognized option '--write-out'
- /usr/bin/wget: option '--retry' is ambiguous; possibilities: '--retry-connrefused' '--retry-on-host-error' '--retry-on-http-error'
- /usr/bin/wget: unrecognized option '--retry-delay'
- Usage: wget [OPTION]... [URL]...
- 
- Try `wget --help' for more options.
  • The 3rd config is an opam error too, OPAMCURL is not taken into account if OPAMFETCH is set.

@rjbou rjbou linked a pull request Jul 19, 2023 that will close this issue
2 tasks
@rjbou
Copy link
Collaborator

rjbou commented Jul 19, 2023

The main issue should be fixed by #5606, and the 3rd config error by #5607.
Can you check with the PRs?

@rjbou rjbou linked a pull request Jul 24, 2023 that will close this issue
1 task
@kit-ty-kate kit-ty-kate added this to the 2.2.0~alpha3 milestone Sep 12, 2023
@kit-ty-kate kit-ty-kate added this to Done in Opam 2.2.0 Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Opam 2.2.0
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants