Skip Menu |
Report information
Id: 130456
Status: resolved
Priority: 0/
Queue: perl6

Owner: cpan [at] zoffix.com
Requestors: comdog <brian.d.foy [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



From: brian d foy <brian.d.foy [...] gmail.com>
Date: Fri, 30 Dec 2016 04:05:37 -0500
To: rakudobug [...] perl.org
Subject: $*HOME blows up if HOME isn't set
If the HOME environment variable is not set (say, as in non-interactive sessions), using $*HOME throws an exception: $ unset HOME $ echo $HOME $ perl6 -e 'put "HOME is $*HOME"' Use of uninitialized value of type Any in string context. Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful. in block <unit> at -e line 1 HOME is Curiously, $*TMPDIR is /tmp if the TMPDIR environment variable is not set. Maybe that's good and maybe not. But, trying to use homedir blows up the same way tmpdir does (https://rt.perl.org/Ticket/Display.html?id=130455): $ perl6 -e 'homedir( "/Users/brian" ); put "HOME is $*HOME"' No such method 'chdir' for invocant of type 'Any' in block <unit> at -e line 1 But, homedir isn't documented outside of S16 even though it appears to be there somewhere. Trying to set $*HOME directly doesn't work either, which is certainly perplexing: $ perl6 -e '$*HOME = "/Users/brian"; put "HOME is $*HOME"' Cannot modify an immutable Any in block <unit> at -e line 1 I can set a key is a completely different variable to get it to work: $ perl6 -e '%*ENV<HOME> = "/Users/brian"; put "HOME is $*HOME"' HOME is /Users/brian And I can even set it to a directory that does not exist: $ perl6 -e '%*ENV<HOME> = "/Users/brian/not-there"; put "HOME is $*HOME"' HOME is /Users/brian/not-there The $*HOME variable is listed in . If it isn't set, it's documented to be Nil, but it is apparently Any. That also appears to mess with the REPL: $ perl6 I ran into a problem while trying to set up Linenoise: Cannot resolve caller new(IO::Path: Any); none of these signatures match: (IO::Path $: Cool $path, :$SPEC = { ... }, :$CWD = { ... }, *%_) (IO::Path $: :$basename!, :$dirname = "", :$volume = "", :$SPEC = { ... }, :$CWD = { ... }, *%_) (IO::Path $: *%_) Continuing without tab completions or line editor You may want to consider using rlwrap for simple line editor functionality To exit type 'exit' or '^D' Show quoted text
> $*HOME
(Any) Show quoted text
>
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 3.4k
On Fri, 30 Dec 2016 01:06:35 -0800, comdog wrote: Show quoted text
> If the HOME environment variable is not set (say, as in > non-interactive sessions), using $*HOME throws an exception: > > $ unset HOME > $ echo $HOME > > $ perl6 -e 'put "HOME is $*HOME"' > Use of uninitialized value of type Any in string context. > Methods .^name, .perl, .gist, or .say can be used to stringify it > to something meaningful. > in block <unit> at -e line 1 > HOME is > > Curiously, $*TMPDIR is /tmp if the TMPDIR environment variable is not > set. > > Maybe that's good and maybe not. But, trying to use homedir blows up > the > same way tmpdir does > (https://rt.perl.org/Ticket/Display.html?id=130455): > > $ perl6 -e 'homedir( "/Users/brian" ); put "HOME is $*HOME"' > No such method 'chdir' for invocant of type 'Any' > in block <unit> at -e line 1 > > But, homedir isn't documented outside of S16 even though it appears to > be there somewhere. Trying to set $*HOME directly doesn't work either, > which is certainly perplexing: > > $ perl6 -e '$*HOME = "/Users/brian"; put "HOME is $*HOME"' > Cannot modify an immutable Any > in block <unit> at -e line 1 > > I can set a key is a completely different variable to get it to work: > > $ perl6 -e '%*ENV<HOME> = "/Users/brian"; put "HOME is $*HOME"' > HOME is /Users/brian > > And I can even set it to a directory that does not exist: > > $ perl6 -e '%*ENV<HOME> = "/Users/brian/not-there"; put "HOME is > $*HOME"' > HOME is /Users/brian/not-there > > The $*HOME variable is listed in . If it isn't set, it's documented to > be Nil, but it is apparently Any. That also appears to mess with the > REPL: > > $ perl6 > I ran into a problem while trying to set up Linenoise: Cannot > resolve caller new(IO::Path: Any); none of these signatures match: > (IO::Path $: Cool $path, :$SPEC = { ... }, :$CWD = { ... }, *%_) > (IO::Path $: :$basename!, :$dirname = "", :$volume = "", > :$SPEC = { ... }, :$CWD = { ... }, *%_) > (IO::Path $: *%_) > Continuing without tab completions or line editor > You may want to consider using rlwrap for simple line editor > functionality > > To exit type 'exit' or '^D'
> > $*HOME
> (Any)
> >
Thank you for the report. All the points in this ticket are now resolved: - "If HOME env var unset, using $*HOME throws an exception" - That's just a stringified-undef warning. You can use `quietly` to quiet it. - "Trying to use homedir blows up" - &homedir has been removed; use $*HOME directly - "Trying to set $*HOME directly doesn't work either" - That was fixed[^1] by lizmat and is available in 2017.04 compiler release; tests in [^2] - "It's documented to be Nil, but it is apparently Any" - This is now fixed[^3] and tested[^4] to be Nil; will be in 2017.05 release - "I can even set it to a directory that does not exist" - After a discussion[^5] (a soliloquy?), I think that behaviour is most desirable - "That also appears to mess with the REPL" - This is now fixed[^6] (will be in 2017.05 release). For testing this, added a TODO note into Rakudo's test suite, since the test requires Linenoise/Readline to be installed. [^1] https://github.com/rakudo/rakudo/commit/1b9d53ce5ed1e9e1c546f39fbec4fe342667ed1c [^2] https://github.com/perl6/roast/commit/2d9194fff9 [^3] https://github.com/rakudo/rakudo/commit/7412184fcd [^4] https://github.com/perl6/roast/commit/71a6423a99 [^5] https://irclog.perlgeek.de/perl6-dev/2017-04-27#i_14496170 [^6] https://github.com/rakudo/rakudo/commit/1b0e41f972


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org