Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

realpath does not exist on Mac #221

Closed
vfrinken opened this issue Jun 1, 2020 · 5 comments
Closed

realpath does not exist on Mac #221

vfrinken opened this issue Jun 1, 2020 · 5 comments
Labels
Installation Issue Problem compiling or running Idris

Comments

@vfrinken
Copy link
Contributor

vfrinken commented Jun 1, 2020

trying to install Idris2 in a Mac using
make bootstrap SCHEME=chez
aborts with an error message that realpath cannot be found, which is not surprising, since realpath doesn't exist.

i propose to include something like this

realpath() {
  OURPWD=$PWD
  cd "$(dirname "$1")"
  LINK=$(readlink "$(basename "$1")")
  while [ "$LINK" ]; do
    cd "$(dirname "$LINK")"
    LINK=$(readlink "$(basename "$1")")
  done
  REALPATH="$PWD/$(basename "$1")"
  cd "$OURPWD"
  echo "$REALPATH"
}

(found in whatwg/html-build#90)

@vfrinken vfrinken added the Installation Issue Problem compiling or running Idris label Jun 1, 2020
@keram
Copy link
Contributor

keram commented Jun 1, 2020

Hi @vfrinken realpath is required for installation and as mentioned in https://github.com/idris-lang/Idris2/blob/master/INSTALL.md you can install it on Mac as part of coreutils
brew install coreutils
cheers!

@ska80
Copy link
Contributor

ska80 commented Mar 18, 2021

I believe this issue can be closed.

@gallais gallais closed this as completed Mar 18, 2021
@gallais gallais reopened this Mar 18, 2021
@gallais
Copy link
Member

gallais commented Mar 18, 2021

Can we check in the makefile that the required dependencies are
installed & complain if it's not the case?

@ska80
Copy link
Contributor

ska80 commented Mar 19, 2021

Can we check in the makefile that the required dependencies are
installed & complain if it's not the case?

This PR #1210 checks if realpath exists for Chez and Racket backends. I didn't put this check in the makefile because only Chez and Racket use realpath at the moment.

@benhormann
Copy link
Contributor

Can we check in the makefile that the required dependencies are
installed & complain if it's not the case?

Not really, it is also a runtime dependency i.e. compiled "Hello world" app includes same script.

Racket's raco exe has an option to include libs, maybe it is possible to embed the support lib? Chez mentions concatenating object files. Failing that, a shell imitation of realpath isn't a bad way to go (easy to fix when it breaks).


## The following is equivalent to: DIR=$(dirname $(realpath $0))
## Non-GNU systems don't always have realpath/grealpath installed.
DIR=$PWD
LINK=$0
while [ -n "$LINK" ]; do
  # If LINK is not absolute, join with DIR.
  [ -n "${LINK##/*}" ] && LINK=$DIR/$LINK
  DIR=$(dirname "$LINK")
  LINK=$(readlink "$LINK")
done
# Canonicalize path.
DIR=$(cd -P "$DIR" && pwd -P)
# Note: For non-POSIX systems, try without the -P option.
ERR=$?; [ 0 = $ERR ] || {
  echo "Script '$0' expects POSIX shell and read access." >&2
  exit $ERR
}

Should work on all modern systems, so let's replace the whole case `uname` block?
This way , "\"`dirname \"$DIR\"`\"/\"" ++ target ++ "\" \"$@\"" becomes , "\"$DIR/" ++ target ++ "\" \"$@\"".

Caveat: cd -P only works on POSIX systems, according to: https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.70/html_node/Limitations-of-Builtins.html#index-cd
For such old shells, the $() and ${} syntax might not work either.

benhormann added a commit to benhormann/Idris2 that referenced this issue May 15, 2021
Zsh is available by default on macOS
`readlink -f` is commonly supported on Linux and BSD
benhormann added a commit to benhormann/Idris2 that referenced this issue May 15, 2021
Zsh is available by default on macOS
readlink -f is commonly supported on Linux and BSD
ska80 added a commit to ska80/Idris2-SH that referenced this issue May 24, 2021
In addition to idris-lang#221 remove `realpath` usage leftovers.

I left the `realpath` requirement in `INSTALL.md` so bootstrapped compiler could still work.
attila-lendvai pushed a commit to attila-lendvai-patches/Idris2 that referenced this issue Jul 27, 2021
Make the applicative combinators in `Text.Parser.Core` lazier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Installation Issue Problem compiling or running Idris
Projects
None yet
Development

No branches or pull requests

5 participants