Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#17620 closed defect (wontfix)

Problem with Installing python_select

Reported by: sean.b.palmer@… Owned by: raimue (Rainer Müller)
Priority: Normal Milestone:
Component: ports Version: 1.6.0
Keywords: Cc: sean.b.palmer@…, MarcusCalhoun-Lopez (Marcus Calhoun-Lopez), nslater@…
Port: python_select

Description

When I try to install python_select, I get the following:

  • * *
$ sudo port install python_select
--->  Staging python_select into destroot
Error: Target org.macports.destroot returned: shell command 
"/opt/local/var/macports/build
/_opt_local_var_macports_sources_rsync.macports.org_release_ports_sysutils_python_select
/work/destroot/opt/local/bin/python_select -i 
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_sysutils_python_select
/work/destroot python23-apple" returned error 12
Command output: /opt/local/var/macports/build
/_opt_local_var_macports_sources_rsync.macports.org_release_ports_sysutils_python_select
/work/destroot/opt/local/bin/python_select: line 124: [: /: unary 
operator expected
ln: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_sysutils_python_select
/work/destroot/opt/local/Library/Frameworks/Python.framework/Resources: No such file or directory
Unknown option: n
Usage: head [-options] <url>...
    -m <method>   use method for the request (default is 'HEAD')
    -f            make request even if head believes method is illegal
    -b <base>     Use the specified URL as base
    -t <timeout>  Set timeout value
    -i <time>     Set the If-Modified-Since header on the request
    -c <conttype> use this content-type for POST, PUT, CHECKIN
    -a            Use text mode for content I/O
    -p <proxyurl> use this as a proxy
    -P            don't load proxy settings from environment
    -H <header>   send this HTTP header (you can specify several)

    -u            Display method and URL before any response
    -U            Display request headers (implies -u)
    -s            Display response status code
    -S            Display response status chain
    -e            Display response headers
    -d            Do not display content
    -o <format>   Process HTML content in various ways

    -v            Show program version
    -h            Print this message

    -x            Extra debugging output
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_sysutils_python_select
/work/destroot/opt/local/bin/python_select: line 121: [: -: unary operator expected
/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_sysutils_python_select
/work/destroot/opt/local/bin/python_select: line 124: [: /: unary operator expected
ln: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_sysutils_python_select
/work/destroot/opt/local/Library/Frameworks/Python.framework/Python: No such file or directory

Error: Status 1 encountered during processing.
  • * *

When I tried to fix this by editing the problematic file, macports overwrote it on the next installation attempt. I suppose there's probably some way to get around that too, but either way this needs fixing upstream I presume.

Change History (21)

comment:1 Changed 15 years ago by sean.b.palmer@…

Cc: sean.b.palmer@… added

Cc Me!

comment:2 Changed 15 years ago by mf2k (Frank Schima)

Cc: sean.b.palmer@… removed
Owner: changed from macports-tickets@… to raimue@…
Port: python_select added

Assigning to maintainer.

comment:3 Changed 15 years ago by raimue (Rainer Müller)

Status: newassigned

Do I assume correctly you are installing on Tiger?

comment:4 in reply to:  3 Changed 15 years ago by sean.b.palmer@…

Replying to raimue@…:

Do I assume correctly you are installing on Tiger?

Yep, indeed. Sorry, forgot to mention.

comment:5 Changed 15 years ago by sean.b.palmer@…

Cc: sean.b.palmer@… added

Cc Me!

comment:6 Changed 15 years ago by raimue (Rainer Müller)

You seem to have some binary named head in PATH which does not behave like the standard UNIX utility. According to the help message it looks like it is some tool to query a webserver over HTTP. python_select relies on head and tail being the standard tools.

comment:7 Changed 15 years ago by sean.b.palmer@…

The head binary is the standard unix utility:

$ which head
/usr/bin/head

$ echo 'a\nb\nc' | head -n 1
a

There is also a HEAD utility as part of perl's lwp:

$ HEAD -v
This is lwp-request version 2.07 (libwww-perl-5.805)

Copyright 1995-1999, Gisle Aas.

This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.

But that's "HEAD", not "head"...

comment:8 Changed 15 years ago by raimue (Rainer Müller)

According to port contents p5-libwww-perl, my installation of lwp does not contain any binaries, only perl modules and man pages. Where does HEAD come from? What is the output of port provides /opt/local/bin/HEAD?

Usually Mac OS X uses a case-insensitive filesystem. Therefore head and HEAD are treated the same.

comment:9 Changed 15 years ago by sean.b.palmer@…

$ which HEAD
/opt/local/bin/HEAD

$ port provides /opt/local/bin/HEAD
/opt/local/bin/HEAD is not provided by a MacPorts port.

Presumably if I'd installed it myself it would be in /usr/local/bin, so I'm not sure how it came to be there. It's fairly old:

$ ls -al /opt/local/bin/HEAD 
-r-xr-xr-x   1 root  admin  14685 Mar 20  2007 /opt/local/bin/HEAD*

But I can't remember what circumstances might surround the installation. In any case, my shell managed to distinguish between the two correctly. How does it do so, if the filesystem is case-insensitive? Could MacPorts follow the same procedure to do so?

comment:10 in reply to:  9 Changed 15 years ago by sean.b.palmer@…

Replying to sean.b.palmer@…:

In any case, my shell managed to distinguish between the two correctly.

A friend suggested the problem might only be in the root environment, and sure enough...

$ sudo su
...
# which head
/opt/local/bin/head
# which HEAD
/opt/local/bin/HEAD

Which is strange, because my standard user $PATH is identical to the superuser $PATH, yet it works fine as standard user in zsh and not in the superuser shell, which is using sh by default. You get the same outcome in superuser zsh.

Also, I wonder if the HEAD utility from lwp came from installing it using the MacPorts perl, but from CPAN.

comment:11 Changed 15 years ago by raimue (Rainer Müller)

Replying to sean.b.palmer@…:

But I can't remember what circumstances might surround the installation. In any case, my shell managed to distinguish between the two correctly. How does it do so, if the filesystem is case-insensitive? Could MacPorts follow the same procedure to do so?

In fact, python_select is a bash script. /opt/local/bin/bash does not distinguish between head and HEAD, neither does /bin/bash. I don't know which shell you use, but for bash it will not work.

comment:12 Changed 15 years ago by MarcusCalhoun-Lopez (Marcus Calhoun-Lopez)

Cc: mcalhoun@… added

Cc Me!

comment:13 Changed 15 years ago by nslater@…

Cc: nslater@… added

Cc Me!

comment:14 Changed 15 years ago by sean.b.palmer@…

Can the script be ported to sh? Or should I file a bash bug? (Or both?)

comment:15 Changed 15 years ago by raimue (Rainer Müller)

This is not a bug in the shell. On a case-insensitive filesystem there is just no difference between HEAD and head. This is intended behavior.

The only thing we could do is to hardcode a path into the shell script. But that would make it less portable. As a workaround, please remove HEAD from your PATH.

comment:16 Changed 15 years ago by nslater@…

The original reporter told me in a private communication that this behaviour is not exhibited by /bin/sh - is this not the case?

comment:17 Changed 15 years ago by blb@…

Note that the p5-libwww-perl port disables installing the programs, ever since it's been in the repository; looking through libwww-perl, it sounds like HEAD (and the other programs) may have been removed in favor of lwp-request at some point in the past, so a HEAD program would have come from an older libwww-perl, so having come from CPAN sounds likely.

Finally, at least on 10.4 and 10.5, /bin/sh is just bash anyway, though it acts a bit differently.

comment:18 Changed 15 years ago by sean.b.palmer@…

Some more perplexing diagnostics:

$ which head
/usr/bin/head

$ sh -c 'which head'
/opt/local/bin/head

$ bash -c 'which head'
/opt/local/bin/head

$ zsh -c 'which head'
/opt/local/bin/head

$ echo $ZSH_VERSION
4.2.3

$ zsh -c 'echo $ZSH_VERSION'
4.2.3

$ sh -l -c 'which head'
/opt/local/bin/head

$ zsh -l -c 'which head'
/opt/local/bin/head

$ env > env1
$ sh -c env > env2
$ diff =(sort env1) =(sort env2)
17c16
< SHLVL=1
---
> SHLVL=2

I'd really like to know how my regular shell can tell the difference between "HEAD" and "head" when apparently nothing else can, even though the environments (including $PATH) are the same except for shell level.

comment:19 Changed 15 years ago by sean.b.palmer@…

I've isolated it even further. This just gets stranger and stranger:

$ zsh -c 'which head'
/opt/local/bin/head

$ zsh -c 'echo test; which head'
test
/opt/local/bin/head

$ zsh -c 'date; which head'
Mon Dec 15 21:05:15 GMT 2008
/usr/bin/head

$ zsh -c 'which head; date; which head'
/opt/local/bin/head
Mon Dec 15 21:05:32 GMT 2008
/opt/local/bin/head

$ bash -c 'date; which head'      
Mon Dec 15 21:05:55 GMT 2008
/opt/local/bin/head

If you do date first, it works! This seems to be a pattern with any non-shell builtin. If you do a shell builtin as the first invocation in zsh, then which doesn't work properly. If you do a non-shell builtin first, then which does work properly.

comment:20 Changed 15 years ago by raimue (Rainer Müller)

Resolution: wontfix
Status: assignedclosed

I can only suspect this is a zsh bug. Just do not have any tools around on PATH which are supposed to be standard tools.

comment:21 Changed 15 years ago by (none)

Milestone: Port Bugs

Milestone Port Bugs deleted

Note: See TracTickets for help on using tickets.