@@ -52,15 +52,17 @@ install_tinytex = function(
5252 " the installation is aborted."
5353 )
5454 if (! is.logical(force )) stop(' The argument "force" must take a logical value.' )
55+ continue_inst = function () {
56+ tolower(substr(readline(' Continue the installation anyway? (Y/N) ' ), 1 , 1 )) == ' y'
57+ }
5558 # if tlmgr is detected in the system, ask in interactive mode whether to
5659 # continue the installation, and stop in non-interactive() mode
5760 p = which_bin(c(' tlmgr' , ' pdftex' , ' xetex' , ' luatex' ))
5861 p = p [p != ' ' ]
5962 if (! force && length(p )) {
6063 message(" Found '" , p [1 ], " ', which indicates a LaTeX distribution may have existed in the system." )
6164 if (interactive()) {
62- if (tolower(substr(readline(' Continue the installation anyway? (Y/N) ' ), 1 , 1 )) != ' y' )
63- return (invisible (' ' ))
65+ if (! continue_inst()) return (invisible (' ' ))
6466 } else stop(
6567 ' If you want to force installing TinyTeX anyway, use tinytex::install_tinytex(force = TRUE).'
6668 )
@@ -77,8 +79,17 @@ install_tinytex = function(
7779 if (dir != ' ' ) {
7880 dir = gsub(' [/\\ ]+$' , ' ' , dir ) # remove trailing slashes
7981 check_dir(dir )
82+ dir = xfun :: normalize_path(dir )
83+ if (is_windows() && ! valid_path(dir )) {
84+ warning(
85+ " The directory path '" , dir , " ' contains spaces or non-ASCII characters, " ,
86+ " and TinyTeX may not work. Please use a path with pure ASCII characters and no spaces." ,
87+ immediate. = TRUE
88+ )
89+ if (! force && ! (interactive() && continue_inst())) return (invisible (dir ))
90+ }
8091 unlink(dir , recursive = TRUE )
81- user_dir = normalizePath( dir , mustWork = FALSE )
92+ user_dir = dir
8293 }
8394
8495 repository = normalize_repo(repository )
@@ -218,13 +229,16 @@ win_app_dir = function(s) {
218229 )
219230 return (d2 )
220231 }
221- if (grepl( ' ^[!-~]+$ ' , d )) return (d2 ) # path is pure ASCII and has no spaces
232+ if (valid_path( d )) return (d2 )
222233 }
223234 d = Sys.getenv(' ProgramData' )
224235 if (d == ' ' ) stop(" The environment variable 'ProgramData' is not set." )
225236 file.path(d , s )
226237}
227238
239+ # test if path is pure ASCII and has no spaces
240+ valid_path = function (x ) grepl(' ^[!-~]+$' , x )
241+
228242# check if /usr/local/bin on macOS is writable
229243check_local_bin = function () {
230244 if (os_index != 3 || is_writable(p <- ' /usr/local/bin' )) return ()
0 commit comments