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

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/')

Related

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

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

Error when trying to install TinyTeX using tinytex R package "cannot contact mirror.ctan.org, returning a backbone server!"

I am trying to use RMarkdown to knit my report to a pdf. I am on my work computer (without administrative privileges and behind a firewall), and chose TinyTeX as a LaTeX distribution because I was hoping it would still work without having to involve the IT department (at my place of work it takes ages to get elevated privileges). I had no problems installing the tinytex R package, but I run into errors when using the package to install TinyTeX. The code with errors is below:
>tinytex::install_tinytex()
trying URL 'http://mirror.ctan.org/systems/texlive/tlnet/install-tl.zip'
trying URL 'http://mirror.ctan.org/systems/texlive/tlnet/install-tl.zip'
Content type 'application/zip' length 22541272 bytes (21.5 MB)
downloaded 21.5 MB
trying URL 'https://yihui.org/gh/tinytex/tools/pkgs-custom.txt'
trying URL 'https://yihui.org/gh/tinytex/tools/pkgs-custom.txt'
Content type 'text/plain; charset=utf-8' length 551 bytes
downloaded 551 bytes
trying URL 'https://yihui.org/gh/tinytex/tools/tinytex.profile'
trying URL 'https://yihui.org/gh/tinytex/tools/tinytex.profile'
Content type 'text/plain; charset=utf-8' length 295 bytes
downloaded 295 bytes
Then at this point I get a dialog box that pops up and states: "Next you may see two error dialog boxes about the missing luatex.dll, and an error message like "Use of uninitialized value in bitwise or (|)..." in the end. These messages can be ignored." When I click 'Okay', I don't see any other dialog boxes but I get the following 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
cannot contact mirror.ctan.org, returning a backbone server!
Loading http://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb
C:\Users\*****\AppData\Local\Temp\RtmpgHbZh0\install-tl-20200214\install-tl: TLPDB::from_file could not initialize from: http://www.ctan.org/tex-archive/systems/texlive/tlnet/tlpkg/texlive.tlpdb
C:\Users\*****\AppData\Local\Temp\RtmpgHbZh0\install-tl-20200214\install-tl: Maybe the repository setting should be changed.
C:\Users\*****\AppData\Local\Temp\RtmpgHbZh0\install-tl-20200214\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 messages:
1: In download.file(url, output, ..., method = method) :
URL 'http://mirror.ctan.org/systems/texlive/tlnet/install-tl.zip': status was 'Couldn't connect to server'
2: In download.file(url, output, ..., method = method) :
URL 'https://yihui.org/gh/tinytex/tools/pkgs-custom.txt': status was 'Couldn't connect to server'
3: In download.file(url, output, ..., method = method) :
URL 'https://yihui.org/gh/tinytex/tools/tinytex.profile': status was 'Couldn't connect to server'
4: In file.remove("TinyTeX/install-tl.log") :
cannot remove file 'TinyTeX/install-tl.log', reason 'No such file or directory'
After this, I try tinytex:::is_tinytex() and I get FALSE.
I am using R version 3.6.2, RStudio version 1.2.1335 and I'm on a Windows 10 x64.
I'm not familiar enough with R, RMarkdown or TinyTeX to understand what is going wrong and how to fix it. Perhaps it is because of no admin rights or the firewall...Any help is appreciated!

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'.

Using install.packages with custom temp dir

I would like to install a package with a security profile that does not have access to /tmp , but has its own temporary directory, for example /tmp/jeroen. However even though I try to pass the TMPDIR environment variable, it still fails because it tries to use /tmp. Below a toy example using RAppArmor and unixtools (see here for the test profile)
> library(RAppArmor)
> library(unixtools)
> dir.create("/tmp/jeroen")
> set.tempdir("/tmp/jeroen")
> setwd(tempdir());
> aa_change_profile("r-test")
Switching profiles...
> print(tempdir());
[1] "/tmp/jeroen"
> install.packages("plyr", lib="/tmp/jeroen", configure.vars="TMPDIR=/tmp/jeroen")
trying URL 'http://cran.rstudio.com/src/contrib/plyr_1.8.tar.gz'
Content type 'application/x-gzip' length 384462 bytes (375 Kb)
opened URL
==================================================
downloaded 375 Kb
Fatal error: cannot create 'R_TempDir'
The downloaded source packages are in
‘/tmp/jeroen/downloaded_packages’
When looking at the kern.log file (which logs security messages), it turns out that the problem is that R CMD INSTALL still tried to use /tmp which was denied:
Jul 24 19:41:34 Jeroen-Antec kernel: [16270.696805] type=1400 audit(1374687694.097:599):
apparmor="DENIED" operation="mkdir" parent=5798 profile="r-test" name="/tmp/RtmpcUOJuQ/"
pid=5802 comm="R" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000
Is there any way I can tell R CMD INSTALL to use /tmp/jeroen instead?
The correct answer was given by #hadley in the comments: in order to make sure install.packages uses the custom temporary directory, one needs to do
Sys.setenv(TMPDIR="/tmp/jeroen")
in addition to:
configure.vars="TMPDIR=/tmp/jeroen"
This way both the extraction and the installation of the package avoids the system or user default temporary directory.
The documentation in help(tempdir) pretty clearly states that TMP, TMPDIR, ... are used:
By default, ‘tmpdir’ will be the directory given by ‘tempdir()’.
This will be a subdirectory of the per-session temporary directory
found by the following rule when the R session is started. The
environment variables ‘TMPDIR’, ‘TMP’ and ‘TEMP’ are checked in
turn and the first found which points to a writable directory is
used: if none succeeds ‘/tmp’ is used.
So if setting one alone does not help, maybe you want to set several, and make sure the permissions on your 'replacement directory' are permissive enough etc pp.

Installing packages onto R

For some reason I am suddenly not able to install packages in R (I have subsequently updated to the latest version of R and am running Windows 7). For example, if I type:
install.packages('beeswarm')
Installing package into ‘D:/Rlibs’ (as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session --- trying URL 'http://www.stats.bris.ac.uk/R/bin/windows/contrib/3.0/beeswarm_0.1.5.zip'
Content type 'text/html' length unknown opened URL downloaded 1859
bytes
Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package",
"Type")) : cannot open the connection In addition: Warning
messages: 1: In unzip(zipname, exdir = dest) : error 1 in extracting
from zip file 2: In read.dcf(file.path(pkgname, "DESCRIPTION"),
c("Package", "Type")) : cannot open compressed file
'beeswarm/DESCRIPTION', probable reason 'No such file or directory'
I have read that in Windows 7 there can be important restrictions on rights to writing to certain folders etc. so I've gone to some lengths to install R and library folders in non-default areas of my computer, and to allow myself rights to certain folders, but to no avail. Possibly also of importance is when I type:
.libPaths()
# [1] "D:/Rlibs"
# [2] "C:/Users/L.Halsey/Documents/R/win-library/3.0"
# [3] "C:/Users/L.Halsey/Documents/Documents/R-3.0.1/library"
I have created several folders in an attempt to create one that I could successfully install libraries into and set them up to be recognised by R using 'environment variables' from the start button. I don't know how to delete any of them though - not sure if this is relevant to my overall problem of not now being able to install/update packages for some reason.
The error being reported is inability to open a connection. In Windows that is often a firewall problem and is in the Windows R FAQ. The usual first attempt should be to run internet2.dll. From a console session you can use:
setInternet2(TRUE)
(You are correct in thinking this is not due to your library setup. The error says nothing about permissions.) I don't think just typing .libPaths should return that character vector since on my machine I would need to type .libPaths() to see something like that. If you wanted to reduce the number of places for libraries you can use the .libPaths function for setting the values. This would pick the second and third of the existing paths
.libPaths( .libPaths()[2:3] )
The inner call retrieves the path vector and the outer call sets it to a reduced vector.
Running RStudio as administrator fixed it for me!
I will probably duplicate a lot of other answers on the stackoverflow, but I got exactly the same error as OP, namely:
Warning messages: 1: In unzip(zipname, exdir = dest) : error 1 in extracting from zip file 2: In read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type")) : cannot open compressed file 'zoo/DESCRIPTION', probable reason 'No such file or directory'
Turned out, while I as a user had permissions to write in a certain directory, R did not. In order to be sure you don't have something similar, do following:
get a usb drive, let's name it E
download package source as a .zip file and store it onto usb-drive in some directory, let's name it E:/source
Create directory for libraries on the usb drive, let's name it E:/libs
Install packages calling R command install.package from the R console and setting all relevant directories to point to your usb drive:
(here I use package zoo as an example)
install.packages("E:/source/zoo_1.7-12.zip",
destdir = 'E:/source', # no "/" after the path
lib = 'E:/libs',
repos = NULL)
Load the package from the directory, where you installed it:
library('zoo', lib.loc = 'E:/libs')
After you are sure, it works this way on your usb drive, you can start resolving directories permissions, and try out by changing the paths in the code above.
update:
In some windows environments even your usb-stick might be protected from read-write by the R. Make sure you check the permissions using the machine you are working from.
The following worked for me (based on the answer above)
install.packages("clustvarsel", lib = "C:/Users/dnentchev/My Programs/R-3.2.2/library")
I had the same problem. I turned the windows firewall off, and Run RStudio as administrator. so, that error fixed.

Resources