cloc icon indicating copy to clipboard operation
cloc copied to clipboard

Windows issue: spaces in path

Open metanoid opened this issue 5 years ago • 3 comments

Running the example for cloc on Windows gives an error.

Under the hood, the system command is C:\STRAWB~1\perl\bin\perl.exe C:/Program Files/R/R-4.0.0/library/cloc/bin/cloc.pl --quiet --csv C:/Program Files/R/R-4.0.0/library/cloc/extdata

Unfortunately, there are spaces in the paths (because of Program Files) and so perl cannot find the cloc.pl script.

metanoid avatar Aug 21 '20 08:08 metanoid

Thx for kicking the package tyres & submitting a bug report!

I switched all the system() calls to {processx] run() calls which should fix this, but I'm not near a Windows box to test it fully. Let me know if it works and I'll close it out.

hrbrmstr avatar Aug 21 '20 09:08 hrbrmstr

The main issue is fixed - I can run the cloc function and get output for a local file or directory now on Windows.

The test called "retrieving things from CRAN works" fails, the output of

r cran <- cloc_cran("dplyr", "https://cran.rstudio.com", .progress=FALSE) is

              source language file_count file_count_pct loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct   pkg
1 dplyr_1.0.2.tar.gz     <NA>          0              0   0       0           0              0             0                0 dplyr

Not sure if this is a separate issue or not.

metanoid avatar Aug 21 '20 10:08 metanoid

👍🏽

I'll have to poke at the cloc_cran() issue as it is likely Windows platform-related since:

(cran <- cloc_cran("dplyr", "https://cran.rstudio.com", .progress=FALSE))
## # A tibble: 8 x 11
##   source           language    file_count file_count_pct   loc loc_pct blank_lines blank_line_pct comment_lines comment_line_pct pkg  
##   <chr>            <chr>            <int>          <dbl> <int>   <dbl>       <int>          <dbl>         <int>            <dbl> <chr>
## 1 dplyr_1.0.2.tar… R                  185        0.407   13684 2.98e-1        3223        0.296            5749          0.397   dplyr
## 2 dplyr_1.0.2.tar… HTML                 9        0.0198   5917 1.29e-1         306        0.0281             18          0.00124 dplyr
## 3 dplyr_1.0.2.tar… Markdown             2        0.00441  1802 3.93e-2         899        0.0827              0          0       dplyr
## 4 dplyr_1.0.2.tar… C++                  9        0.0198    780 1.70e-2         198        0.0182             26          0.00179 dplyr
## 5 dplyr_1.0.2.tar… Rmd                 11        0.0242    641 1.40e-2         793        0.0729           1452          0.100   dplyr
## 6 dplyr_1.0.2.tar… C/C++ Head…          1        0.00220    99 2.16e-3          18        0.00166             0          0       dplyr
## 7 dplyr_1.0.2.tar… SVG                 10        0.0220     10 2.18e-4           0        0                   0          0       dplyr
## 8 dplyr_1.0.2.tar… SUM                227        0.5     22933 5.00e-1        5437        0.5              7245          0.5     dplyr

works on macOS and linux.

I'll keep this open until I get a chance to do that.

hrbrmstr avatar Aug 21 '20 11:08 hrbrmstr