Bug report #14143
getRequiredPackages in RUtils.py does not respect commented out lines
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||22145|
The function getRequirePackages in python/plugins/processing/algs/r/RUtils.py includes packages that are commented out.
The regular expression in the function searches for the string 'library' without respect for lines that are commented out with a '#'. The returned list of packages includes package names for lines that are commented out in the .rsx file. As a result, getImortCommands in python/plugins/processing/algs/r/RAlgorithm.py adds lines to the generated r script that tries to install packages that are not needed by the script.
As an example:
in an .rsx file:
tryCatch(find.package("network"), error=function(e) install.packages("network", dependencies=TRUE))
to processing_script.r even though the library is not needed or used.
I can work around this in my code by removing the commented out library line from my .rsx file. However, the regular expression should be modified to respect comments