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

invalid version check by installBuildTools on Mac OS #4175

Closed
bhogan-mitre opened this issue Jan 17, 2019 · 10 comments
Closed

invalid version check by installBuildTools on Mac OS #4175

bhogan-mitre opened this issue Jan 17, 2019 · 10 comments
Labels
bug macos stale Issues which have been closed automatically due to inactivitiy.

Comments

@bhogan-mitre
Copy link

@bhogan-mitre bhogan-mitre commented Jan 17, 2019

System details

RStudio Edition :  Desktop
RStudio Version :  1.2.1237
OS Version      :  macOS Mojave 10.14.2
R Version       :  3.5.2

Steps to reproduce the problem

> getOption("buildtools.check", NULL)("Building R package from source")
[1] FALSE

Describe the problem in detail

I believe that I have build tools installed, with XCode and the command line interface.

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

However, rstudioapi::buildToolsCheck() returns FALSE, and I am unable to use devtools to install a package that needs compiling.

checkBuildTools is testing for identical(.Platform$pkgType, "mac.binary.mavericks")

However, mac.binary.mavericks is not a value that is ever obtained.

> .Platform$pkgType
[1] "mac.binary.el-capitan"

My real issue is with installBuildTools always just showing the CNET page. Since this is testing isOSXMavericks(), I suspect the trouble may be related to the bug mentioned above.

I have followed the suggestions from @jimhester and @kevinushey here: r-lib/devtools#1879, and still had no luck.

Is there a way to test the values returned by module_context::isOSXMavericks() and module_context::hasOSXMavericksDeveloperTools()?

Describe the behavior you expected

I expect to be able to use devtools::install_github, and install packages that need compiling.

@bhogan-mitre
Copy link
Author

@bhogan-mitre bhogan-mitre commented Feb 1, 2019

Clarifying that the bug is visible in an RStudio session:

> getOption("buildtools.check")
function (action) 
{
    if (identical(.Platform$pkgType, "mac.binary.mavericks")) {
        .Call("rs_canBuildCpp")
    }
    else {
        if (!.Call("rs_canBuildCpp")) {
            .rs.installBuildTools(action)
            FALSE
        }
        else {
            TRUE
        }
    }
}

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Feb 12, 2019

This works on my Mojave machine:

> getOption("buildtools.check", NULL)("Building R package from source")
[1] TRUE

Have you installed the system headers for Mojave? https://stackoverflow.com/questions/53169970/where-are-the-c-headers-in-macos-mojave

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Feb 12, 2019

(I saw that was recommended on the linked discussion in devtools but wanted to confirm)

@bhogan-mitre
Copy link
Author

@bhogan-mitre bhogan-mitre commented Feb 14, 2019

As noted in r-lib/pkgbuild#63, the culprit for me was a lingering ~/.R/Makevars file from an old Xcode install. This SO post had the very simple suggestion to delete that file.

So now I get:

> rstudioapi::buildToolsCheck()
[1] TRUE

I'll leave this issue open for now, as I still think it is bizarre to be checking identical(.Platform$pkgType, "mac.binary.mavericks") when there is no chance that could be true.

@ronblum ronblum added the bug label Mar 8, 2019
@hrbrmstr
Copy link
Contributor

@hrbrmstr hrbrmstr commented Aug 8, 2020

I have full Xcode 12.0 beta installed and this has been happening consistently for me:

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

$ sw_vers -productVersion
11.0
RStudio.Version()$version
## [1] ‘1.4.687’

If in RStudio and I, say, try to do:

install_github("r-lib/vctrs")

I get:

image

plus:

rstudioapi::buildToolsCheck()
## [1] FALSE

If I drop to iTerm and startup R the install works fine:

install_github("r-lib/vctrs")
Using github PAT from envvar GITHUB_PAT
Downloading GitHub repo r-lib/vctrs@master
   checking for file/private/var/folders/r_/8gkkj9d57739wtr_wn1gv_hm0000gn/T/Rtmp34UCc4/remotes26b54402cc64/r-lib-vctrs-1b3cd7c/DESCRIPTION’ ✔  checking for file/private/var/folders/r_/8gkkj9d57739wtr_wn1gv_hm0000gn/T/Rtmp34UCc4/remotes26b54402cc64/r-lib-vctrs-1b3cd7c/DESCRIPTION’
─  preparingvctrs:checking DESCRIPTION meta-information ...cleaning srcinstalling the package to process help pages

And, Makevars is:

cat ~/.R/Makevars
CC=clang
CXX=clang++

Of note (and, unsurprisingly?):

pkgbuild::check_build_tools(debug = TRUE)

fails miserably as well (and doesn't debug anything).

but (surprisingly?)

pkgbuild::has_compiler(debug = TRUE)
## Running /Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB \
  foo.c
## clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include   -fPIC  -Wall -g -O2  -c foo.c -o foo.o
## clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o foo.so foo.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
##  
## [1] TRUE

so it kinda looks like some sort of "perhaps RStudio should really dig into this and fix it universally" effort might be needed.

If I can carve out any time I'll see what src/cpp/session/modules/build/SessionBuild.cpp is doing to come up with the errant assertion about no build tools.

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Aug 9, 2020

This is where RStudio detects if macOS command line tools are installed:

bool hasMacOSCommandLineTools()
{
if (!isMacOS())
return false;
return FilePath("/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk").exists();
}

Does this need to change to accommodate macOS Big Sur? (Maybe we need to be running xcode-select -p to allow the use of "any" set of macOS developer tools?)

Does xcode-select --install help here?

@hrbrmstr
Copy link
Contributor

@hrbrmstr hrbrmstr commented Aug 9, 2020

It should probably check for either the straight command line tools or the ones that come along for the ride with Xcode 12, now (for the first few months of Big Sur there was no separate command line tools install and the ones that come with Xcode, now, are the same, so no need for another installation if one has full Xcode).

@stale
Copy link

@stale stale bot commented Feb 5, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.

@stale stale bot added the stale Issues which have been closed automatically due to inactivitiy. label Feb 5, 2021
@stale
Copy link

@stale stale bot commented Feb 19, 2021

This issue has been automatically closed due to inactivity.

@stale stale bot closed this as completed Feb 19, 2021
@contefranz
Copy link

@contefranz contefranz commented Mar 27, 2021

The problem is still here. I am experiencing what @hrbrmstr did. My C++ code has no problems and I can install other packages. For some reason, I cannot build my own package. I have everything installed in terms of both Xcode and Command Line Tools. Can you suggest or hint what is wrong?

This is my current R session info.

sessionInfo()
#> R version 4.0.4 (2021-02-15)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Catalina 10.15.7
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] digest_0.6.27     assertthat_0.2.1  magrittr_2.0.1    reprex_1.0.0     
#>  [5] evaluate_0.14     highr_0.8         stringi_1.5.3     rlang_0.4.10     
#>  [9] cli_2.3.1         rstudioapi_0.13   fs_1.5.0          rmarkdown_2.7    
#> [13] tools_4.0.4       stringr_1.4.0     glue_1.4.2        xfun_0.22        
#> [17] yaml_2.2.1        compiler_4.0.4    htmltools_0.5.1.1 knitr_1.31

Created on 2021-03-27 by the reprex package (v1.0.0)

UPDATE

Also, everything works just fine from terminal. I can do R CMD build and R CMD check no problem.

UPDATE 2

For some other reason, I can do devtools:load_all("."). Magically, I can then build and check the package inside RStudio. Any hints?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug macos stale Issues which have been closed automatically due to inactivitiy.
Projects
None yet
Development

No branches or pull requests

6 participants