#52211 closed defect (invalid)
bzip2 refuses to work, attempts to create /opt/local/bin/bzip2.bz2 file
Reported by: | mouse07410 (Mouse) | Owned by: | ryandesign (Ryan Carsten Schmidt) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.3.4 |
Keywords: | Cc: | ||
Port: | bzip2 |
Description
When I try to bzip2 a file, I get this problem:
$ pwd /Users/uri/src/ast61 $ ll Astro.txt -r--r--r-- 1 uri staff 4620 Sep 11 11:42 Astro.txt $ bzip2 Astro.txt bzip2: Can't create output file /opt/local/bin/bzip2.bz2: Permission denied. $ ll Astro.txt* -r--r--r-- 1 uri staff 2219 Sep 11 11:42 Astro.txt.bz2 $ bunzip2 Astro.txt.bz2 bunzip2: Can't guess original name for /opt/local/bin/bzip2 -- using /opt/local/bin/bzip2.out bunzip2: Output file /opt/local/bin/bzip2.out already exists. $ ll Astro.txt* -r--r--r-- 1 uri staff 4620 Sep 11 11:42 Astro.txt $
While bzip2 does (usually - when not invoked from the script) create compressed file despite that complaint, it does not work when, e.g., bzip2 is invoked by GnuTAR:
$ gnutar -cjvf t.tbz Astro.txt Astro.txt bzip2: Can't create output file /opt/local/bin/bzip2.bz2: Permission denied. gnutar: Child returned status 1 gnutar: Error is not recoverable: exiting now $ ll t.tbz -rw-r--r-- 1 uri staff 0 Sep 11 14:56 t.tbz $
This bug (that I suspect is present in the upstream) prevents use of bzip2 - I'd appreciate your help.
Change History (6)
comment:1 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)
Cc: | ryandesign@… removed |
---|---|
Owner: | changed from macports-tickets@… to ryandesign@… |
comment:2 Changed 8 years ago by mouse07410 (Mouse)
Sounds like a misconfiguration of some sort on your system.
Based on what I'm observing, I rather doubt that - but would be happy to hear suggestions how to find this out.
Maybe an alias or function overriding MacPorts bzip2
I don't think so - see below.
What do you get when you run...
This:
$ type bzip2 bzip2 is hashed (/opt/local/bin/bzip2) $ type bunzip2 bunzip2 is hashed (/opt/local/bin/bunzip2) $ bzip2 --version bzip2, a block-sorting file compressor. Version 1.0.6, 6-Sept-2010. Copyright (C) 1996-2010 by Julian Seward. This program is free software; you can redistribute it and/or modify it under the terms set out in the LICENSE file, which is included in the bzip2-1.0.6 source distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE file for more details. bzip2: Can't create output file /opt/local/bin/bzip2.bz2: Permission denied. $ bunzip2 --version bzip2, a block-sorting file compressor. Version 1.0.6, 6-Sept-2010. Copyright (C) 1996-2010 by Julian Seward. This program is free software; you can redistribute it and/or modify it under the terms set out in the LICENSE file, which is included in the bzip2-1.0.6 source distribution. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE file for more details. bunzip2: Can't guess original name for /opt/local/bin/bzip2 -- using /opt/local/bin/bzip2.out bunzip2: Can't create output file /opt/local/bin/bzip2.out: Permission denied. $ alias bzip2 -bash: alias: bzip2: not found $ alias bunzip2 -bash: alias: bunzip2: not found $
comment:3 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)
I've found a reference to a similar problem:
https://lists.macosforge.org/pipermail/macports-changes/2014-April/103619.html
It suggests that you have set the BZIP2
environment variable to the path to the bzip2 program. But the bzip2 program actually uses that variable for additional arguments. So you should unset the BZIP2
environment variable.
comment:4 Changed 8 years ago by mouse07410 (Mouse)
Yes!
I checked my .bashrc, and found
export BZIP2=/opt/local/bin/bzip2
in it (I don't remember what application needed that definition).
Then, after unsetting it:
$ unset BZIP2 $ bzip2 Astro.txt $ bunzip2 Astro.txt.bz2 $
So when env variable BZIP2 is not set, it works just fine. But why would that env var screw things up so badly? Isn't that a bug? What do you think?
comment:5 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)
Resolution: | → invalid |
---|---|
Status: | new → closed |
It's a documented feature of the bzip2 program. From its man page:
bzip2 will read arguments from the environment variables BZIP2 and BZIP, in that order, and will process them before any arguments read from the command line. This gives a convenient way to supply default arguments.
It was surprising to us too when we found out about this "feature" and we had to make some changes to MacPorts itself to not run into problems. We, too, had been using the BZIP2
environment variable as a way to specify the path to the bzip2 program, and had to change it.
comment:6 Changed 8 years ago by mouse07410 (Mouse)
I see, thanks! Appreciate your time and help! And I've unseated BZIP2 now. ;-)
I've never seen anything like that before. It works fine for me:
Sounds like a misconfiguration of some sort on your system. Maybe an alias or function overriding MacPorts bzip2.
What do you get when you run: