Installing without R available gives confusing error

Issue #593 resolved
Gijs Molenaar created an issue

This just bit me and it took me a while to figure out what was wrong. Probably better to print an error message.

This simple docker file:

FROM ubuntu:18.04
RUN apt-get update && apt-get install -y python3-pip
RUN pip3 install rpy2==3.2.0

gives the error:

TypeError: expected str, bytes or os.PathLike object, not NoneType

Full output:

Sending build context to Docker daemon  2.048kB
Step 1/3 : FROM ubuntu:18.04
 ---> a2a15febcdf3
Step 2/3 : RUN apt-get update && apt-get install -y python3-pip
 ---> Using cache
 ---> 5f2a47d50e9e
Step 3/3 : RUN pip3 install rpy2==3.2.0
 ---> Running in 1188299c3854
Collecting rpy2==3.2.0
  Downloading https://files.pythonhosted.org/packages/7e/e0/7da849bb6cf47466ceb28a75f930e61c311878882c275dfb4bbb4fdcc3cb/rpy2-3.2.0.tar.gz (161kB)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-whxj4k07/rpy2/setup.py", line 102, in <module>
        c_extension_status = get_r_c_extension_status()
      File "/tmp/pip-build-whxj4k07/rpy2/setup.py", line 91, in get_r_c_extension_status
        *situation.get_r_flags(r_home, '--ldflags')
      File "/tmp/pip-build-whxj4k07/rpy2/rpy2/situation.py", line 176, in get_r_flags
        allow_empty=False)))
      File "/tmp/pip-build-whxj4k07/rpy2/rpy2/situation.py", line 141, in _get_r_cmd_config
        r_exec = get_r_exec(r_home)
      File "/tmp/pip-build-whxj4k07/rpy2/rpy2/situation.py", line 130, in get_r_exec
        r_exec = os.path.join(r_home, 'bin', 'R')
      File "/usr/lib/python3.6/posixpath.py", line 80, in join
        a = os.fspath(a)
    TypeError: expected str, bytes or os.PathLike object, not NoneType

I’ll see if I can do a PR.

Comments (2)

  1. Gijs Molenaar reporter

    This seems already fixed in master:

    Error: rpy2 in API mode cannot be built without R in the PATH or R_HOME defined. Correct this or force ABI mode-only by defining the environment variable RPY2_CFFI_MODE=ABI
    

    thanks!

  2. Log in to comment