Trouble running whitebox in Rstudio ("~/whitebox_tools.exe" not found) - r

I am trying to run 'whitebox' packages in R.
To get started, I follow the steps in the link: https://github.com/giswqs/whiteboxR
install.packages("whitebox")
whitebox::install_whitebox()
Console:
------------------------------------------------------------------------
Could not find WhiteboxTools!
------------------------------------------------------------------------
Your next step is to download and install the WhiteboxTools binary:
> whitebox::install_whitebox()
If you have WhiteboxTools installed already run `wbt_init(exe_path=...)`':
> wbt_init(exe_path='/home/user/path/to/whitebox_tools')
For whitebox package documentation, ask for help:
> ??whitebox
For more information visit https://giswqs.github.io/whiteboxR/
------------------------------------------------------------------------
Performing one-time download of WhiteboxTools binary from
https://www.whiteboxgeo.com/WBT_Windows/WhiteboxTools_win_amd64.zip
(This could take a few minutes, please be patient...)
trying URL 'https://www.whiteboxgeo.com/WBT_Windows/WhiteboxTools_win_amd64.zip'
Content type 'application/zip' length 15383844 bytes (14.7 MB)
downloaded 14.7 MB
WhiteboxTools binary is located here: C:/Users/frsu0056/OneDrive - Umeå universitet/Documents/R/win-library/4.1/whitebox/WBT/whitebox_tools.exe
You can now start using whitebox
library(whitebox)
wbt_version()
After downloading i run:
library(whitebox)
if(wbt_init()==TRUE){print("all good")}#confirms if the whitebox_tools.exe exists in,'C:/Users/frsu0056/OneDrive - Umeå universitet/Documents/R/win-library/4.1/whitebox/WBT/whitebox_tools.exe'.
console:
[1] "all good"
Now, if I try to run any function in the whitebox package, it returns an odd error message
for example
wbt_version()
returns:
Error :
Error running WhiteboxTools
whitebox.exe_path: "C:/Users/frsu0056/OneDrive - Umeå universitet/Documents/R/win-library/4.1/whitebox/WBT/whitebox_tools.exe"; File exists? TRUE
Arguments: --version
Error in system(exeargs, intern = TRUE, ignore.stderr = ignore.stderr, : '"C:/Users/frsu0056/OneDrive - Umeå universitet/Documents/R/win-library/4.1/whitebox/WBT/whitebox_tools.exe"' not found
Yet, the wbt_init() returns TRUE so the file exists in the given directory. Nevertheless, the wbt_version() function can not find it.
And so the story goes for any function in the whitebox package. It just can't find the .exe file yet the file exists in the folder where it is supposed to be.
Anyone else get the same problem running this? And what could possibly be wrong here?
Below is the .exe file resting in the directory.

The problem with whitebox in my experience is that it cannot decode spaces. I don't think the problem is the one drive folder per se, just that there are spaces in the file path. I would suggest not having your packages installed in a one drive folder or any other folder where the path has spaces. To change the folder where your libraries are installed, refer to the solution: Change R default library path using .libPaths in Rprofile.site fails to work

Related

Error with install.packages using renv|knit|rmarkdown

I'm updating the renv folder from a project in order to adjust the libraries, but it seems I'm having a permission problem. After running renv::init() and trying to installing manually the remaining libraries using install.packages() I always get the message
Error: failed to retrieve 'https://cran.rstudio.com/bin/windows/contrib/4.2/ipeadatar_0.1.6.zip' [error code 23]
1: curl: (23) Failure writing output to destination
2: curl: (23) Failure writing output to destination
Using .libPath() I can see that the renv was created in the "AppData" hidden folder
1] "C:/Users/André Ferreira/AppData/Local/R/cache/R/renv/library/MacroBRA_Wrld-09789847/R-4.2/x86_64-w64-mingw32"
So checking my permissions, I couldn't see anything wrong. Any thoughts about this problem? The thing it's that when I open my .Rmd file and try to knit, I receive the same message "1: curl: (23) Failure writing output to destination", now from rmarkdown retrieve installation, so it may be a configuration/permission problem.
Adding "C:\rtools42\usr\bin" and "C:\Program Files\R\R-4.2.1\bin" in the environment variable didn't help.
As I could see, opening an empty file from rstudio, I could use install.packages() without problem.
Although this doesn't solve the problem directly, you can also instruct renv to use a different library path with something like:
# use a project-local library path
RENV_PATHS_LIBRARY = renv/library
in your project's .Renviron file. Depending on your environment, you might also consider placing the library path in an alternate location.
See https://rstudio.github.io/renv/articles/packages.html#r-cmd-build-and-the-project-library for more details.

Can't understand the error message from blogdown

I am trying to make a blog with blogdown using my windows machine, but get this error message when I use RStudio (File/New Project/New Directory/Website using blogdown/ ... and enter Directory name: "new"):
setwd("C:/Users/AndrésLagerlöf/OneDrive - Andrés Lagerlöf Konsulttjänst AB/R/blog")
'C:\Users\Andr‚sLagerl”f\AppData\Roaming\Hugo\hugo.exe" new site "new' is not recognized as an internal or external command,
operable program or batch file.
Error in shell(cmd, mustWork = TRUE, intern = intern) :
'"C:\Users\AndrésLagerlöf\AppData\Roaming\Hugo\hugo.exe" new site "new" --force -f toml' execution failed with error code 1
I do not know what to make out of this error message. Does anyone know how to fix this?
I use R version 4.0.0 and RStudio Version 1.2.5033.
Kind regards,
Andrés
You may consider installing Hugo to a path that does not contain multibyte characters. Per documentation ?blogdown::install_hugo:
If you want to install Hugo to a custom path, you can set the global option blogdown.hugo.dir to a directory to store the Hugo executable before you call install_hugo(), e.g., options(blogdown.hugo.dir = '~/Downloads/hugo_0.20.1/').
This is also mentioned in Appendix D.1 in the blogdown book. You'd better set this option in your .Rprofile (see Section 1.4 for how), so the setting won't be lost after you restart R.

cannot install tinytex package. (Maybe the repository setting should be changed.)

im using R and quite new at rmarkdown. i want to knit my rmarkdown into pdf formatted file and i already read that i need to install tinytex package.
i enter the code as instructed on https://yihui.org/tinytex/
install.packages('tinytex')
tinytex::install_tinytex()
and i got this error code
Starting to install TinyTeX to C:\Users*****\AppData\Roaming\TinyTeX. It will take a few minutes.
Automated TeX Live installation using profile: ../tinytex.profile
Loading https://mirror.unpad.ac.id/ctan/systems/texlive/tlnet/tlpkg/texlive.tlpdb
C:\Users*****\AppData\Local\Temp\RtmpW6xVT8\install-tl-20191206\install-tl: TLPDB::from_file could not initialize from: https://mirror.unpad.ac.id/ctan/systems/texlive/tlnet/tlpkg/texlive.tlpdb
C:\Users*****\AppData\Local\Temp\RtmpW6xVT8\install-tl-20191206\install-tl: Maybe the repository setting should be changed.
C:\Users*****\AppData\Local\Temp\RtmpW6xVT8\install-tl-20191206\install-tl: More info: https://tug.org/texlive/acquire.html
TinyTeX installed to C:\Users*****\AppData\Roaming\TinyTeX
Please quit and reopen your R session and IDE (if you are using one, such as RStudio or Emacs) and check if tinytex:::is_tinytex() is TRUE.
Warning message:
In file.remove("TinyTeX/install-tl.log") :
cannot remove file 'TinyTeX/install-tl.log', reason 'No such file or directory'
i restart my r and rstudio, run tinytex::is_tinytex(), returned FALSE.
i guess the repository cannot be accessed anymore so i tried to change the repo but still it doesnt change.
can anyone help me with solution? thanks
UPDATE :
i tried to run this as Yihui Xie told me :
tinytex::install_tinytex(repository = 'http://dante.ctan.org/tex-archive/')
and
tinytex::install_tinytex(repository = 'http://mirrors.ibiblio.org/CTAN/')
and return this
trying URL
'http://dante.ctan.org/tex-archive/systems/texlive/tlnet/install-tl.zip'
length 22539829 bytes (21.5 MB) downloaded 21.5 MB trying URL
'https://yihui.name/gh/tinytex/tools/pkgs-custom.txt' Content length
81 bytes downloaded 351 bytes trying URL
'https://yihui.name/gh/tinytex/tools/tinytex.profile' Content length
81 bytes downloaded 295 bytes Starting to install TinyTeX to
C:\Users\Kandu\AppData\Roaming/TinyTeX. It will take a few minutes.
Automated TeX Live installation using profile: ../tinytex.profile
Loading
https://mirror.unpad.ac.id/ctan/systems/texlive/tlnet/tlpkg/texlive.tlpdb
C:\Users\Kandu\AppData\Local\Temp\Rtmp8OFCvK\install-tl-20191209\install-tl:
TLPDB::from_file could not initialize from:
https://mirror.unpad.ac.id/ctan/systems/texlive/tlnet/tlpkg/texlive.tlpdb
C:\Users\Kandu\AppData\Local\Temp\Rtmp8OFCvK\install-tl-20191209\install-tl:
Maybe the repository setting should be changed.
C:\Users\Kandu\AppData\Local\Temp\Rtmp8OFCvK\install-tl-20191209\install-tl:
More info: https://tug.org/texlive/acquire.html TinyTeX installed to
C:\Users\Kandu\AppData\Roaming/TinyTeX Please quit and reopen your R
session and IDE (if you are using one, such as RStudio or Emacs) and
check if tinytex:::is_tinytex() is TRUE. Warning messages:
1: In
file.remove("TinyTeX/install-tl.log") : cannot remove file
'TinyTeX/install-tl.log', reason 'No such file or directory'
2: In
in_dir(target, { : The repository
http://dante.ctan.org/tex-archive/systems/texlive/tlnet does not seem
to be accessible. Reverting to the default CTAN mirror.
idk why but it keep trying to download from https://mirror.unpad.ac.id.
any explanation?
At the moment, the mirror https://mirror.unpad.ac.id does not seem to have a valid SSL certificate, so the site is not accessible. You can find other accessible mirrors at https://ctan.org/mirrors/mirmon. To specify the mirror, use the repository argument. Below are two possible examples:
tinytex::install_tinytex(repository = 'http://mirrors.ibiblio.org/pub/mirrors/CTAN/')
tinytex::install_tinytex(repository = 'http://dante.ctan.org/tex-archive/')

Unable to run Papaja in Windows due to spaces in folder name

I'm trying to load papaja in R (version 3.6.0). I'm running Windows 10 on my computer. When I try to run devtools::install_github("crsh/papaja") I get the following error message:
package ‘markdown’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\My
Name\AppData\Local\Temp\RtmpKCmBDG\downloaded_packages
ERROR
cannot change to directory 'C:\Users\My'
The system cannot find the path specified.
Error in (function (command = NULL, args = character(), error_on_status =
TRUE, :
System command error
From some research, including this post and this post, I realise that this is a common issue, but none of the answers I can find help me work around this in papaja.
For info, I don't have this problem when installing other packages using install.packages().
I have managed to solve this problem after hours and hours of googling. The problem is not papaja; it is the presence of spaces in the path, which devtools does not deal with well.
To solve this, I first changed my library path:
.libPaths("C:/Program Files/R/R-3.6.1/library") # for R v.3.6.1
At first I couldn't get this to work - I kept getting the error 'lib = "C:/Program Files/R/R-3.6.1/library"' is not writable. Basically, this is because I did not have permission to write into this folder. To fix this, you simply close RStudio, go to the folder where the programme is saved and right click, then select 'Run as administrator'.

Building PhantomJS 2.0 on Windows results in a strange error

I am trying to build PhantomJS 2.0 on Windows from the c:\fastio\phantomjs\phantomjs directory. For some reason, the build process fails after a while, with 2 errors (see error message below):
1) It tries to access "C:fastiophantomjsphantomjssrcqtqtbasebinmoc.exe". Obviously, the backslash characters between directory names are somehow getting stripped away deep in the build process - possibly a mismatch between Windows-style "\" and Linux-style "/" (but this is only a guess).
2) There's another error, "Failed to read names from file: C:/fastio/phantomjs/phantomjs/src/qt/qtwebkit/Source/WebCore/mathml/mathtags.in".
If I remove sh.exe from the PATH, the build still gets to this point, and only error #2 appears, leading me to think that error #2 is the real problem here.
Here is the full error message (as far as I can tell this is happening while building WebKit):
sh: C:fastiophantomjsphantomjssrcqtqtbasebinmoc.exe: command not found
Failed to read names from file: C:/fastio/phantomjs/phantomjs/src/qt/qtwebkit/Source/WebCore/mathml/mathtags.in at C:/fastio/phantomjs/phantomjs/src/qt/qtwebkit/Source/WebCore/dom/make_names.pl line 315.
NMAKE : fatal error U1077: 'C:\Users\Eugene\AppData\Local\GitHub\PortableGit_c2ba306e536fdf878271f7fe636a147ff37326ad\bin\perl.EXE' : return code '0x7f'
Stop.
(By the way, I saw this question but I'm already past the issues described there, my error is happening later in the build process.)
How can I make this work?
Full logs below:
Console output:
http://pastebin.com/btMeNPz4
QT build log file build_qt_4-285-20-0859.log:
http://pastebin.com/LUEJz7E0
WebKit build log file build_webkit_4-285-20_0859.log:
http://pastebin.com/494TivXF
PhantomJS build log file build_phantomjs_4-285-20_0859.log:
Empty
Looks like I found the solution myself, here were my steps:
Remove as much as possible from the PATH leaving only the entries critical to the build process
Most importantly, remove all GitHub's git directories from the PATH
Install GIT separately (not from GitHub but from git-scm.com), add its cmd directory only (not its bin directory) to the PATH
Install ActivePerl separately, add it to the PATH
It's moving past the error I asked about with the steps above (still not sure if it will finish the build successfully, it's taking a while).

Resources