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

Cannot build INLA from source on Windows #99

Open
weshinsley opened this issue Jun 12, 2024 · 15 comments
Open

Cannot build INLA from source on Windows #99

weshinsley opened this issue Jun 12, 2024 · 15 comments

Comments

@weshinsley
Copy link

weshinsley commented Jun 12, 2024

If we try and build INLA from source, we get the error message below:-

> install.packages("INLA",
                 repos = c(getOption("repos"),
                           INLA = "https://inla.r-inla-download.org/R/stable"),
                 type = "source",
                 dep = TRUE)

Installing package into ‘C:/Users/wrh1/Documents/R/win-library/4.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
  dependencies ‘Rgraphviz’, ‘graph’ are not available
trying URL 'https://inla.r-inla-download.org/R/stable/src/contrib/INLA_24.05.10.tar.gz'
Content type 'application/x-gzip' length 61448956 bytes (58.6 MB)
downloaded 58.6 MB

* installing *binary* package 'INLA' ...
C:\Windows\cp.exe: invalid option -- )
Try `C:\Windows\cp.exe --help' for more information.
ERROR: installing binary package failed
* removing 'C:/Users/wrh1/Documents/R/win-library/4.4/INLA'
* restoring previous 'C:/Users/wrh1/Documents/R/win-library/4.4/INLA'
Warning in install.packages :
  installation of package ‘INLA’ had non-zero exit status

This is easy to work around with R 4.4 - just don't build from source, and the binary gets downloaded - if the ready-build version is available. But for users still on R 4.3, there is no matching binary of 24.05.10 in https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.3/, so install.packages tries to build 24.05.10 from source. They have to either upgrade to R 4.4, or specify version 24.05.01-1 manually, because there's a binary for that.

So the workarounds are not hard, but is seems there's a problem in the source version for building at the moment.

@finnlindgren
Copy link
Collaborator

finnlindgren commented Jun 12, 2024

The build process for the INLA R package requires a manual step of first building the standalone inla binary executable, so no INLA package version can be built purely using the normal R build process. When installing from the repositories, one cannot "build" the package in a working format, as that will not include the executable, so "building from source" will not work on any R version, or any existing INLA source code version, without manual intervention. This may be improved in the future, but the build process is difficult to fully automate.

The "stable" repository cannot yet be used with R 4.4, as only the testing version has been built for R 4.4, currently one must use testing with 4.4, and stable with 4.3. But yes, the missing binary for 24.05.10 will cause an issue. R should let you specify that you only want "binary" installation, which should work around the issue without needing to specify the version (as that's not supported by install.packages()):

install.packages("INLA", repos = ..., type = "binary")

@finnlindgren
Copy link
Collaborator

The documentation for install.packages contains a further option:

For a binary install from a repository, the function checks for the availability of a source package on the same repository, and reports if the source package has a later version, or is available but no binary version is. This check can be suppressed by using

  options(install.packages.check.source = "no")

and should be if there is a partial repository containing only binary files.

@weshinsley
Copy link
Author

OK - thanks for these workarounds - but just to highlight the immediate problem - So if we want to use the stable version, we should use R 4.3 for now - fine - but if an R 4.3 user follows the installation instructions from here (https://www.r-inla.org/download-install) - which say:

install.packages("INLA",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/stable"), dep=TRUE) 

that will fail with the error message I got above because it will try to install 24.05.10 from source. So I think for now, either updating the installation instructions with the workaround to make install.packages not do that, or filling in the missing binary in the 4.3 folder might be helpful to do.

@weshinsley
Copy link
Author

weshinsley commented Jun 12, 2024

Further - I tested on R 4.3 with options(install.packages.check.source = "no") - but it made no difference:-

> options(install.packages.check.source = "no")
> install.packages("INLA",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/stable"), dep=TRUE) 
Warning in install.packages :
  partial argument match of 'dep' to 'dependencies'
Installing package into ‘E:/Rlib’
(as ‘lib’ is unspecified)
Warning in install.packages :
  dependencies ‘Rgraphviz’, ‘graph’ are not available

  There is a binary version available but the source version is later:
         binary   source needs_compilation
INLA 24.05.01-1 24.05.10             FALSE

installing the source package ‘INLA’

trying URL 'https://inla.r-inla-download.org/R/stable/src/contrib/INLA_24.05.10.tar.gz'
Content type 'application/x-gzip' length 61448956 bytes (58.6 MB)
downloaded 58.6 MB

* installing *binary* package 'INLA' ...
C:\WINDOWS\cp.exe: invalid option -- )
Try `C:\WINDOWS\cp.exe --help' for more information.
ERROR: installing binary package failed
* removing 'E:/Rlib/INLA'
Warning in install.packages :
  installation of package ‘INLA’ had non-zero exit status

The downloaded source packages are in
	‘E:\Rtmp\Rtmp4ows8C\downloaded_packages’

For now, an explicit INLA version, for which a binary exists for that R-version seems to be the only workaround - or pressing ahead with R 4.4 regardless, where the binary does seem to exist.

@finnlindgren
Copy link
Collaborator

Did the type = "binary" method work?

@finnlindgren
Copy link
Collaborator

I see in the NEWS.md file that 24.05.10 was the first R 4.4 build, so the error with that one is that it shouldn't be present in any form in the 4.3 folder.

@finnlindgren
Copy link
Collaborator

Have you found a method for specifying a specific INLA version that actually works? I don't see an option for that in install.packages, and I don't have access to try remotes::install_version() on Windows.

@weshinsley
Copy link
Author

type = "binary" on the install.packages did work - it picked the most recent binary correctly.

trying URL 'https://inla.r-inla-download.org/R/stable/bin/windows/contrib/4.3/INLA_24.05.01-1.zip'

Yes, so the issue then is why does it still try to build 24.05.10 from source in R 4.3

@finnlindgren
Copy link
Collaborator

It tries to build it because it finds a newer source package. I would have expected turning off that check to have fixed it; that may be an error in the install.packages documentation for that feature.

@finnlindgren
Copy link
Collaborator

The most generally useful approach on windows and macos seems to be for such users to always specify type = "binary" when installing INLA, so that seems to be the hint that needs to be added to the webpage. That way, the instruction will work also in future cases, and not having to rely on specific version instructions.

@weshinsley
Copy link
Author

weshinsley commented Jun 12, 2024

Have you found a method for specifying a specific INLA version that actually works? I don't see an option for that in install.packages, and I don't have access to try remotes::install_version() on Windows.

Yes, you're right - and further remotes::install_version requires type="source". So type="binary" on install.packages indeed seems the best option, since building from source on Windows does not seem likely to be possible.

(On our cluster, we use pkgdepends, which can let us specify both the repo and version)

@finnlindgren
Copy link
Collaborator

I see that https://www.r-inla.org/download-install already does mention the remotes::install_version() option, specifically in the context of the transition period when INLA gets built for new R versions. But I think as long as the available packages in the repository section for each version are correct, then the install.packages(..., type = "binary") option would be sufficient. So removing the 24.05.10 source package from the 4.3 section might make the type argument the only thing needed to handle the issue for all R versions.

@weshinsley
Copy link
Author

I think all the instructions for remotes::install_version probably need reviewing.

From R 4.3, the instructions there do the following:-

> remotes::install_version("INLA", version="23.05.30",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/testing"), dep=TRUE) 
Trying https://cloud.r-project.org
Trying https://inla.r-inla-download.org/R/testing
Error in download_version_url(package, version, repos, type) : 
  version '23.05.30' is invalid for package 'INLA'

and for R 4.4, since remotes::install_version has default type='source' that can't be changed to binary, we get the familiar error:-

> remotes::install_version("INLA", version="24.05.10",repos=c(getOption("repos"), INLA="https://inla.r-inla-download.org/R/testing"), dep=TRUE) 
Downloading package from url: https://inla.r-inla-download.org/R/testing/src/contrib/INLA_24.05.10.tar.gz
Installing package into ‘C:/Users/wrh1/Documents/R/win-library/4.4’
(as ‘lib’ is unspecified)
* installing *binary* package 'INLA' ...
C:\Windows\cp.exe: invalid option -- )
Try `C:\Windows\cp.exe --help' for more information.
ERROR: installing binary package failed

@weshinsley
Copy link
Author

weshinsley commented Jun 13, 2024

Incidentally, for R 4.3 the issue is that version 23.05.30 doesn't exist - the earliest is 23.05.30-1 - and the most recent 24.05.01-1 - but again, you can't install any of these with remotes::install_version because that would require compilation from source. (I haven't tested R 4.1)

So at present, the only way you can install any INLA package on any R version on windows is

install.packages("INLA",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/stable"), dep=TRUE, type="binary") 

which will get the most recent binary for your R version. There is no way I think to get a specific older (binary) version, or to use any method that involves compiling from source.

@finnlindgren
Copy link
Collaborator

There's always a way: downloading the needed tar/zip file manually and installing from the file instead of the repository. But the type="binary" option is easier.

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

No branches or pull requests

2 participants