timbunce / devel-nytprof

Devel::NYTProf is a powerful feature-rich source code profiler for Perl. (Mostly in maintenance mode, so PRs are much more likely to be acted upon than Issues.)
http://blog.timbunce.org/tag/nytprof/
68 stars 51 forks source link

Calling 'nytprofhtml' emits error messages about WSL interoperability. #221

Open jkeenan opened 2 months ago

jkeenan commented 2 months ago

I am encountering some problems in the execution of nytprofhtml on Ubuntu Linux 22.04 LTS. Here is my environment:

$ uname -a
Linux tpadx1 6.8.0-40-generic #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

$ perl -v | head -2 | tail -1
This is perl 5, version 40, subversion 0 (v5.40.0) built for x86_64-linux

$ perl -MDevel::NYTProf -E 'say $Devel::NYTProf::VERSION;' 2>/dev/null
6.14

I have a locally installed Perl program called get-pod-outline. It takes a single argument: a path to a POD file. I go to profile it.

$ perl -d:NYTProf /home/jkeenan/bin/perl/get-pod-outline /home/jkeenan/gitwork/perl/pod/perldelta.pod

[0906-01] 2066 $ nytprofhtml --open
Reading nytprof.out
Processing nytprof.out data
Writing line reports to nytprof directory
 100% ... 
Extracting subroutine call data ...
Extracting subroutine links
Generating subroutine stack flame graph ...
grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
WSL Interopability is disabled. Please enable it before using WSL.
grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory
[0906-01] 2067 $ [error] WSL Interoperability is disabled. Please enable it before using WSL.
/usr/bin/wslview: line 216: /mnt/c/Windows/System32/reg.exe: No such file or directory
/usr/bin/wslview: line 308: [: -ge: unary operator expected
[error] This protocol is not supported before version 1903.
^C

The program hangs here. Once I Ctrl-C, I get the files I expect in the nytprof/ subdirectory.

I have never attempted to install or use WSL interoperability on this Ubuntu 22.04 LTS machine, so I don't understand why I am getting these error messages. Moreover, I searched for WSL in my checkout of the master branch and came up with nothing.

Can anyone provide guidance?

choroba commented 2 months ago

Does it happen without --open, too?

jkeenan commented 2 months ago

Does it happen without --open, too?

No.

 $ nytprofhtml -o /tmp/0906-02
Reading nytprof.out
Processing nytprof.out data
Writing line reports to /tmp/0906-02 directory
 100% ... 
Extracting subroutine call data ...
Extracting subroutine links
Generating subroutine stack flame graph ...

$ ls -ltr 0906-02
total 2872
-rw-rw-r-- 1 jkeenan jkeenan   3380 Sep  6 13:05  style.css
-rw-rw-r-- 1 jkeenan jkeenan  37780 Sep  6 13:05  home-jkeenan-bin-perl-get-pod-outline-1-line.html
-rw-rw-r-- 1 jkeenan jkeenan 131949 Sep  6 13:05  warnings-pm-2-line.html
...
-rw-rw-r-- 1 jkeenan jkeenan   2850 Sep  6 13:06  packages-callgraph.dot
-rw-rw-r-- 1 jkeenan jkeenan  24832 Sep  6 13:06  subs-callgraph.dot
-rw-rw-r-- 1 jkeenan jkeenan  28225 Sep  6 13:06  index.html
drwxrwxr-x 3 jkeenan jkeenan   4096 Sep  6 13:06  js
choroba commented 2 months ago

No.

That means the problem probably comes from running the browser.

jkeenan commented 2 months ago

No.

That means the problem probably comes from running the browser.

A recognized problem, apparently.

commit 65cb2634f880985697210ca4dbebecc3cf9c90be
Author:     Tim Bunce <Tim.Bunce@pobox.com>
AuthorDate: Fri Jun 15 16:04:32 2012 +0000
Commit:     Tim Bunce <Tim.Bunce@pobox.com>
CommitDate: Fri Jun 15 16:04:32 2012 +0000

    Add --debug, add --open docs, use Browser::Open if available, rework related logic.

...    

It is likely that I never previously had occasion to run a freestanding instance of nytprofhtml. Out of time now; will have to debug further later.

shawnlaffan commented 1 week ago

I just tried on an Ubuntu 24.04 WSL2 instance with no browser installed. I don't get the same errors but it does fail to open.

There is an apparent hang but really there is some stderr that has printed past the command prompt. Hitting enter resets the prompt.

Reading nytprof.out
Processing nytprof.out data
Writing line reports to nytprof directory
 100% ...
Extracting subroutine call data ...
Extracting subroutine links
Generating subroutine stack flame graph ...
WARNING: You don't seem to have any mimeinfo.cache files.
Try running the update-desktop-database command. If you
don't have this command you should install the
desktop-file-utils package. This package is available from
http://freedesktop.org/wiki/Software/desktop-file-utils/
No applications found for mimetype: text/html
./usr/bin/open: 882: x-www-browser: not found
/usr/bin/open: 882: firefox: not found
/usr/bin/open: 882: iceweasel: not found
/usr/bin/open: 882: seamonkey: not found
/usr/bin/open: 882: mozilla: not found
/usr/bin/open: 882: epiphany: not found
/usr/bin/open: 882: konqueror: not found
/usr/bin/open: 882: chromium: not found
/usr/bin/open: 882: chromium-browser: not found
/usr/bin/open: 882: google-chrome: not found
/usr/bin/open: 882: www-browser: not found
/usr/bin/open: 882: links2: not found
/usr/bin/open: 882: elinks: not found
/usr/bin/open: 882: links: not found
/usr/bin/open: 882: lynx: not found
/usr/bin/open: 882: w3m: not found
xdg-open: no method available for opening 'nytprof/index.html'
Running xdg-open "nytprof/index.html" &
user@wsl_machine:/mnt/c/git/devel-nytprof$ WARNING: You don't seem to have any mimeinfo.cache files.
Try running the update-desktop-database command. If you
don't have this command you should install the
desktop-file-utils package. This package is available from
http://freedesktop.org/wiki/Software/desktop-file-utils/
No applications found for mimetype: text/html
./usr/bin/xdg-open: 882: x-www-browser: not found
/usr/bin/xdg-open: 882: firefox: not found
/usr/bin/xdg-open: 882: iceweasel: not found
/usr/bin/xdg-open: 882: seamonkey: not found
/usr/bin/xdg-open: 882: mozilla: not found
/usr/bin/xdg-open: 882: epiphany: not found
/usr/bin/xdg-open: 882: konqueror: not found
/usr/bin/xdg-open: 882: chromium: not found
/usr/bin/xdg-open: 882: chromium-browser: not found
/usr/bin/xdg-open: 882: google-chrome: not found
/usr/bin/xdg-open: 882: www-browser: not found
/usr/bin/xdg-open: 882: links2: not found
/usr/bin/xdg-open: 882: elinks: not found
/usr/bin/xdg-open: 882: links: not found
/usr/bin/xdg-open: 882: lynx: not found
/usr/bin/xdg-open: 882: w3m: not found
xdg-open: no method available for opening 'nytprof/index.html'

Trying with Ubuntu 20.04 gives this error:

Processing nytprof.out data
Writing line reports to nytprof directory
 100% ...
Extracting subroutine call data ...
Extracting subroutine links
Generating subroutine stack flame graph ...
Start : This command cannot be run due to the error: The system cannot find the file specified.
At line:1 char:1
+ Start "/mnt/c/git/devel-nytprof/nytprof/index.html"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

WSL2 details:

wsl --version
WSL version: 2.3.24.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.65
MSRDC version: 1.2.5620
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.22631.4317
shawnlaffan commented 1 week ago

And checking further, the original error seems related to the wslview utility, installed on Ubuntu as part of the wslu package.
https://manpages.ubuntu.com/manpages/focal/man1/wslview.1.html

When I install wslu on the Ubuntu 24.04 instance it opens the results in my Windows firefox browser when I call nytprofhtml --open.

WRT the original report, it does seem there is a fresh command prompt in the middle of the error logs ([0906-01] 2067 $).

So there is no issue in Devel::NYTProf per se given the command has completed.

Maybe stderr could be flushed on exit to avoid such overlaps, but that would entail capturing the results so they can be flushed? If so then Capture::Tiny would be one option.