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

Report inaccesible file on failed require #14263

Closed
p5pRT opened this issue Nov 21, 2014 · 7 comments
Closed

Report inaccesible file on failed require #14263

p5pRT opened this issue Nov 21, 2014 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 21, 2014

Migrated from rt.perl.org#123270 (status was 'resolved')

Searchable as RT123270$

@p5pRT
Copy link
Author

p5pRT commented Nov 21, 2014

From @ppisar

As was appended to [perl #113422], the error message due to an inaccessible
file while loading a module is confusing​:

  $ LANG=C perl -I/root -e 'require strict'
  Can't locate strict.pm​: Permission denied at -e line 1.

Attached patch improves the error message to be clear that /root/strict.pm is
the problematic file.

-- Petr

@p5pRT
Copy link
Author

p5pRT commented Nov 21, 2014

From @ppisar

0001-Report-inaccesible-file-on-failed-require.patch
From 8817b5dd0a5e8f6fb7ad1c7826f6724cc83348dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Fri, 21 Nov 2014 10:48:51 +0100
Subject: [PATCH] Report inaccesible file on failed require
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit 2433d39e6 (require should die if a file exists but can't be
read) made first failed opened file fatal as request in
[perl #113422]. However error message produced in that case is not
much helpful in identifying which file ound not been accessed:

    $ LANG=C perl -I/root -e 'require strict'
    Can't locate strict.pm:   Permission denied at -e line 1.

This patch adds the name of the failed file to the message to help
identify which @INC directory is erroneous:

    $ LANG=C ./perl -I/root -I./lib -e 'require strict'
    Can't locate strict.pm:   /root/strict.pm: Permission denied at -e line 1.

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 pp_ctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pp_ctl.c b/pp_ctl.c
index 59ad06e..4a20f34 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -4049,7 +4049,8 @@ PP(pp_require)
 	if (PL_op->op_type == OP_REQUIRE) {
 	    if(saved_errno == EMFILE || saved_errno == EACCES) {
 		/* diag_listed_as: Can't locate %s */
-		DIE(aTHX_ "Can't locate %s:   %s", name, Strerror(saved_errno));
+		DIE(aTHX_ "Can't locate %s:   %s: %s",
+		    name, tryname, Strerror(saved_errno));
 	    } else {
 	        if (namesv) {			/* did we lookup @INC? */
 		    AV * const ar = GvAVn(PL_incgv);
-- 
1.9.3

@p5pRT
Copy link
Author

p5pRT commented Nov 21, 2014

From @cpansprout

On Fri Nov 21 02​:16​:38 2014, ppisar wrote​:

As was appended to [perl #113422], the error message due to an
inaccessible
file while loading a module is confusing​:

$ LANG=C perl -I/root -e 'require strict'
Can't locate strict.pm​: Permission denied at -e line 1.

Attached patch improves the error message to be clear that
/root/strict.pm is
the problematic file.

-- Petr

Thank you. Applied as e2ce095.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Nov 21, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Nov 21, 2014

@cpansprout - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented Jun 2, 2015

From @khwilliamson

Thanks for submitting this ticket

The issue should be resolved with the release today of Perl v5.22, available at http​://www.perl.org/get.html
If you find that the problem persists, feel free to reopen this ticket

--
Karl Williamson for the Perl 5 porters team

@p5pRT p5pRT closed this as completed Jun 2, 2015
@p5pRT
Copy link
Author

p5pRT commented Jun 2, 2015

@khwilliamson - Status changed from 'pending release' to 'resolved'

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

1 participant