Tilde-expansion in --long-options=

  • Done
  • quality assurance status badge
Details
7 participants
  • Bengt Richter
  • Danny Milosavljevic
  • Hartmut Goebel
  • Leo Famulari
  • Ludovic Courtès
  • Tobias Geerinckx-Rice
  • zimoun
Owner
unassigned
Submitted by
Hartmut Goebel
Severity
normal

Debbugs page

H
H
Hartmut Goebel wrote on 30 Apr 2020 01:15
--load-path does not honor ~
(name . bug-guix)(address . bug-guix@gnu.org)
9fc5fc35-10c6-dda3-1e11-36740e4510c4@crazy-compilers.com
Specifying the home directory using `~` (tilde) in `--load-path` does
not add the proper path to

Does not work (not who "mypackage":

  guix package --load-path=~/path/tp/my/project -A mypackage

Using $HOME (which si resolve by the shell works:

  guix package --load-path=$HOME/path/tp/my/project -A mypackage


I would expect ~ and ~username to work, too.
Z
Z
zimoun wrote on 30 Apr 2020 08:31
(name . Hartmut Goebel)(address . h.goebel@crazy-compilers.com)(address . 40977@debbugs.gnu.org)
CAJ3okZ0FYmFqx31C4Lhxix0zY6VQMr3GSFQZp6rN4BnbhZFbdQ@mail.gmail.com
Dear,

On Thu, 30 Apr 2020 at 10:17, Hartmut Goebel
<h.goebel@crazy-compilers.com> wrote:
Toggle quote (8 lines)
>
> Specifying the home directory using `~` (tilde) in `--load-path` does
> not add the proper path to
>
> Does not work (not who "mypackage":
>
> guix package --load-path=~/path/tp/my/project -A mypackage

It seems related to long vs short options, not to the expansion.


The short option works:

guix package -L ~/path/to/my/project -A mypackage

but not the long '--load-path='.


Toggle quote (2 lines)
> I would expect ~ and ~username to work, too.

Same for '~username'.


Well, I think it is related to bug #40549, see [1].



All the best,
simon
Z
Z
zimoun wrote on 30 Apr 2020 09:37
(name . Hartmut Goebel)(address . h.goebel@crazy-compilers.com)(address . 40977@debbugs.gnu.org)
CAJ3okZ14xbfTtYCumU0S7-u3FwxQq0_wb_LPZourCPxL8A7aRA@mail.gmail.com
On Thu, 30 Apr 2020 at 17:31, zimoun <zimon.toutoune@gmail.com> wrote:
Toggle quote (15 lines)
>
> Dear,
>
> On Thu, 30 Apr 2020 at 10:17, Hartmut Goebel
> <h.goebel@crazy-compilers.com> wrote:
> >
> > Specifying the home directory using `~` (tilde) in `--load-path` does
> > not add the proper path to
> >
> > Does not work (not who "mypackage":
> >
> > guix package --load-path=~/path/tp/my/project -A mypackage
>
> It seems related to long vs short options, not to the expansion.

I am wrong. It is about the expansion. When using the short option,
then the expansion is done by the shell.

Note that it should be the same for '--manifest=~/path/to/manifests/'.
And all the '--long-options=~/path/to/something'.

Well, I do not find a function to expand tilde in Guile.


All the best,
simon
H
H
Hartmut Goebel wrote on 30 Apr 2020 09:42
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 40977@debbugs.gnu.org)
52117c4b-3090-1ccf-5669-ff4c47935e19@crazy-compilers.com
Hi,

This is not related to #40549.

The short option "-L ~/…" works, since thin this case the shell resolves the tilde. Whereas for the long-option the shell does not revolve the tilde, since the tilde is in the middle of the argument. Yu can verify this yourself easily:

$ python -c 'import sys; print(sys.argv)' ~
['-c', '/home/hartmut']
$ python -c 'import sys; print(sys.argv)' -L ~
['-c', '-L', '/home/hartmut']
$ python -c 'import sys; print(sys.argv)' ---long=~
['-c', '---long=~']


Proposed solution:

After processing options, guix need to "expanduser()" (as it is called
in Python) on all arguments which are paths.


--
Regards
Hartmut Goebel

| Hartmut Goebel | h.goebel@crazy-compilers.com |
| www.crazy-compilers.com | compilers which you thought are impossible |
Z
Z
zimoun wrote on 30 Apr 2020 09:50
(name . Hartmut Goebel)(address . h.goebel@crazy-compilers.com)(address . 40977@debbugs.gnu.org)
CAJ3okZ0cEP3vJcT_me0J20Wm=b01PEEWYM1sGq5BL5+qVai=5A@mail.gmail.com
Dear Hartmut,

On Thu, 30 Apr 2020 at 18:42, Hartmut Goebel
<h.goebel@crazy-compilers.com> wrote:

Toggle quote (2 lines)
> The short option "-L ~/…" works, since thin this case the shell resolves the tilde. Whereas for the long-option the shell does not revolve the tilde, since the tilde is in the middle of the argument. Yu can verify this yourself easily:

Yes, you have right.


Toggle quote (5 lines)
> Proposed solution:
>
> After processing options, guix need to "expanduser()" (as it is called
> in Python) on all arguments which are paths.

I agree.
I am not aware of such function in Guile.

All the best,
simon
D
D
Danny Milosavljevic wrote on 30 Apr 2020 10:34
(name . zimoun)(address . zimon.toutoune@gmail.com)
20200430193439.0db54d2f@scratchpost.org
Toggle quote (3 lines)
> After processing options, guix need to "expanduser()" (as it is called
> in Python) on all arguments which are paths.

Please don't do it.

UNIX has its warts, and this is a well-known one (use ${HOME} instead).

If we did expanduser, I'm sure we'd be seeing bug reports about paths where
there was a tilde in the actual file name, NOT as a expanduser mark.

UNIX tools do what they do, and this wart is here to stay in a lot of tools.
Then at least make it consistent across all the tools UNIX has.
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAl6rDC8ACgkQ5xo1VCww
uqXOzwf+L7U3vk0HQ8ehOS4D7fjZFXefXyDZuJJKjxbEz+2BSaoxUKGTSLPV6lHO
m9cxMnlTbUPz8bGLa3Xp2p+7bYzAySWzEFbzjQmsKMizHVCu7FswaEHTChPlgzuj
LolyLA0GqteGGQDrlfFqpq6A1wz0x3gx0oktl+M5CfZQhqYFjwGwhhYreswtsiLl
mNyHgO+XZiEGuAHlAycxvJQQhJrnJ4fpEVYufHUqJPIQow4+HOLAX9K9orb9ZlcY
VKcTvBEYnPp7ejwhZ9fx/KQDZHaf9I24IFvsbsnYupjxaTtJNZXuP6Erm7wA11Yn
4nB8GT2NC6RJAPx1jDy6l7DZdJoKNA==
=NZhE
-----END PGP SIGNATURE-----


L
L
Leo Famulari wrote on 30 Apr 2020 10:53
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
20200430175305.GA26916@jasmine.lan
On Thu, Apr 30, 2020 at 07:34:39PM +0200, Danny Milosavljevic wrote:
Toggle quote (8 lines)
> UNIX has its warts, and this is a well-known one (use ${HOME} instead).
>
> If we did expanduser, I'm sure we'd be seeing bug reports about paths where
> there was a tilde in the actual file name, NOT as a expanduser mark.
>
> UNIX tools do what they do, and this wart is here to stay in a lot of tools.
> Then at least make it consistent across all the tools UNIX has.

If it's true that this behaviour is more or less consistent in UNIX /
POSIX, then I agree with Danny that we should leave it as is. And, I
have noticed that ${HOME} is the way to go.
Z
Z
zimoun wrote on 30 Apr 2020 11:14
(name . Leo Famulari)(address . leo@famulari.name)
CAJ3okZ1qzCCVwC2jMAKYxo_-B-ZDasADqTQ_AE02qDX42kZYAg@mail.gmail.com
On Thu, 30 Apr 2020 at 19:53, Leo Famulari <leo@famulari.name> wrote:

Toggle quote (3 lines)
> > UNIX tools do what they do, and this wart is here to stay in a lot of tools.
> > Then at least make it consistent across all the tools UNIX has.

I do not have a clear opinion on the subject so I fall with the
Danny's wise opinion.
T
T
Tobias Geerinckx-Rice wrote on 30 Apr 2020 12:21
87y2qcsst3.fsf@nckx
Hartmut, Zimoun,

Hartmut Goebel 写道:
Toggle quote (4 lines)
> After processing options, guix need to "expanduser()" (as it is
> called
> in Python) on all arguments which are paths.

If any Python (or other) software does this, it's broken. File a
bug there.

This is the wrong thing to do and makes the GNU system an
inconsistent mess. …OK, *more* of an inconsistent, loveable, mess
;-)

It also makes

$ sudo guix system --load-path=~/path/tp/my/project …

and

$ sudo guix system -L ~/path/to/my/project -A mypackage …

suddenly result in different file names.

Please don't do it.

Kind regards,

T G-R
-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQT12iAyS4c9C3o4dnINsP+IT1VteQUCXqslHwAKCRANsP+IT1Vt
eVTOAP9kAgyVgt1j+wlg2CTHh29MK+iYy7IFvAsGIGeSXnrroAEAmME/0lyS3PCR
AIwEbPlwu9cri6AQbhtdB8EXf0k08AM=
=8af+
-----END PGP SIGNATURE-----

Z
Z
zimoun wrote on 30 Apr 2020 13:54
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)(address . 40977@debbugs.gnu.org)
CAJ3okZ0mLs3bZwZSGuawVovUdGWJu9BH1XmfG7KVsv0RDWohvQ@mail.gmail.com
Hi Tobias,

On Thu, 30 Apr 2020 at 21:20, Tobias Geerinckx-Rice <me@tobias.gr> wrote:
Toggle quote (25 lines)
>
> Hartmut, Zimoun,
>
> Hartmut Goebel 写道:
> > After processing options, guix need to "expanduser()" (as it is
> > called
> > in Python) on all arguments which are paths.
>
> If any Python (or other) software does this, it's broken. File a
> bug there.
>
> This is the wrong thing to do and makes the GNU system an
> inconsistent mess. …OK, *more* of an inconsistent, loveable, mess
> ;-)
>
> It also makes
>
> $ sudo guix system --load-path=~/path/tp/my/project …
>
> and
>
> $ sudo guix system -L ~/path/to/my/project -A mypackage …
>
> suddenly result in different file names.

Sorry to be slow. Naive questions.

Do you mean the issue comes from who expand '~' (user vs sudo)?
Or do you mean refer to subfolder named '~, i.e., $HOME/foo/~/bar?

I should miss a point... about what is less or more inconsistent. :-)
Because it seems more based on conventions than on consistent inconsistencies.

About expansion, is it not the same question with
'--load-path=$HOME/path/to/' vs '-L $HOME/path/to/'?
About naming, is it possible to create a folder named '~' directly in $HOME?

Well, I am surely not enough skilled to have an opinion but I have
learnt something. :-)


Toggle quote (2 lines)
> Please don't do it.

The fact that Guile does not have a built-in ``expand-tilde`` is a
strong indication to not do it. ;-)


Cheers,
simon
B
B
Bengt Richter wrote on 30 Apr 2020 23:51
(name . zimoun)(address . zimon.toutoune@gmail.com)
20200501065120.GA8427@LionPure
On +2020-04-30 22:54:47 +0200, zimoun wrote:
Toggle quote (44 lines)
> Hi Tobias,
>
> On Thu, 30 Apr 2020 at 21:20, Tobias Geerinckx-Rice <me@tobias.gr> wrote:
> >
> > Hartmut, Zimoun,
> >
> > Hartmut Goebel 写道:
> > > After processing options, guix need to "expanduser()" (as it is
> > > called
> > > in Python) on all arguments which are paths.
> >
> > If any Python (or other) software does this, it's broken. File a
> > bug there.
> >
> > This is the wrong thing to do and makes the GNU system an
> > inconsistent mess. …OK, *more* of an inconsistent, loveable, mess
> > ;-)
> >
> > It also makes
> >
> > $ sudo guix system --load-path=~/path/tp/my/project …
> >
> > and
> >
> > $ sudo guix system -L ~/path/to/my/project -A mypackage …
> >
> > suddenly result in different file names.
>
> Sorry to be slow. Naive questions.
>
> Do you mean the issue comes from who expand '~' (user vs sudo)?
> Or do you mean refer to subfolder named '~, i.e., $HOME/foo/~/bar?
>
> I should miss a point... about what is less or more inconsistent. :-)
> Because it seems more based on conventions than on consistent inconsistencies.
>
> About expansion, is it not the same question with
> '--load-path=$HOME/path/to/' vs '-L $HOME/path/to/'?
> About naming, is it possible to create a folder named '~' directly in $HOME?
>
> Well, I am surely not enough skilled to have an opinion but I have
> learnt something. :-)
>

FYA:(Amusement): man bash to see what more ~ can lead to ;-)
(scroll down or search for the "Tilde Expansion" section)

Toggle quote (13 lines)
>
> > Please don't do it.
>
> The fact that Guile does not have a built-in ``expand-tilde`` is a
> strong indication to not do it. ;-)
>
>
> Cheers,
> simon
>
>
>

--
Regards,
Bengt Richter
Z
Z
zimoun wrote on 1 May 2020 08:24
(address . 40977@debbugs.gnu.org)
CAJ3okZ03nmo-JABJ-YNs9YLpBm2Hr_YWX9hns8KCENS2aMpehQ@mail.gmail.com
Dear,

Sorry to be slow.


On Thu, 30 Apr 2020 at 21:20, Tobias Geerinckx-Rice <me@tobias.gr> wrote:

Toggle quote (6 lines)
> Hartmut Goebel 写道:

> This is the wrong thing to do and makes the GNU system an
> inconsistent mess. …OK, *more* of an inconsistent, loveable, mess
> ;-)

I still think that the behaviour of Guix could be considered as a bug
and inconsistent with other GNU tools, such as Emacs -- to pick one
but Emacs should be an exception in the GNU tools landscape
(inconsistent loveable mess :-))

Maybe what I am saying is irrelevant and only bikeshedding.
Like Saint-Thomas, I only believe that I see. ;-)


Toggle quote (10 lines)
> It also makes
>
> $ sudo guix system --load-path=~/path/tp/my/project …
>
> and
>
> $ sudo guix system -L ~/path/to/my/project -A mypackage …
>
> suddenly result in different file names.

Emacs behaves differently; and it is what is expected (at least by me :-)).

Toggle snippet (18 lines)
mkdir -p ${HOME}/tmp/foo
cat <<EOF > ${HOME}/tmp/foo/eg.el
(defun an-example ()
(interactive)
(message (car load-path))
(message (expand-file-name "kikoo" "~/foo/~/bar")))

(provide 'eg)
EOF

# ~ means /home/simon/
sudo emacs --batch -L ~/tmp/foo/ --eval "(require 'eg)" --eval "(an-example)"

# ~ mean /root/
sudo emacs --batch --directory=~/tmp/foo/ --eval "(require 'eg)"
--eval "(an-example)"

The first '~' is expanded by the shell so in the user's context. The
second '~' is expanded by Emacs so in the root's context.
Well, nothing new. :-)
This is not the issue, if I understand correctly.

This issue is about the subfolders named '~'.

Toggle snippet (20 lines)
mkdir -p ${HOME}/tmp/foo/~/bar

cat <<EOF > ${HOME}/tmp/foo/~/bar/ex.el
(defun from-tilde ()
(interactive)
(message (car load-path))
(message (expand-file-name "yahoga" "~/foo/~/bar")))

(provide 'ex)
EOF

cd ${HOME}/tmp/foo

# ~ means /home/simon
emacs --batch --directory=~/bar/ --eval "(require 'ex)" --eval "(from-tilde)"

# protect ~
emacs --batch --directory=./~/bar/ --eval "(require 'ex)" --eval "(from-tilde)"

From the folder '${HOME}/foo', Emacs is run with prepending the
subfolder named '~'. The first line fails because the folder
'/home/simon/bar/' does not exist. The second '~' refers to the
correct subfolder because of the dot.

Now the behaviour of Emacs is inconsistent with the Guix's behaviour.

Toggle snippet (4 lines)
cd ${HOME}/foo
guix show --load-path=~/bar from-tilde

This works. Because Guix uses the argument as it is. Note that
'--load-path=./~/bar/' works too.

And note that from the folder '$HOME/tmp/foo', the commands

guix show -L ~/bar from-tilde

and

guix show --load-path=~/bar from-tilde

refer to different file names. And it appears to me weirder than the
tilde expansion done as Emacs does.


Toggle snippet (16 lines)
mkdir -p ${HOME}/tmp/foo/~/bar
cat <<EOF > ${HOME}/tmp/foo/~/bar/from-tilde.scm
(define-module (from-tilde)
#:use-module (guix packages)
#:use-module (gnu packages maths))

(pk (car %load-path))

(define-public from-tilde
(package
(inherit gmsh)
(name "from-tilde")))
EOF


Toggle quote (2 lines)
> Please don't do it.

Well, in summary.
I have no knowledge about GNU tools and how they expand '~'.
I agree that '~' could be considered as a wart. And I do not know if
considering '~' as shortcut for $HOME is a "good practise" or not.

But I use '~' as meaning $HOME more more often than I create an
obscure subfolder named '~' (well I never did :-)). And I treat with
care the filename when I use 'sudo' because it is context switch so so
error-prone.

Maybe wrong terminology has been used with 'expanduser' but Guix
should expand '~' in agreement with the GNU Bash tilde-expansion
section IMHO.

(And this is valid for any '--long-option=~'.)


Therefore does the "it" in the Danny's and Tobias's "don't do it" mean
tilde-expansion?


Sorry again to be slow or bikeshed.

Best regards,
simon
L
L
Ludovic Courtès wrote on 2 May 2020 06:14
(name . Danny Milosavljevic)(address . dannym@scratchpost.org)
87k11u8oo6.fsf@gnu.org
Danny Milosavljevic <dannym@scratchpost.org> skribis:

Toggle quote (7 lines)
>> After processing options, guix need to "expanduser()" (as it is called
>> in Python) on all arguments which are paths.
>
> Please don't do it.
>
> UNIX has its warts, and this is a well-known one (use ${HOME} instead).

Seconded.

Tilde expansion is performed by the shell. In the case of
‘--foo=~/bar’, tilde expansion does not happen because ~ is right in the
middle of a string.

It’s admittedly annoying, but it’s not something Guix itself should
paper over. Doing that would open a can of worms, as illustrated by the
example Tobias gave.

Ludo’.
L
L
Ludovic Courtès wrote on 2 May 2020 06:14
control message for bug #40977
(address . control@debbugs.gnu.org)
87imhe8ont.fsf@gnu.org
tags 40977 notabug
close 40977
quit
Z
Z
zimoun wrote on 2 May 2020 06:55
Re: bug#40977: --load-path does not honor ~
(name . Ludovic Courtès)(address . ludo@gnu.org)
CAJ3okZ231BEc2pnkn9cikP4PY6xY4+ywPcuhpYObFsXW7U=zBQ@mail.gmail.com
On Sat, 2 May 2020 at 15:14, Ludovic Courtès <ludo@gnu.org> wrote:

Toggle quote (4 lines)
> It’s admittedly annoying, but it’s not something Guix itself should
> paper over. Doing that would open a can of worms, as illustrated by the
> example Tobias gave.

Instead of 'notabug' , I propose to tag this bug as 'wontfix' and
retitle it as: "Tilde-expansion in --long-options=".

Is it ok?


Best regards,
simon

ps:
Quoting the 'wontfix' explanation [1]: ``this is a choice between two
arbitrary ways of doing things and the maintainer and submitter prefer
different ways of doing things``.
L
L
Ludovic Courtès wrote on 2 May 2020 15:14
(name . zimoun)(address . zimon.toutoune@gmail.com)
87mu6q2ddi.fsf@gnu.org
zimoun <zimon.toutoune@gmail.com> skribis:

Toggle quote (11 lines)
> On Sat, 2 May 2020 at 15:14, Ludovic Courtès <ludo@gnu.org> wrote:
>
>> It’s admittedly annoying, but it’s not something Guix itself should
>> paper over. Doing that would open a can of worms, as illustrated by the
>> example Tobias gave.
>
> Instead of 'notabug' , I propose to tag this bug as 'wontfix' and
> retitle it as: "Tilde-expansion in --long-options=".
>
> Is it ok?

Sure.

Ludo’.
Z
Z
zimoun wrote on 3 May 2020 08:19
(address . control@debbugs.gnu.org)
CAJ3okZ2oo9BmCXqBet+tg4iKfeX-X9croD1H5eeHp8BHB8p_5g@mail.gmail.com
tags 40977 - notabug
tags 40977 wontfix
retitle 40977 Tilde-expansion in --long-options=
thanks
?
Your comment

This issue is archived.

To comment on this conversation send an email to 40977@patchwise.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 40977
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch