On Fri, 30 Dec 2016 01:06:35 -0800, comdog wrote: > 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