codeandkey/mii

Install Issue with non-default PREFIX

Closed this issue · 3 comments

mii seems to have a bug somewhere with non-default PREFIX. To wit:

I heard about mii and thought I'd try it out. Now, I'm on a work macOS laptop so lots of things are "fun" for a user. First I found mii wasn't happy building with clang 12.0.5, but I have "real" gcc (10.3.0) installed, so I tried that and it was happy with:

make PREFIX=~/mii/1.1.0
make PREFIX=~/mii/1.1.0 install

But when I tried the mii install command:

❯ ~/mii/1.1.0/bin/mii install
[10:48:56] INFO  Detected zsh shell
To enable mii for your shell, append the following to your .zshrc:
    source /share/mii/init/zsh
Automatically write /Users/mathomp4/.zshrc ? (y/N) y
Wrote /Users/mathomp4/.zshrc! Mii integration is now enabled.

I didn't read that closely enough and you'll see it added:

    source /share/mii/init/zsh

when that should be:

   source ~/mii/1.1.0/share/mii/init/zsh

or maybe the expanded PREFIX path?

Desktop (please complete the following information):

  • OS: macOS
  • Version 11.5.1

It looks like the REALPREFIX = $(realpath $(PREFIX)) line I added in the makefile to support relative PREFIXes doesn't work when the PREFIX variable is passed after the make command. PREFIX=~/mii/1.1.0 make install works as expected.

Ahhh. I didn't think of that. 👍🏼

Because realpath cannot parse tildes (~), when there is a tilde in the PREFIX, it returns an empty string, and the empty string is used as the MII_PREFIX constant in the program. The files were copied to the right location, since the PREFIX variable is used for the copy instead of REALPREFIX.

When the PREFIX is before the make command, the shell takes care of expanding the tilde, so realpath returns the right value.

A fix would be to check if REALPREFIX is empty, and if it is, set it to the value of PREFIX. This shouldn't cause any issue, because the tilde in the PREFIX will be expanded at run time.