git-extras icon indicating copy to clipboard operation
git-extras copied to clipboard

make install fails for different install locations of `bash_completion`

Open jbnicolai opened this issue 10 years ago • 12 comments

Running on OS X, having installed bash_completion through Homebrew my completion directory is not /etc/bash_completion.d/.

Instead it is /usr/local/etc/bash_completion.d/, or more general: $(brew --prefix)/etc/bash_completion.d/

Running make install I get the following error:

... installing git-summary
... installing git-touch
... installing git-undo
... installing git-unlock
cp -f man/git-*.1 "/usr/local/share/man/man1"
mkdir: /etc/bash_completion.d: Permission denied
make: *** [install] Error 1

This is because /etc/ is owned by root, /etc/bash_completion.d/ does not exist (nor should it!) and it is trying to mkdir as my current user.

I suggest adding in a check that if the user has brew and if `$(brew --prefix)/etc/bash_completion.d/' exists that then that directory is used, rather than the current hardcoded default.

Would a pull request for this be welcome?

jbnicolai avatar Jul 14 '14 14:07 jbnicolai

Is the same across brew versions? As in $(brew --prefix)/etc/bash_completion.d/

hemanth avatar Jul 14 '14 15:07 hemanth

As far as I know brew has always installed it there. Everything brew installs is scoped to $(brew --prefix) (e.g. /bin), and bash_completion.d is expected to go under /etc.

jbnicolai avatar Jul 14 '14 15:07 jbnicolai

I'm having this problem as well while trying to update git-extras from 2.0.

zakdances avatar Nov 21 '14 04:11 zakdances

Same problem if I try to set a custom location

$ PREFIX=/my/custom/path make install

Also PREFIX and DESTDIR looks like repeated information, if I try

$ DESTDIR=/my/custom/path PREFIX=/my/custom/path make install

also does not work.

fibo avatar Apr 24 '15 17:04 fibo

Strange. //cc @spacewander @chernjie

hemanth avatar Apr 25 '15 15:04 hemanth

I get this:

... installing git-extras
... installing git-fork
... installing git-setup
cp -f man/git-*.1 /usr/local/share/man/man1
cp -f etc/bash_completion.sh /etc/bash_completion.d/git-extras
cp: /etc/bash_completion.d/git-extras: Permission denied
make: *** [install] Error 1
/usr/local/bin/git-extras: line 30: syntax error near unexpected token `&'
/usr/local/bin/git-extras: line 30: `& cd "$orig" \'

when I try to git extras update, which I guess is running make install under the hoods too.

If it is of any help, this is what I get when I brew install git-extras:

==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/git-extras-2.2.0.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/git-extras-2.2.0.yosemite.bottle.tar.gz
==> Pouring git-extras-2.2.0.yosemite.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/git-extras/2.2.0: 91 files, 388K

revolter avatar Apr 29 '15 11:04 revolter

@jbnicolai Do you notice this in the latest version?

hemanth avatar Apr 30 '15 05:04 hemanth

This affects more than just Homebrew. It means you can't install it as a non-root user on locked-down systems, period.

The Makefile should not try to detect Homebrew. That ends up being a mess for both users and the Homebrew maintainers. Let Homebrew take care of the relocations it needs to do. But you could expand the Makefile to make it easier and cleaner to do so. Right now Homebrew does it by just hacking the makefile so etc/ respects $(PREFIX).

  def install
    inreplace "Makefile", %r{\$\(DESTDIR\)(?=/etc/bash_completion\.d)}, "$(DESTDIR)$(PREFIX)"
    system "make", "PREFIX=#{prefix}", "install"
  end

It would be nice to provide the ability to relocate where the etc files are installed to as part of the standard install script. It seems to me that the etc stuff should respect $PREFIX too. But if you don't want to do that, maybe you could just add a nonstandard $SYSCONFPREFIX which used only for locating etc.

PREFIX ?= /usr/local
SYSCONFPREFIX ?= 
...
    mkdir -p $(DESTDIR)$(SYSCONFPREFIX)/etc/bash_completion.d
    cp -f etc/bash_completion.sh $(DESTDIR)$(SYSCONFPREFIX)/etc/bash_completion.d/git-extras
...
uninstall:
    rm -f $(DESTDIR)$(SYSCONFPREFIX)/etc/bash_completion.d/git-extras

or

PREFIX ?= /usr/local
SYSCONFPREFIX ?= 
sysconfdir = $(DESTDIR)$(SYSCONFPREFIX)/etc
...
    mkdir -p $(sysconfdir)/bash_completion.d
    cp -f etc/bash_completion.sh $(sysconfdir)/bash_completion.d/git-extras
...
uninstall:
    rm -f $(sysconfdir)/bash_completion.d/git-extras

I put an example up at https://github.com/apjanke/git-extras/tree/relocatable-etc, since I had to make this change locally to work with it outside Homebrew anyway.

@fibo: $PREFIX and $DESTDIR are used for different things. $PREFIX represents the path where it's going to end up when installed. $DESTDIR is conventionally for making staged installs, where the files end up in a different location from where they should eventually live once installed. As a hack, it looks like $DESTDIR could be used now with a blank $PREFIX to get everything including the etc stuff to install to a different location

apjanke avatar Oct 02 '15 08:10 apjanke