asdf-vm / asdf-erlang

Erlang plugin for asdf version manager
https://github.com/asdf-vm/asdf
MIT License
475 stars 118 forks source link

erl -man <module name> doesn't work #310

Open jrfondren opened 4 months ago

jrfondren commented 4 months ago

Previously reported and fixed in #22

$ asdf install erlang 26.2.5
asdf_26.2.5 is not a kerl-managed Erlang/OTP installation
No build named asdf_26.2.5
Downloading 26.2.5 to /home/jrfondren/.asdf/downloads/erlang/26.2.5...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  101M  100  101M    0     0  19.3M      0  0:00:05  0:00:05 --:--:-- 21.1M
Extracting source code
Building Erlang/OTP 26.2.5 (asdf_26.2.5), please wait...
[packages] Unknown Linux distro rocky; not checking build packages.
Building docs...
Erlang/OTP 26.2.5 (asdf_26.2.5) has been successfully built
Cleaning up compilation products for asdf_26.2.5
Cleaned up compilation products for asdf_26.2.5 under /home/jrfondren/.asdf/plugins/erlang/kerl-home/builds
$ which erl
~/.asdf/shims/erl
$ erl -s init stop
Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

$ erl -man erl
No manual entry for erl
$ fop |head -3
FOP Version SVN

USAGE

A strace of erl -man erl shows it trying

15:41:19 openat(AT_FDCWD, "/home/jrfondren/.asdf/installs/erlang/26.2.5/man", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
15:41:19 newfstatat(AT_FDCWD, "/home/jrfondren/.asdf/installs/erlang/26.2.5/man", 0x7ffc52e1d130, 0) = -1 ENOENT (No such file or directory)

The only 'man' directory under ~/.asdf that I have is empty, ~/.asdf/installs/erlang/26.2.5/erts-14.2.5/man

workaround

Open module documentation with xdg-open https://www.erlang.org/doc/man/$module instead. I.e.,

$ function erlman() { xdg-open https://www.erlang.org/doc/man/$1; }
$ erlman erl  # opens the 'erl' manpage in another tab of the default browser

Manpages have many advantages that this misses, such as always being for the correct version of Erlang.

post-build fix

$ function getman() { wget https://github.com/erlang/otp/releases/download/OTP-$1/otp_doc_man_$1.tar.gz && tar -C ~/.asdf/installs/erlang/$1/ -zxvf otp_doc_man_$1.tar.gz && rm -fv otp_doc_man_$1.tar.gz; }
$ getman 26.2.5
$ getman 27.0-rc3
03juan commented 4 months ago

There's a very recent upstream fix in kerl/kerl#520 for this, currently only on the main branch.

You can recompile with

$ export ASDF_KERL_VERSION=master
export KERL_BUILD_DOCS=yes
export KERL_DOC_TARGETS="chunks man"
export KERL_INSTALL_MANPAGES=yes

$ asdf install erlang 26.2.5     
Downloading kerl...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 82416  100 82416    0     0  1787k      0 --:--:-- --:--:-- --:--:-- 1829k
ERROR: 'asdf_26.2.5' is not a kerl-managed Erlang/OTP installation.
ERROR: no build named 'asdf_26.2.5'!
Downloading (from GitHub) Erlang/OTP 26.2.5 to /home/juan/.asdf/downloads/erlang/26.2.5...
Extracting source code for normal build...
Building (normal) Erlang/OTP 26.2.5 (asdf_26.2.5); please wait...
Initializing (build) log file at /home/juan/.asdf/plugins/erlang/kerl-home/builds/asdf_26.2.5/otp_build_26.2.5.log.
Building docs...
Erlang/OTP 26.2.5 (asdf_26.2.5) has been successfully built.
Cleaning up compilation products for 'asdf_26.2.5' under:
  - /home/juan/.asdf/plugins/erlang/kerl-home/builds...
  - /home/juan/.asdf/downloads/erlang/26.2.5...
... done.

$ asdf global erlang 26.2.5
$ erl -man erl
erl(1)                                     User Commands                                    erl(1)

NAME
       erl - The Erlang emulator.
Stratus3D commented 4 months ago

Once a new version of kerl is tagged I'll get this fix into asdf-erlang.

hrubi commented 2 months ago

This seems to be fixed in 4468afe892d41ab8963de2e064048027d9dff9e3 by pulling in kerl 4.1.1.