Skip Menu |

This queue is for tickets about the File-HomeDir CPAN distribution.

Report information
The Basics
Id: 122175
Status: rejected
Priority: 0/
Queue: File-HomeDir

People
Owner: Nobody in particular
Requestors: djerius [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



Subject: On Darwin::Cocoa, the create flag has no effect if the parent directory does not exist
The documentation for the methods which take a create flag reads: Passing a true value to this key will force the creation of the directory if it doesn't exist (remember that File::HomeDir's policy is to return undef if the directory doesn't exist). This isn't always true. For example, File::HomeDir->my_dist_data( 'File-HomeDir', { create => 1 } ); will not create a directory if File::HomeDir->my_data returns undef, which is the case on darwin if the "$USER/Library/Application Support" directory doesn't exist. I know of at least one package (PAUSE::Packages) which depends upon File::HomeDir->my_dist_data(..., { create => 1 } ) always returning a valid directory name, which is what the documentation indicates.
I do not understand what your request is. I tried: sudo -u _calendar perl -Mblib -MData::Dumper -MFile::HomeDir -le 'delete $ENV{HOME}; my $dd = File::HomeDir->my_dist_data( "File-HomeDir" ); print Dumper {dist_data => $dd}' an receive as expected and documented etc.: $VAR1 = { 'dist_data' => undef }; What do you expect File::HomeDir shall do or try? Fetch current privilege escalation code, run it and create some directories with super-power? Or throw an exception instead of returning undef?
On Fri Mar 09 12:42:28 2018, REHSACK wrote: Show quoted text
> I do not understand what your request is. > > I tried: > > sudo -u _calendar perl -Mblib -MData::Dumper -MFile::HomeDir -le > 'delete $ENV{HOME}; my $dd = File::HomeDir->my_dist_data( "File- > HomeDir" ); print Dumper {dist_data => $dd}' > > an receive as expected and documented etc.: > > $VAR1 = { > 'dist_data' => undef > }; > > What do you expect File::HomeDir shall do or try? Fetch current > privilege escalation code, run it and create some directories with > super-power? Or throw an exception instead of returning undef?
Why in the world are you deleting $ENV{HOME}? What does that have to do with my report? Why are you replying with sarcasm? I sent you a polite message and I expect to be treated politely, not with sarcasm. My report clearly states that the documentation is incorrect if if File::HomeDir->my_data returns undef, that on OS X, my_data refers to "$USER/Library/Application Support", and if that directory does not exist the create flag is ignored. To make it clear, here's an example: % sw_vers ProductName: Mac OS X ProductVersion: 10.10.5 BuildVersion: 14F2511 % ls -R Library % perl -MFile::HomeDir -e "File::HomeDir->my_dist_data( 'File-HomeDir', { create => 1 } );" % ls -R Library % mkdir "Library/Application Support" % perl -MFile::HomeDir -e "File::HomeDir->my_dist_data( 'File-HomeDir', { create => 1 } );" % ls -R Library Application Support Library/Application Support: Perl Library/Application Support/Perl: dist Library/Application Support/Perl/dist: File-HomeDir Library/Application Support/Perl/dist/File-HomeDir:
On Fri Mar 09 14:54:14 2018, DJERIUS wrote: Show quoted text
> On Fri Mar 09 12:42:28 2018, REHSACK wrote:
> > I do not understand what your request is. > > > > I tried: > > > > sudo -u _calendar perl -Mblib -MData::Dumper -MFile::HomeDir -le > > 'delete $ENV{HOME}; my $dd = File::HomeDir->my_dist_data( "File- > > HomeDir" ); print Dumper {dist_data => $dd}' > > > > an receive as expected and documented etc.: > > > > $VAR1 = { > > 'dist_data' => undef > > }; > > > > What do you expect File::HomeDir shall do or try? Fetch current > > privilege escalation code, run it and create some directories with > > super-power? Or throw an exception instead of returning undef?
> > > Why in the world are you deleting $ENV{HOME}? What does that have to > do with my report?
I strongly suggest 'man sudo' and keep calm. Show quoted text
> Why are you replying with sarcasm? I sent you a polite message and I > expect to be treated politely, not with sarcasm.
I don't know how polite a message is "Your code does XY since ages. I know that is something failing. Please do." Show quoted text
> My report clearly states that the documentation is incorrect if > if File::HomeDir->my_data returns undef, that on OS X, my_data refers > to > "$USER/Library/Application Support", and if that directory does not > exist the create flag > is ignored.
$a and $b and $c; if $a is false, $b and $c are not evaluated. This is called short circuit. Show quoted text
> To make it clear, here's an example: > > % sw_vers > ProductName: Mac OS X > ProductVersion: 10.10.5 > BuildVersion: 14F2511 > > % ls -R Library > > % perl -MFile::HomeDir -e "File::HomeDir->my_dist_data( 'File- > HomeDir', { create => 1 } );" > > % ls -R Library > > % mkdir "Library/Application Support" > > % perl -MFile::HomeDir -e "File::HomeDir->my_dist_data( 'File- > HomeDir', { create => 1 } );" > > % ls -R Library > Application Support > > Library/Application Support: > Perl > > Library/Application Support/Perl: > dist > > Library/Application Support/Perl/dist: > File-HomeDir > > Library/Application Support/Perl/dist/File-HomeDir:
This is the expected behavior. There is no statement, that my_data() is created unless exists - this would be weird anyway. In opposite, it is documented that my_data() will return undef unless the expected directory is existing. Mind the short circuit? Thanks for asking back. Best regards, Jens
On Fri Mar 09 15:02:35 2018, REHSACK wrote: Show quoted text
> On Fri Mar 09 14:54:14 2018, DJERIUS wrote:
> > On Fri Mar 09 12:42:28 2018, REHSACK wrote:
> > > I do not understand what your request is. > > > > > > I tried: > > > > > > sudo -u _calendar perl -Mblib -MData::Dumper -MFile::HomeDir -le > > > 'delete $ENV{HOME}; my $dd = File::HomeDir->my_dist_data( "File- > > > HomeDir" ); print Dumper {dist_data => $dd}' > > > > > > an receive as expected and documented etc.: > > > > > > $VAR1 = { > > > 'dist_data' => undef > > > }; > > > > > > What do you expect File::HomeDir shall do or try? Fetch current > > > privilege escalation code, run it and create some directories with > > > super-power? Or throw an exception instead of returning undef?
> > > > > > Why in the world are you deleting $ENV{HOME}? What does that have to > > do with my report?
> > I strongly suggest 'man sudo' and keep calm. >
> > Why are you replying with sarcasm? I sent you a polite message and I > > expect to be treated politely, not with sarcasm.
> > I don't know how polite a message is "Your code does XY since ages. I > know that is something failing. Please do."
I did not attack you, I did not attack your code, I did not impune your intelligence. I did nothing but point out a discrepancy in the documented behavior. I looked at the code to try and understand what was happening in the hopes that it would improve the quality of my report. I made no suggestion as to which was correct, the documentation or the behavior. That would be presumptuous. It's your code, your documentation. I cannot determine which is correct. Show quoted text
> > My report clearly states that the documentation is incorrect if > > if File::HomeDir->my_data returns undef, that on OS X, my_data refers > > to > > "$USER/Library/Application Support", and if that directory does not > > exist the create flag > > is ignored.
> > $a and $b and $c; > if $a is false, $b and $c are not evaluated. This is called short > circuit.
Show quoted text
> This is the expected behavior. There is no statement, that my_data() > is created unless exists - this would be weird anyway. In opposite, it > is documented that my_data() will return undef unless the expected > directory is existing. Mind the short circuit?
Please note that the call is to my_dist_data(), not my_data(). There is no documentation indicating that my_dist_data and my_data are related in any way. They are system dependent, so the user *cannot* make an assumption about their relationship. The user must depend upon the documentation. If my_dist_data( create => 1 ) will fail if my_data does not exist, then please document it.
On Fri Mar 09 15:41:38 2018, DJERIUS wrote: Show quoted text
> On Fri Mar 09 15:02:35 2018, REHSACK wrote:
> > On Fri Mar 09 14:54:14 2018, DJERIUS wrote:
> > > On Fri Mar 09 12:42:28 2018, REHSACK wrote:
> > > > I do not understand what your request is. > > > > > > > > I tried: > > > > > > > > sudo -u _calendar perl -Mblib -MData::Dumper -MFile::HomeDir -le > > > > 'delete $ENV{HOME}; my $dd = File::HomeDir->my_dist_data( "File- > > > > HomeDir" ); print Dumper {dist_data => $dd}' > > > > > > > > an receive as expected and documented etc.: > > > > > > > > $VAR1 = { > > > > 'dist_data' => undef > > > > }; > > > > > > > > What do you expect File::HomeDir shall do or try? Fetch current > > > > privilege escalation code, run it and create some directories > > > > with > > > > super-power? Or throw an exception instead of returning undef?
> > > > > > > > > Why in the world are you deleting $ENV{HOME}? What does that have > > > to > > > do with my report?
> > > > I strongly suggest 'man sudo' and keep calm. > >
> > > Why are you replying with sarcasm? I sent you a polite message and > > > I > > > expect to be treated politely, not with sarcasm.
> > > > I don't know how polite a message is "Your code does XY since ages. I > > know that is something failing. Please do."
> > I did not attack you, I did not attack your code, I did not impune > your intelligence. I did nothing but point out a discrepancy in the > documented behavior. I looked at the code to try and understand what > was happening in the hopes that it would improve the quality of my > report. I made no suggestion as to which was correct, the > documentation or the behavior. That would be presumptuous. It's your > code, your documentation. I cannot determine which is correct.
You didn't ask for clarification. You asked for fixing the assumption of Show quoted text
> I know of at least one package (PAUSE::Packages) which depends upon > > File::HomeDir->my_dist_data(..., { create => 1 } ) > > always returning a valid directory name, which is what the > documentation indicates.
And I told you, that the documentation doesn't promise that under any circumstance the complete path is created. Show quoted text
> > > My report clearly states that the documentation is incorrect if > > > if File::HomeDir->my_data returns undef, that on OS X, my_data > > > refers > > > to > > > "$USER/Library/Application Support", and if that directory does not > > > exist the create flag > > > is ignored.
> > > > $a and $b and $c; > > if $a is false, $b and $c are not evaluated. This is called short > > circuit.
> >
> > This is the expected behavior. There is no statement, that my_data() > > is created unless exists - this would be weird anyway. In opposite, > > it > > is documented that my_data() will return undef unless the expected > > directory is existing. Mind the short circuit?
> > Please note that the call is to my_dist_data(), not my_data().
Your initial post clearly states that you know that the behavior is caused by Show quoted text
> There > is no documentation indicating that my_dist_data and my_data are > related in any way.
That is in best case ignorance. Please re-read the documentation of both methods again. Show quoted text
> They are system dependent, so the user *cannot* > make an assumption about their relationship. The user must depend upon > the documentation. > > If my_dist_data( create => 1 ) will fail if my_data does not exist, > then please document it.
The documentation for my_dist_data says: Show quoted text
> ... This directory will be of course a subdirectory of C<my_data> ...
And further: Show quoted text
> ... remember that C<File::HomeDir>'s policy > is to return C<undef> if the directory doesn't exist ...
So please don't tell that it is not documented. You referred to that behavior in your initial post.
On Fri Mar 09 17:48:02 2018, REHSACK wrote: Show quoted text
> On Fri Mar 09 15:41:38 2018, DJERIUS wrote:
> > On Fri Mar 09 15:02:35 2018, REHSACK wrote:
> > > On Fri Mar 09 14:54:14 2018, DJERIUS wrote:
> > > > On Fri Mar 09 12:42:28 2018, REHSACK wrote:
> > > > > I do not understand what your request is. > > > > > > > > > > I tried: > > > > > > > > > > sudo -u _calendar perl -Mblib -MData::Dumper -MFile::HomeDir -le > > > > > 'delete $ENV{HOME}; my $dd = File::HomeDir->my_dist_data( "File- > > > > > HomeDir" ); print Dumper {dist_data => $dd}' > > > > > > > > > > an receive as expected and documented etc.: > > > > > > > > > > $VAR1 = { > > > > > 'dist_data' => undef > > > > > }; > > > > > > > > > > What do you expect File::HomeDir shall do or try? Fetch current > > > > > privilege escalation code, run it and create some directories > > > > > with > > > > > super-power? Or throw an exception instead of returning undef?
> > > > > > > > > > > > Why in the world are you deleting $ENV{HOME}? What does that have > > > > to > > > > do with my report?
> > > > > > I strongly suggest 'man sudo' and keep calm. > > >
> > > > Why are you replying with sarcasm? I sent you a polite message and > > > > I > > > > expect to be treated politely, not with sarcasm.
> > > > > > I don't know how polite a message is "Your code does XY since ages. I > > > know that is something failing. Please do."
> > > > I did not attack you, I did not attack your code, I did not impune > > your intelligence. I did nothing but point out a discrepancy in the > > documented behavior. I looked at the code to try and understand what > > was happening in the hopes that it would improve the quality of my > > report. I made no suggestion as to which was correct, the > > documentation or the behavior. That would be presumptuous. It's your > > code, your documentation. I cannot determine which is correct.
> > You didn't ask for clarification. You asked for fixing the assumption > of >
> > I know of at least one package (PAUSE::Packages) which depends upon > > > > File::HomeDir->my_dist_data(..., { create => 1 } ) > > > > always returning a valid directory name, which is what the > > documentation indicates.
> > And I told you, that the documentation doesn't promise that under > any circumstance the complete path is created. >
> > > > My report clearly states that the documentation is incorrect if > > > > if File::HomeDir->my_data returns undef, that on OS X, my_data > > > > refers > > > > to > > > > "$USER/Library/Application Support", and if that directory does not > > > > exist the create flag > > > > is ignored.
> > > > > > $a and $b and $c; > > > if $a is false, $b and $c are not evaluated. This is called short > > > circuit.
> > > >
> > > This is the expected behavior. There is no statement, that my_data() > > > is created unless exists - this would be weird anyway. In opposite, > > > it > > > is documented that my_data() will return undef unless the expected > > > directory is existing. Mind the short circuit?
> > > > Please note that the call is to my_dist_data(), not my_data().
> > Your initial post clearly states that you know that the behavior is > caused by
Show quoted text
>
> > There > > is no documentation indicating that my_dist_data and my_data are > > related in any way.
> > That is in best case ignorance. Please re-read the documentation > of both methods again.
I did not reread the documentation before writing this statement, and the statement is obviously completely wrong. I apologize. Show quoted text
>
> > They are system dependent, so the user *cannot* > > make an assumption about their relationship. The user must depend upon > > the documentation. > > > > If my_dist_data( create => 1 ) will fail if my_data does not exist, > > then please document it.
> > The documentation for my_dist_data says: >
> > ... This directory will be of course a subdirectory of C<my_data> ...
> > And further: >
> > ... remember that C<File::HomeDir>'s policy > > is to return C<undef> if the directory doesn't exist ...
> > So please don't tell that it is not documented. You referred > to that behavior in your initial post.
Clearly I am not interpreting the documentation as you intend it to be understood. Thank you for the clarification. I appreciate your efforts. Diab
The entire public documentation is written by Adam or one of his contributors. My only change was commit 2aac62af before I now take some more time digging into open tickets. So, the documentation did not change since Fri Oct 19 21:32:41 2012