Skip to content

Setting LD_LIBRARY_PATH may break valid Python environments #1860

@mschubert

Description

@mschubert

I'm trying to use a conda environment with reticulate.

With use_python("~/.conda/envs/scanpy/bin/python", required=TRUE) I'm getting:

sh: symbol lookup error: sh: undefined symbol: rl_full_quoting_desired
Error in system2(command = python, args = shQuote(script), stdout = TRUE,  :
  error in running command '~/.conda/envs/scanpy/bin/python'

This is due to the autosetup of LD_LIBRARY_PATH, adding ~/.conda/envs/scanpy/lib. This path contains libreadline.so without rl_full_quoting_desired, which gets preferred over my system libreadline.so that has this. My system shell gets invoked with the wrong libreadline, so I get this error.

The code path is the following:

  • use_python
  • python_config
  • python_config_impl:
    config <- tryCatch(system2(command = python, args = shQuote(script),
        stdout = TRUE, stderr = FALSE), error = function(e) {
        e$message <- paste(e$message, shQuote(python))
        stop(e)
    })

Note that this fails with the shell invocation, before starting python. The minimal example to reproduce this issue on my system is running LD_LIBRARY_PATH=~/.conda/envs/scanpy/lib sh.

My conda environment's python executable runs fine without additional setup by setting RPATH/RUNPATH rather than LD_LIBRARY_PATH. If I'm not mistaken, so does every conda installation (and bash modules) in the meantime and setting LD_LIBRARY_PATH is explicitly discouraged.

Would it be possible to provide an environment variable (e.g. RETICULATE_NO_SETUP_LD_PATH) to disable the automatic discovery of the library path? if setting LD_LIBRARY_PATH is still required for other use cases

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions