solvuu / solvuu-build

DEPRECATED. We recommend Jane Street's dune (formerly jbuilder).
ISC License
24 stars 5 forks source link

Make shell command doesn't resolve which opam #39

Open rleonid opened 8 years ago

rleonid commented 8 years ago
$ make
make: opam: Command not found
Makefile:1: /solvuu.mk: No such file or directory
make: *** No rule to make target `/solvuu.mk'.  Stop.

and

$ which make
/usr/bin/make
hammerlab-dev2:prohlatype$ make --version
GNU Make 3.82
Built for x86_64-redhat-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

and

$ echo "opam: $(which opam)"
opam: /hpc/users/rozenl02/code/foreign/opam/opam

our ~ is NFS mounted.

agarwal commented 7 years ago

To add more info, so the issue is that we recommend creating a Makefile with the line

include $(shell opam config var solvuu-build:lib)/solvuu.mk

And the issue OP is experiencing is that the opam executable is not found in this context. It seems Make causes his PATH to be not used correctly. Thus, the $(shell ... ) part ends up being empty, and Make thinks it is supposed to include /solvuu.mk and this of course doesn't exist.

Does anyone know the portable way to call out to a shell command from within Make?

rleonid commented 7 years ago

To add a bit more info, I changed the Makefile to

include $(shell /full/path/to/opam config var solvuu-build:lib)/solvuu.mk

so perhaps a more robust mechanism would be to tie an installation of solvuu_build to the opam that it is using?

agarwal commented 7 years ago

tie an installation of solvuu_build to the opam that it is using?

I don't think there is a general way to do that because opam is an executable that could be anywhere. It is not related in any way to the directory structure opam maintains because opam is not installed by opam.

rleonid commented 7 years ago

I was suggesting inserting the result of which opam during the build phase.

agarwal commented 7 years ago

If which opam is a reliable way to get the path to an executable, then we could recommend the following Makefile:

OPAM=$(shell which opam)
include $(shell $(OPAM) config var solvuu-build:lib)/solvuu.mk
rleonid commented 7 years ago

Just hit this again, as I was reinstalling things. Can you add that change? On testing, it solves my problems.

agarwal commented 7 years ago

Can you add that change?

Do you mean determining the path to opam by doing OPAM=$(shell which opam)? You feel that is the more correct general solution? We just need to update the documentation then.

agarwal commented 7 years ago

I'm not clear on exactly what the problem is. If which opam works within the Makefile, it seems impossible that opam is not found because all which does is search PATH.

rleonid commented 7 years ago

On my instance the shell opam config var solvuu-build:lib part fails. But, weirdly, using the OPAM=$(shell which opam) technique succeeds. Maybe because the final shell invocation somehow doesn't operate with the full PATH variable.