Troubleshooting .onLoad failed in loadNamespace() for 'XML' in Bitbucket Pipeline build

I'm trying to use the Salesforcer package in a Bitbucket Pipeline.

However, on installation of Salesforcer I get the following error message:

* installing *source* package ‘salesforcer’ ...
** package ‘salesforcer’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error: .onLoad failed in loadNamespace() for 'XML', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/usr/local/lib/R/site-library/XML/libs/XML.so':
  libxml2.so.2: cannot open shared object file: No such file or directory
Execution halted
ERROR: lazy loading failed for package ‘salesforcer’
* removing ‘/usr/local/lib/R/site-library/salesforcer’
The downloaded source packages are in
	‘/tmp/RtmppCefXI/downloaded_packages’
Warning message:
In install.packages("salesforcer") :
  installation of package ‘salesforcer’ had non-zero exit status

My bitbucket-pipelines.yml file is as follows:

image: rocker/r-ver:4.2.1

pipelines:
  custom:
    script4-pipeline-3: # The name displayed in the Bitbucket Cloud GUI
      - step:
          script:
            - apt-get update && apt-get install -y unzip git git-core libc-client-dev libkrb5-dev && rm -r /var/lib/apt/lists/*  
            - Rscript -e "install.packages('salesforcer')"  
            - Rscript "script4.R"  
            - git add "script4.csv"  
            - git commit -m "[Pipeline] Add foo CSV file."  
            - git push  

Trying to troubleshoot this, I tried the command apt-get install libxml2 but got:

+ apt-get install libxml2
Reading package lists...
Building dependency tree...
Reading state information...
Package libxml2 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'libxml2' has no installation candidate

Would anyone have any tips on how to proceed / resolve this issue??

I wonder if you re-run apt-get update prior to your apt-get install libxml2 call ? The first command would repopulate the repository information in the local docker container which allows the second to find libxml2

More to the point: I would simply add libxml2 to the existing apt-get install command in your pipeline definition. Once Rscriptinstalls the package salesforcer (and all dependencies) it can load R package XML since now libxml2.so.2 is installed from libxml2.

Yes, that worked!! Thank you so much! :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.