Skip to content

cmake detection appears to be broken for Linux builds #279

Open

Description

@michaelmayer2

According to

s2/tools/build_absl.sh

Lines 22 to 23 in ff3f727

if test -z "$CMAKE"; then CMAKE="`which cmake`"; fi
if test -z "$CMAKE"; then CMAKE=/Applications/CMake.app/Contents/bin/cmake; fi
we are checking if CMAKE env variable is empty and then first set CMAKE to which cmake (appropriate for Linux envs) but in the next line we overwrite the same with the MacOS equivalent without checking if we are on MacOS or not.

It would be great to make those two checks work on both Linux and MacOS so that s2 can use Linux's cmake to build Abseil as a system dependency.

Activity

  1. michaelmayer2 commented on May 22, 2025

    @michaelmayer2
    ContributorAuthor

    potential fix in #280

  2. paleolimbot commented on May 22, 2025

    @paleolimbot
    Collaborator

    Thank you for opening!

    I'm curious what the error message is you're getting, since I've run this a fair bit on Linux forgetting to install cmake first. The last time this happened I remember getting a message telling me to install cmake...is there a situation where we aren't getting that message?

  3. michaelmayer2 commented on May 22, 2025

    @michaelmayer2
    ContributorAuthor

    Below is the output I get on Rocky Linux 9.

    You are right that cmake was missing but I would not have expected it to try to use /Applications/CMake.app/Contents/bin/cmake instead as a fall-back - which then also fails.

    The patch will make sure that /Applications/CMake.app/Contents/bin/cmake will only be used if the OS is Darwin while the output of which cmake will be used to detect cmake on Linux.

    Full installation output:
    * installing *source* package ‘s2’ ...
    ** package ‘s2’ successfully unpacked and MD5 sums checked
    staged installation is only possible with locking
    ** using non-staged installation
    Found OpenSSL pkg-config cflags and libs!
    Testing compiler OpenSSL configuration using PKG_CFLAGS=
    ** Using PKG_CONFIG_PATH=:/tmp/Rtmp6E2yoY/R.INSTALL609e133db3bd/s2/tools/pkgconfig
    ** Building abseil-cpp using cmake
    Warning message:
    In readRenviron("~/.R/Makevars") :
      file '/root/.R/Makevars' cannot be opened for reading
    GNU Make 4.3
    Built for x86_64-redhat-linux-gnu
    Copyright (C) 1988-2020 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.
    Using MAKE=make 
    /usr/bin/which: no cmake in (/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin)
    tools/build_absl.sh: line 24: /Applications/CMake.app/Contents/bin/cmake: No such file or directory
    cmake not found
    ** CMake build of Abseil failed
    ** Abseil can be installed with:
    ** - apt-get install libabsl-dev
    ** - dnf install abseil-cpp-devel
    ** - brew install abseil
    ** If a system install of Abseil is not possible, cmake is required to build
    ** the internal vendored copy.
    ERROR: configuration failed for package ‘s2’
    * removing ‘/tmp/RtmpKlSMjh/pkg-lib60471d5bdd5/s2’
    Type .Last.error to see the more details.
    
  4. paleolimbot commented on May 22, 2025

    @paleolimbot
    Collaborator

    Ah, got it. The error telling you to install cmake does show up but it's confusing because /Applications/CMake.app/Contents/bin/cmake obviously doesn't exist on linux. The fix seems reasonable, I'll take a look!

  5. priyapatel1 commented on May 23, 2025

    @priyapatel1

    I'm having a similar issue when I try to install s2:

    > install.packages('s2')
    Installing package into ‘/usr/local/lib/R/site-library’
    (as ‘lib’ is unspecified)
    trying URL 'https://cloud.r-project.org/src/contrib/s2_1.1.8.tar.gz'
    Content type 'application/x-gzip' length 2966956 bytes (2.8 MB)
    ==================================================
    downloaded 2.8 MB
    
    * installing *source* package ‘s2’ ...
    ** this is package ‘s2’ version ‘1.1.8’
    ** package ‘s2’ successfully unpacked and MD5 sums checked
    ** using staged installation
    Found OpenSSL pkg-config cflags and libs!
    Testing compiler OpenSSL configuration using PKG_CFLAGS=
    ** Using PKG_CONFIG_PATH=:/tmp/RtmpipCUzL/R.INSTALL38119195ca694/s2/tools/pkgconfig
    ** Building abseil-cpp using cmake
    Warning message:
    In readRenviron("~/.R/Makevars") :
      file '/root/.R/Makevars' cannot be opened for reading
    GNU Make 4.2.1
    Built for x86_64-pc-linux-gnu
    Copyright (C) 1988-2016 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.
    Using MAKE=make 
    tools/build_absl.sh: 24: /Applications/CMake.app/Contents/bin/cmake: not found
    cmake not found
    ** CMake build of Abseil failed
    ** Abseil can be installed with:
    ** - apt-get install libabsl-dev
    ** - dnf install abseil-cpp-devel
    ** - brew install abseil
    ** If a system install of Abseil is not possible, cmake is required to build
    ** the internal vendored copy.
    ERROR: configuration failed for package ‘s2’
    * removing ‘/usr/local/lib/R/site-library/s2’
    
    The downloaded source packages are in
            ‘/tmp/Rtmp08vdLY/downloaded_packages’
    Warning message:
    In install.packages("s2") :
      installation of package ‘s2’ had non-zero exit status
    

    I'm not sure if I should create a separate issue or not, but don't know how to resolve this.

  6. michaelmayer2 commented on May 23, 2025

    @michaelmayer2
    ContributorAuthor

    @priyapatel1 same issue than mine - if you install cmake on your system the installation will succeed.

    You can avoid installing cmake if you install the Abseil system requirement.

    The error message kind of says that cmake is missing but it is confusing to read since it tries to use cmake from the default path in MacOS and then of course fails - hence my PR to clear up this confusion.

    Relevant part of your log is

    cmake not found
    ** CMake build of Abseil failed
    
  7. priyapatel1 commented on May 23, 2025

    @priyapatel1

    Installing cmake worked for me, thanks

  8. paleolimbot commented on May 23, 2025

    @paleolimbot
    Collaborator

    Thanks for reporting! We definitely need to make that part of the failure clearer in the message 😬

    Probably also

    GNU Make 4.2.1
    Built for x86_64-pc-linux-gnu
    ...
    

    ...should be suppressed.

  9. michaelmayer2 commented on May 26, 2025

    @michaelmayer2
    ContributorAuthor

    I think there is ample room for improvement like with any software, just trying to get the part fixed that tripped me up in #280

  10. GuiAlDuS commented on Sep 5, 2025

    @GuiAlDuS

    This is also happening to me when building on docker over openanalytics/r-ver:4.5.1

    18.37 GNU Make 4.3
    18.37 Built for x86_64-pc-linux-gnu
    18.37 Copyright (C) 1988-2020 Free Software Foundation, Inc.
    18.37 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
    18.37 This is free software: you are free to change and redistribute it.
    18.37 There is NO WARRANTY, to the extent permitted by law.
    18.37 Using MAKE=make 
    18.37 tools/build_absl.sh: 26: : Permission denied
    18.37 cmake not found
    18.37 ** CMake build of Abseil failed
    18.37 ** Abseil can be installed with:
    18.37 ** - apt-get install libabsl-dev
    18.37 ** - dnf install abseil-cpp-devel
    18.37 ** - brew install abseil
    18.37 ** If a system install of Abseil is not possible, cmake is required to build
    18.37 ** the internal vendored copy.
    18.37 ERROR: configuration failed for package ‘s2’
    18.37 * removing ‘/usr/local/lib/R/site-library/s2’
    18.46 Warning message:
    18.46 In i.p(...) :
    18.46   installation of package ‘/tmp/Rtmpmjz6vs/file74c163a7d/s2_1.1.9.tar.gz’ had non-zero exit status
    

    One thing that might be important to note is that I did install libabsl-dev before installing S2 but the installer says it can´t access it.

    Thanks!

  11. paleolimbot commented on Sep 5, 2025

    @paleolimbot
    Collaborator

    I think that last error might be that cmake is not available! I am guessing the version of abseil installed via system is too old.

  12. michaelmayer2 commented on Sep 9, 2025

    @michaelmayer2
    ContributorAuthor

    This is also happening to me when building on docker over openanalytics/r-ver:4.5.1

    Doesn't this container set the repository to use binary packages from p3m.dev, suited for the linux distro used (ubuntu noble) ? in my little test the package installation worked quite well (installing the latest version of sf that is).

    Related to this, realizing that the container runs R as the root user makes this a prime target for using the pak package:

    > install.packages("pak")
    Installing package into ‘/usr/local/lib/R/site-library’
    (as ‘lib’ is unspecified)
    trying URL 'https://p3m.dev/cran/__linux__/noble/latest/src/contrib/pak_0.9.0.tar.gz'
    Content type 'binary/octet-stream' length 7022577 bytes (6.7 MB)
    ========p=====a====k================:======:===========
    downloaded 6.7 MB
    
    * installing *binary* package ‘pak’ ...
    * DONE (pak)
    
    The downloaded source packages are in
    	‘/tmp/RtmpIAgeZF/downloaded_packages’
    > pak::pak("s2")
    ✔ Updated metadata database: 4.10 MB in 9 files.                          
    ✔ Updating metadata database ... done                                     
                                                                              
    → Will install 3 packages.
    → Will download 3 packages with unknown size.
    + Rcpp   1.1.0 [dl]
    + s2     1.1.9 [dl] + ✖ libabsl-dev, ✖ cmake, ✖ libssl-dev
    + wk     0.9.4 [dl]
    → Will install 3 system packages:
    + cmake        - s2
    + libabsl-dev  - s2
    + libssl-dev   - s2
    ℹ Getting 3 pkgs with unknown sizes
    ✔ Got Rcpp 1.1.0 (x86_64-pc-linux-gnu-ubuntu-24.04) (2.19 MB)                
    ✔ Got s2 1.1.9 (x86_64-pc-linux-gnu-ubuntu-24.04) (2.21 MB)                  
    ✔ Got wk 0.9.4 (x86_64-pc-linux-gnu-ubuntu-24.04) (1.73 MB)              
    ✔ Downloaded 3 packages (6.13 MB) in 1.9s                                
    ℹ Installing system requirements
    ℹ Executing `sh -c apt-get -y update`
    ℹ Executing `sh -c apt-get -y install libabsl-dev cmake libssl-dev`
    ✔ Installed wk 0.9.4  (1.1s)                                         
    ✔ Installed Rcpp 1.1.0  (1.1s)                                       
    ✔ Installed s2 1.1.9  (1.1s)                                     
    ✔ 1 pkg + 2 deps: added 3, dld 3 (6.13 MB) [28.1s]     
    

    As you can see, not only the package is being installed, but also any system dependencies !

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions