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] CRAN is unhappy about calls to stderr in source code #1909

Closed
jameslamb opened this issue Dec 17, 2018 · 7 comments
Closed

[R] CRAN is unhappy about calls to stderr in source code #1909

jameslamb opened this issue Dec 17, 2018 · 7 comments

Comments

@jameslamb
Copy link
Collaborator

This issue is a blocker for #629 (the path to CRAN distribution of LightGBM.

Overview

CRAN does not permit compiled code in packages to terminate R or directly write to stdout/stderr. See this NOTE that arises:

* checking compiled code ... NOTE
Note: information on .o files for x64 is not available
File 'E:/sandbox/LightGBM/lightgbm.Rcheck/lightgbm/libs/x64/lib_lightgbm.dll':
  Found '_exit', possibly from '_exit' (C)
  Found 'abort', possibly from 'abort' (C), 'runtime' (Fortran)
  Found 'exit', possibly from 'exit' (C), 'stop' (Fortran)
  Found 'printf', possibly from 'printf' (C)

Compiled code should not call entry points which might terminate R nor
write to stdout/stderr instead of to the console, nor use Fortran I/O
nor system RNGs. The detected symbols are linked into the code but
might come from libraries and not actually be called.
It is good practice to register native routines and to disable symbol
search.

See 'Writing portable packages' in the 'Writing R Extensions' manual.

This is a tough issue to solve because the package uses code shared between R and Python. Solving it for LightGBM probably involves doing something similar to what the XGBoost folks had to do (see here).

How to run R CMD CHECK

To run R CMD CHECK on the package, clone the repo and install from source per these directions, then build the package and run R CMD CHECK.

On Mac OS, this looks like running the following from your local clone of LightGBM:

export CXX=/usr/local/bin/g++-8
export CC=/usr/local/bin/gcc-8

# build the package
Rscript build_r.R

# Check
LGB_VERSION=$(cat R-package/DESCRIPTION | grep ^Version | tr -d "Version: ")
R CMD CHECK lightgbm_${LGB_VERSION}.tar.gz --as-cran | tee check.log | cat

How to close this issue

Contributions must pass our existing CI tests to be accepted. A contribution that fixes this issue will additionally result in R CMD CHECK not returning the note above on Mac OS.

@guolinke
Copy link
Collaborator

guolinke commented Jan 2, 2019

@jameslamb
I remember LightGBM R's package is a hacking solution, which actually doesn't call any R's functions.
We choose this due to the license issues.
Maybe we can hack for the R's print as well?

@jameslamb
Copy link
Collaborator Author

@guolinke Yes we probably will have to do something similar to what XGBoost did (see the link above).

Can you share the history with me on the specific license issues you had to hack around?

@guolinke
Copy link
Collaborator

guolinke commented Jan 2, 2019

@jameslamb refer to #19

@jameslamb
Copy link
Collaborator Author

thanks @guolinke

@Laurae2
Copy link
Contributor

Laurae2 commented Feb 3, 2019

@jameslamb related partially also to #1440 (Rpritnf control)

@guolinke
Copy link
Collaborator

guolinke commented Aug 1, 2019

closed due to duplicate to #1440

@guolinke guolinke closed this as completed Aug 1, 2019
@jameslamb jameslamb changed the title [R} CRAN is unhappy about calls to stderr in source code [R] CRAN is unhappy about calls to stderr in source code Sep 20, 2019
StrikerRUS added a commit that referenced this issue Mar 24, 2020
 #1909) (#2901)

* [R-package] started cutting over from custom R-to-C interface to R.h

* replaced LGBM_SE with SEXP

* fixed error about ocnflicting definitions of length

* got linking working

* more stuff

* eliminated R CMD CHECK note about printing

* switched from hard-coded include dir to the one from FindLibR.cmake

* cleaned up formatting in FindLibR.cmake

* commented-out everything in CI that does not touch R

* more changes

* trying to get better logs

* tried ignoring

* added error message to confirm a suspicion

* still trying to find R during R CMD CHECK

* restore full CI

* fixed comment

* Update R-package/src/cmake/modules/FindLibR.cmake

* changed strategy for finding LIBR_HOME on Windows

* Removed 32-bit Windows stuff in FindLibR.cmake

* Update R-package/src/cmake/modules/FindLibR.cmake

* Update CMakeLists.txt

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update CMakeLists.txt

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* removed some duplication in cmake scripts

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* added LIBR_CORE_LIBRARY back

* small fixes to CMakeLists

* simplified FindLibR.cmake

* some fixes for windows

* Apply suggestions from code review

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* allowed for directly passing LIBR_EXECUTABLE to FindLibR.cmake

* reorganized FindLibR.cmake to catch more cases

* clean up inconsistencies  in R calls in FindLibR.cmake

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* removed unnecessary log messages

* removed unnecessary unset() call

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
jameslamb added a commit to jameslamb/LightGBM that referenced this issue Mar 24, 2020
…#1440, fixes microsoft#1909) (microsoft#2901)

* [R-package] started cutting over from custom R-to-C interface to R.h

* replaced LGBM_SE with SEXP

* fixed error about ocnflicting definitions of length

* got linking working

* more stuff

* eliminated R CMD CHECK note about printing

* switched from hard-coded include dir to the one from FindLibR.cmake

* cleaned up formatting in FindLibR.cmake

* commented-out everything in CI that does not touch R

* more changes

* trying to get better logs

* tried ignoring

* added error message to confirm a suspicion

* still trying to find R during R CMD CHECK

* restore full CI

* fixed comment

* Update R-package/src/cmake/modules/FindLibR.cmake

* changed strategy for finding LIBR_HOME on Windows

* Removed 32-bit Windows stuff in FindLibR.cmake

* Update R-package/src/cmake/modules/FindLibR.cmake

* Update CMakeLists.txt

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update CMakeLists.txt

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* removed some duplication in cmake scripts

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* added LIBR_CORE_LIBRARY back

* small fixes to CMakeLists

* simplified FindLibR.cmake

* some fixes for windows

* Apply suggestions from code review

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* allowed for directly passing LIBR_EXECUTABLE to FindLibR.cmake

* reorganized FindLibR.cmake to catch more cases

* clean up inconsistencies  in R calls in FindLibR.cmake

* Update R-package/src/cmake/modules/FindLibR.cmake

Co-Authored-By: Nikita Titov <nekit94-08@mail.ru>

* removed unnecessary log messages

* removed unnecessary unset() call

Co-authored-by: Nikita Titov <nekit94-08@mail.ru>
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants