anthos-service-mesh-packages icon indicating copy to clipboard operation
anthos-service-mesh-packages copied to clipboard

Absolute paths for overlay files are not determined correctly on Darwin

Open alexbrand opened this issue 3 years ago • 2 comments

As documented in the script, the script cds into a temp directory during the installation. For this reason, the script needs to compute the absolute path for overlay files (among other files) to be able to reference them during the installation.

The script currently uses stat -f $file to obtain the absolute file. However, this does not work as expected:

$ pwd
/Users/alexbrand/test
$ ls
foo.yaml
$ stat -f foo.yaml
foo.yaml
$ stat -f non-existent-file.yaml
non-existent-file.yaml

This causes issues when trying to use a custom overlay file, as the istioctl install command cannot find the overlay files.

alexbrand avatar May 24 '21 20:05 alexbrand

I'm having the same problem.

I have the BSD version of stat installed on my Mac, but the -f in the BSD version of stat is a formatting option, so it doesn't return the absolute path as expected.

$ uname -a
Darwin 60-77490 19.6.0 Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 20204

$ pwd
/Users/na-ga/asm

$ stat -f ./asm_build_package
./asm_build_package

what about using greadlink or realpath on a Mac? If using greadlink, we need to install coreutils.

$ readlink -f ./asm_build_package
readlink: illegal option -- f
usage: readlink [-n] [file ...]

$ greadlink -f ./asm_build_package
/Users/na-ga/asm/asm_build_package

$ realpath ./asm_build_package
/Users/na-ga/asm/asm_build_package

There is a related issue #259. I have modified it to use greadlink to avoid the problem.

$ cp -a ./install_asm ./install_asm.backup
$ gsed -i 's/APATH="stat"/APATH="greadlink"/g' ./install_asm
$ diff ./install_asm ./install_asm.backup
304c304
<     Darwin) APATH="greadlink";;
---
>     Darwin) APATH="stat";;

na-ga avatar Jun 01 '21 08:06 na-ga

Sorry for the late response, this is definitely not getting ignored. Mac compatibility issues are generally not prioritized highly since it's not officially supported. If realpath is installed on Macs by default I'd approve a PR changing stat to realpath if it works locally. I'm hesitant to add a dependency on coreutils unless it's unavoidable.

zerobfd avatar Jul 21 '21 23:07 zerobfd