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

R installation failing on Cygwin #20655

Closed
embray opened this issue May 23, 2016 · 32 comments
Closed

R installation failing on Cygwin #20655

embray opened this issue May 23, 2016 · 32 comments

Comments

@embray
Copy link
Contributor

embray commented May 23, 2016

When running a make of Sage on Cygwin the build fails upon installation of R. I will attach the full log, but the relevant error is:

make[4]: Entering directory '/home/embray/src/sagemath/sage/local/var/tmp/sage/build/r-3.2.4-revised.p0/R-revised/src/library/Recommended'
begin installing recommended package MASS
INSTALL: unknown option -- pkglock
Try 'INSTALL --help' for more information.
Makefile:51: recipe for target 'MASS.ts' failed
make[4]: *** [MASS.ts] Error 1
make[4]: Leaving directory '/home/embray/src/sagemath/sage/local/var/tmp/sage/build/r-3.2.4-revised.p0/R-revised/src/library/Recommended'
Makefile:39: recipe for target 'recommended-packages' failed

--pkglock is an argument to the INSTALL script for installing R packages. But it seems it's been passed in as literally -- pkglock (with a space). Not sure why.

This issue also raises the question again about whether to make R an optional package (as well as whether to allow Sage to use a system install of R).

Upstream: None of the above - read trac for reasoning.

Component: porting: Cygwin

Keywords: windows cygwin R

Author: Erik Bray

Branch/Commit: b2ebe0b

Reviewer: Jeroen Demeyer

Issue created by migration from https://trac.sagemath.org/ticket/20655

@embray embray added this to the sage-7.3 milestone May 23, 2016
@embray
Copy link
Contributor Author

embray commented May 23, 2016

Attachment: r-3.2.4-revised.p0.log

@embray
Copy link
Contributor Author

embray commented May 24, 2016

comment:1

Ahahahahah I at least slightly understand better. I was losing my mind because I could not for the life of me find where this error message could be coming from.

Turns out it's coming from the GNU install command, which gets confused for R's INSTALL command on Windows because case-insensitivity.

@embray
Copy link
Contributor Author

embray commented May 24, 2016

comment:2

Okay, I think this is a bug in R IMO.

R installs a bunch of "scripts" particular to R with names like BUILD and INSTALL. R's install mistakenly marks these "scripts" as executable even though they do not contain a shebang line, so they are technically not executable in that sense. Instead it runs those scripts from a main script (called Rcmd) using exec.

The problem here is that Rcmd only run these R-specific scripts if they are executable, and exist in $R_HOME/bin. Realistically just whether they exist and are files in $R_HOME/bin should be good enough, since there shouldn't be any non-executable files in there. If nothing else it should try to exec and if that fails it will return a permission error. On Cygwin exec doesn't care if the file is marked executable or not, for this reason. It will just try to execute it.

@embray
Copy link
Contributor Author

embray commented May 24, 2016

Upstream: Not yet reported upstream; Will do shortly.

@embray
Copy link
Contributor Author

embray commented May 24, 2016

comment:4

I guess on *nix it still has to mark those scripts as executable in order for them to work with exec, even though they are not strictly executable on their own. Without a shebang line the shell will still try to execute them in the current shell process so I guess I rescind my complaint about them being marked executable.

Nevertheless the test -x used before executing them won't work sometimes on Cygwin :/

@embray
Copy link
Contributor Author

embray commented May 25, 2016

comment:5

This adds a patch that is the bare minimum to work around the issue and is essentially harmless.


New commits:

04d57ebAdd patch for R needed for the 'R CMD' command to work on Cygwin.

@embray
Copy link
Contributor Author

embray commented May 25, 2016

Author: Erik Bray

@embray
Copy link
Contributor Author

embray commented May 25, 2016

Commit: 04d57eb

@embray
Copy link
Contributor Author

embray commented May 25, 2016

Branch: u/embray/cygwin-r-issue

@embray
Copy link
Contributor Author

embray commented May 25, 2016

Changed upstream from Not yet reported upstream; Will do shortly. to None of the above - read trac for reasoning.

@embray
Copy link
Contributor Author

embray commented May 25, 2016

comment:6

Changed my mind about reporting upstream. According to this issue, and a few others it seems they don't want to officially support Cygwin builds and will close Cygwin issues as wontfix. This is also environment specific. It only affects you if you're building sage on a Cygwin filesystem that is mounted with noacl. So maybe this doesn't affect most users.

I still think the patch is worth keeping for the sake of least resistance on trying to build Sage on Cygwin. This was a very mysterious and hard to track down problem.

@vbraun
Copy link
Member

vbraun commented May 25, 2016

comment:7

needs some documentation (in the patch header)

@embray
Copy link
Contributor Author

embray commented May 30, 2016

comment:9

Done!

@tscrim
Copy link
Collaborator

tscrim commented Aug 7, 2016

comment:10

I was able to build R on cygwin32 using 7.3 without this. Still waiting on my cygwin64.

@tscrim
Copy link
Collaborator

tscrim commented Aug 7, 2016

comment:11

Also built okay without this patch on cygwin64. Should we close this as wont-fix?

@embray
Copy link
Contributor Author

embray commented Aug 8, 2016

comment:12

Replying to @tscrim:

Also built okay without this patch on cygwin64. Should we close this as wont-fix?

This issue only impacts if you're building in a directory mounted with noacl or with a messed up ACL which happens not infrequently if you have non-Cygwin processes messing with the permissions on files.

The end result is that setting executable flags may not always work.

@tscrim
Copy link
Collaborator

tscrim commented Aug 8, 2016

comment:13

So it's something more with the configuration then? I will try rebuilding R with this branch later tonight.

@jdemeyer
Copy link

jdemeyer commented Aug 8, 2016

comment:14

It worries me when executable permissions don't work correctly. I think that false positives (test -x returning true on a non-executable file) are not so bad, but false negatives (test -x returning false on an executable file) seem more problematic. I would not be surprised if there would be more programs (even just the shell) behaving badly for this reason.

@embray
Copy link
Contributor Author

embray commented Aug 8, 2016

comment:15

It's not really a problem in the shell so much. Cygwin relies on a lot more than the x flag to determine whether or not a file is executable, precisely because of the unreliability of emulating UNIX permissions on top of Windows ACL. At most, Cygwin just relies on the x permission as a hint.

@tscrim
Copy link
Collaborator

tscrim commented Aug 8, 2016

comment:16

So then should we consider merging this ticket Jeroen? I'm not sure what changing -x to -f really does with regards to how things are built.

@jdemeyer
Copy link

jdemeyer commented Aug 8, 2016

comment:17

I having nothing against adding this patch to R. I am only saying that it's an ugly workaround and not really a fix.

Just one thing: the patch is missing documentation. At the very least, it should refer to this Trac ticket.

@jdemeyer
Copy link

jdemeyer commented Aug 8, 2016

Work Issues: patch description

@embray
Copy link
Contributor Author

embray commented Aug 9, 2016

comment:19

Replying to @jdemeyer:

I having nothing against adding this patch to R. I am only saying that it's an ugly workaround and not really a fix.

No disagreement there. And really what it's working around is a shortcoming in Cygwin. If you prefer, it could be a Cygwin-only patch. It's just there's no real reason that the patched line strictly needs to test -x (and the code being patched is an ugly mess to begin with).

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 16, 2016

Changed commit from 04d57eb to b2ebe0b

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 16, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

b2ebe0bAdded patch description

@embray
Copy link
Contributor Author

embray commented Aug 16, 2016

New commits:

b2ebe0bAdded patch description

@jdemeyer
Copy link

comment:22

If this works for you...

@jdemeyer
Copy link

Changed work issues from patch description to none

@jdemeyer
Copy link

Reviewer: Jeroen Demeyer

@jdemeyer
Copy link

comment:23

because they do no contain a shebang line

I guess this is the real bug.

@embray
Copy link
Contributor Author

embray commented Aug 16, 2016

comment:24

Replying to @jdemeyer:

because they do no contain a shebang line

I guess this is the real bug.

Yes and no. I think the real bug is that it requires them to be executable, because the way those particular scripts are invoked, IIRC, is by sourcing them from an actual executable. In other words, they shouldn't be considered executables in their own right in the first place.

Otherwise yes, I agree they should have a shebang line.

@vbraun
Copy link
Member

vbraun commented Aug 19, 2016

Changed branch from u/embray/cygwin-r-issue to b2ebe0b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants