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

Installation fails when Rprofile prints to stdout #646

Closed
brookslogan opened this issue Jun 10, 2024 · 4 comments · Fixed by #647
Closed

Installation fails when Rprofile prints to stdout #646

brookslogan opened this issue Jun 10, 2024 · 4 comments · Fixed by #647
Labels

Comments

@brookslogan
Copy link
Contributor

Before submitting the issue

  • Check whether a bug report is the right format for your issue. For questions about using the mice package, see Discussions. For theoretical background about the mice methods, see Flexible Imputation of Missing Data.
  • Please make sure that you are using the latest version of mice (e.g. with the packageVersion() or sessionInfo() function).
  • Please verify whether the bug has already been addressed (e.g. on GitHub or Stack Overflow.

Describe the bug
A clear and concise description of what the bug is.

When a home Rprofile exists, and that .Rprofile produces output to stdout, installation of mice fails. (Likely the same for site Rprofiles without home Rprofiles.)

To Reproduce
Create a reproducible example, see e.g. the reprex package. A good reprex uses simulated or public data to showcase the bug. We recommend using one of the incomplete datasets included in the mice package (e.g. mice::boys) and the reprex() function from the reprex package.

Paste the code and output of your reprex here.

home_rprofile_path <- "~/.Rprofile" # assuming no R_PROFILE setting
if (file.exists(home_rprofile_path )) {
  stop ('Home .Rprofile already exists; refusing to clobber with this test.')
  # (`file(home_rprofile_path, "x")` would be preferable but isn't supported)
} else { # `stop` doesn't actually stop in `reprex`
  withr::with_file(home_rprofile_path, {
    writeLines('cat("Using settings from ~/.Rprofile\n")', home_rprofile_path)
    if ("mice" %in% installed.packages()) {
      remove.packages("mice")
    }
    install.packages("mice")
  })
}
#> Installing package into '/home/fullname/R/x86_64-redhat-linux-gnu-library/4.1'
#> (as 'lib' is unspecified)
#> Warning in install.packages("mice"): installation of package 'mice' had
#> non-zero exit status

Created on 2024-06-10 with reprex v2.0.2

Running within reprex appears to reproduce the problem but not the error message to the console; this is the relevant part from running outside reprex:

g++ -m64 -std=gnu++14 -shared -L/usr/lib64/R/lib -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -o mice.so RcppExports.o legendre.o match.o matchindex.o Using settings from ~/.Rprofile -L/usr/lib64/R/lib -lR
/usr/bin/ld: cannot find Using: No such file or directory
/usr/bin/ld: cannot find settings: No such file or directory
/usr/bin/ld: cannot find from: No such file or directory
/usr/bin/ld: cannot find ~/.Rprofile: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/make/shlib.mk:10: mice.so] Error 1
ERROR: compilation failed for package ‘mice’

Expected behavior
A clear and concise description of what you expect to happen without the bug.

Installation succeeds.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

This appears to occur due to this line (or this Windows equivalent). Note that Rcpp:::LdFlags() is deprecated and produces an empty string, and hasn't been needed for long enough that it likely could be dropped now.

User workarounds include temporarily renaming the problematic Rprofile, or producing output to stderr (e.g., with message()) instead of stdout in the Rprofile.

@stefvanbuuren
Copy link
Member

Before building, have you tried removing all src/*.o and src/*.so files?

@brookslogan
Copy link
Contributor Author

brookslogan commented Jun 11, 2024

I didn't have a src/ directory (within my working directory at least), as I was attempting to install from CRAN or RSPM. Here's some testing of devtools-based installation:

  • Cloning and installing or re-installing with devtools::install('~/<path>/mice', quick = TRUE, build = FALSE, upgrade = FALSE, keep_source = TRUE) (from ESS) works even with a problematic home Rprofile. Existing src/*.o files don't seem to interfere with re-installation, and devtools::clean_dll()ing also doesn't introduce problems.
  • Attempting to install directly with devtools::install_github("amices/mice") has the same error as install.packages() though.
  • (pak::pkg_install("mice") appears to succeed in building and installing directly from CRAN/RSPM from source, even after clearing its cache.)

I should note that I am on Fedora, R version 4.1.3 (2022-03-10), devtools_2.4.5, Rcpp_1.0.12.

  • If Fedora has a different configuration than other systems (e.g., where it builds packages or maybe the lack of an R_BUILD_ENVIRON setting?), that might factor in.
  • If R and/or devtools have updated the way builds are done and attempt to isolate them more in later versions by ignoring the home and maybe site Rprofiles, then this may no longer be a problem.

@stefvanbuuren
Copy link
Member

Thanks for trying.

I am not on Fedora and cannot reproduce. I fear I won't be able to help.

brookslogan pushed a commit to brookslogan/mice that referenced this issue Jun 12, 2024
Rcpp:::LdFlags() is deprecated and produces an empty
string (https://www.rdocumentation.org/packages/Rcpp/versions/1.0.12/topics/LdFlags-deprecated),
and hasn't been needed for long enough that there may not be loss in
compatibility with current
systems (RcppCore/Rcpp#1302 (comment)).
Removing these Makevars settings is a simple way to address issues for some
system x Rprofile combinations (amices#646).
brookslogan added a commit to brookslogan/mice that referenced this issue Jun 12, 2024
Rcpp:::LdFlags() is deprecated and produces an empty
string (https://www.rdocumentation.org/packages/Rcpp/versions/1.0.12/topics/LdFlags-deprecated),
and hasn't been needed for long enough that there may not be loss in
compatibility with current
systems (RcppCore/Rcpp#1302 (comment)).
Removing these Makevars settings is a simple way to address issues for some
system x Rprofile combinations (amices#646).
@brookslogan
Copy link
Contributor Author

Thanks for checking on this. The fix for me was as simple as #647, though I haven't done extensive testing. Thought I'd at least throw it in a PR as an option.

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

Successfully merging a pull request may close this issue.

2 participants