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 procedure #1

Closed
FR86 opened this issue Mar 21, 2017 · 5 comments
Closed

Installation procedure #1

FR86 opened this issue Mar 21, 2017 · 5 comments

Comments

@FR86
Copy link

FR86 commented Mar 21, 2017

Hey,
total R noob here, running on windows, fresh installation of R 3.3.3, RStudio 1.0.136. First of all, thanks a lot for this great project and particularly the significant amount of documentation you provide. Definitely not something taken for granted!
When following your installation instruction, devtools::install_github("sebkopf/isotopia", build_vignettes = TRUE, dependencies = TRUE) ran fine, however I had to iteratively try to run devtools::install_github("sebkopf/isoread", build_vignettes = TRUE, dependencies = TRUE) to find out I had to manually

install.packages("stringi")
install.packages("magrittr")
install.packages("htmltools")
install.packages("rprojroot")
install.packages("evaluate")
install.packages("yaml")
install.packages("highr")
install.packages("ggplot2")

before I could install isoread.
Before running devtools::install_github("sebkopf/isorunN2O", build_vignettes = TRUE, dependencies = TRUE), I had to further manually

install.packages("dplyr")
install.packages("plotly")
install.packages("openxlsx")

and then install RTools.
Interestingly,

devtools::install_github("sebkopf/isorunN2O", build_vignettes = FALSE, dependencies = TRUE)
vignette("N2O_data_reduction_tutorial")

Did work before installing RTools and the last three packages.

Is all of this expected behaviour covered by the Troubleshooting part of your Readme or did I do anything wrong?
Apologies if this is not the right place for this.

@sebkopf
Copy link
Owner

sebkopf commented Mar 25, 2017

Thanks for reporting this issue! it allowed me to finally figure out what was going on. It's a bug in the CRAN version of devtools that seems to affect primarily Windows systems during initial installation of GitHub packages. I wrote up a guide that I think will allow to work around this issue here and included links in all the READMEs. Please do let me know if you encounter this issue again with this workaround.

@FR86
Copy link
Author

FR86 commented Mar 30, 2017

Finally got around to testing this. Cleaned the slate before trying, to be sure uninstalled everything, wiped the library foder, reinstalled R and RStudio.
Unfortunately, the command devtools::install_github("hadley/devtools", ref = "1ce84b04568ff7846c3da754f28e7e22a23c8737") produces an Error: Command failed (1).
After it is sucessfully downloading and installing a few packages from CRAN and two source package installations (pkgbuild,pkgload), the output is:

* installing *source* package 'devtools' ...
** R
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
*** arch - i386
Error : package 'devtools' is not installed for 'arch = i386'
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'D:/Path/To/R/R-3.3.3/library/devtools'
* restoring previous 'D:/Path/To/R/R-3.3.3/library/devtools'
Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) :
  problem copying D:\Path\To\R\R-3.3.3\library\00LOCK-hadley-devtools-1ce84b0\devtools\libs\x64\devtools.dll to D:\Path\To\R\R-3.3.3\library\devtools\libs\x64\devtools.dll: Permission denied

This is irrespective of whether or not I have RTools installed and in the PATH.

Some more research reveals that this is a known windows issue. ?build_github_devtools says

[...]
In Windows, it's not possible to upgrade devtools while the package is loaded because there is an open DLL, which in Windows can't be overwritten.
[...]

Looking at the source code of build_github_devtools, I was trying to cook up a variant that takes an arbitrary revision instead of taking the master branch. As the first real failure was a complaint about missing dependencies, I decided to stop there and not manually install dependencies to run a command that should remove the need to manually install dependencies.

Also, running build_github_devtools() to simply install the master branch resulted in an abort from I think devtools::has_devel. It is unclear to me why that function tries to used completely wrong paths to gcc, which is properly set up to be callable via command line (via the installation of RTools, albeit to a non-standard location).

As I was able to install using the procedure described in the original issue description, I guess the current situation is just what windows people have to live with until devtools 1.13 hits CRAN.

@sebkopf
Copy link
Owner

sebkopf commented Mar 31, 2017

Ah right, the problem with the Windows DLLs. Unfortunately build_github_devtools might be the easiest way to get around the issue even if it forces installing the master development branch instead of just the specific commit, which may have other issues. Obviously that doesn't always work either given your experience with problems in has_devel. I'm really sorry for the hassle and much appreciate your efforts to figure out how to resolve it. Failing all workarounds, the best approach I would suggest is looking at the GitHub package's DESCRIPTION file and installing the dependencies by hand (as you have done, although hopefully less painfully than getting sequential missing package errors). I've updated the Gist describing this problem, hopefully it will be useful to others encountering these same problems. In the meantime, I'm crossing my fingers devtools 1.13 hits CRAN soon.

@FR86
Copy link
Author

FR86 commented Apr 2, 2017

No hassle. As I said before, I've noted down which packages to install once and can install isorunN2O with those fairly easily.
I consider this experience an uncommon way to learn R and its particularities.
To follow up on this a little more:
To get RTools to play nice with the R CMD SHLIB command that caused a failure of build_github_devtools I

  • found my RHOME directory via running "R.home(component = "home")
  • Opened file RHOME/etc/x64/Makeconf
  • Edited the definition of BINPREF to match Path/To/RTools/mingw_64/bin directory

At this point, devtools::has_devel() returned TRUE.
Then I could use these functions:

GetExtension <- function()
{
  if (.Platform$OS.type == "windows")
    return("zip")
  else
    return("tgz")
}

#Modified version of devtools::build_github_devtools, installs arbitrary revision of devtools
BuildCustomDevtoolsInstallation <- function (outfile = NULL, revision = "1ce84b04568ff7846c3da754f28e7e22a23c8737")
{
  if (!has_devel()) {
    stop("This requires a working development environment.")
  }
  ext <- GetExtension()
  if (is.null(outfile))
    outfile <- paste0("./devtools.", ext)
  
  if (is.null(revision))
    revision <- master
  url <- paste0("https://github.com/hadley/devtools/archive/", revision, ".zip")
    
  message("Downloading devtools from ", url)
  bundle <- file.path(tempdir(), paste0("devtools-", revision, ".zip"))
  request <- httr::GET(url)
  httr::stop_for_status(request)
  writeBin(httr::content(request, "raw"), bundle)
  on.exit(unlink(bundle))
  utils::unzip(bundle, exdir = tempdir())
  pkgdir <- file.path(tempdir(), paste0("devtools-", revision))
  #Install this particular devtools version dependencies
  install_deps(pkgdir)
  built_pkg <- devtools::build(pkgdir, binary = TRUE)
  message("Renaming file to ", outfile)
  file.rename(built_pkg, outfile)
  invisible(outfile)
}

InstallIsorunN2O <- function()
{
  #Install devtools
  install.packages("devtools")
  #make devtools namespace available
  library(devtools)
  #build desired revision of devtools
  BuildCustomDevtoolsInstallation()
  #no longer use devtools namespace
  detach("package:devtools", unload=TRUE)
  #Now restart R to make sure dll's are unloaded
  .rs.restartR()
  #install
  install.packages("./devtools.zip", repos = NULL)
  #delete zipped build
  unlink("./devtools.zip")
  #install isorunN2O
  devtools::install_github("sebkopf/isotopia", build_vignettes = TRUE, dependencies = TRUE)
  devtools::install_github("sebkopf/isoread", build_vignettes = TRUE, dependencies = TRUE)
  devtools::install_github("sebkopf/isorunN2O", build_vignettes = TRUE, dependencies = TRUE)
}

to try and install using the revision 1ce84b04568ff7846c3da754f28e7e22a23c8737 you indicate in the Gist. Remark: Restarting r via .rs.restartR() only works with RStudio.

Long story short: Neither that particular version nor the current Master (d8ab190cd05e4bd2a3688a1eab3324109060b111) works as advertised.
I get

Installation failed: install_packages(package_name, repos = remote$repos, type = remote$pkg_type,      dependencies = NA, ..., quiet = quiet, out_dir = out_dir,      skip_if_log_exists = skip_if_log_exists) : formal argument "repos" matched by multiple actual arguments

multiple times.

Looks like this bug in devtools is not resolved in master after all...

@FR86
Copy link
Author

FR86 commented Apr 2, 2017

To finish up, this is what I would currently run to install isorunN2O on windows:

install.packages(c("devtools", "dplyr", "plotly", "ggplot2", "openxlsx", "rprojroot", "evaluate", "highr"))
devtools::install_github("sebkopf/isotopia", build_vignettes = TRUE, dependencies = TRUE)
devtools::install_github("sebkopf/isoread", build_vignettes = TRUE, dependencies = TRUE)
devtools::install_github("sebkopf/isorunN2O", build_vignettes = TRUE, dependencies = TRUE)
#To get isorunN2O::run_data_viewer() up and running 
install.packages(c("R.methodsS3","R.oo", "httpuv", "xtable"))

Probably, this needs a working installation of RTools.

@sebkopf sebkopf closed this as completed Mar 3, 2021
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