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

$*HOME blows up if HOME isn't set #5950

Closed
p6rt opened this issue Dec 30, 2016 · 4 comments
Closed

$*HOME blows up if HOME isn't set #5950

p6rt opened this issue Dec 30, 2016 · 4 comments

Comments

@p6rt
Copy link

@p6rt p6rt commented Dec 30, 2016

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

Searchable as RT130456$

@p6rt
Copy link
Author

@p6rt p6rt commented Dec 30, 2016

From @briandfoy

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-archive.perl.org/perl6/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)
  >

@p6rt
Copy link
Author

@p6rt p6rt commented Apr 28, 2017

From @zoffixznet

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-archive.perl.org/perl6/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] rakudo/rakudo@1b9d53c
[^2] Raku/roast@2d9194f
[^3] rakudo/rakudo@7412184
[^4] Raku/roast@71a6423
[^5] https://irclog.perlgeek.de/perl6-dev/2017-04-27#i_14496170
[^6] rakudo/rakudo@1b0e41f

@p6rt
Copy link
Author

@p6rt p6rt commented Apr 28, 2017

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

@p6rt
Copy link
Author

@p6rt p6rt commented Apr 28, 2017

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this Apr 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant