Can't install R in Heroku deployment
I'm trying to install the R buildpack for rpy2 for my website built with Django and React, but I keep getting an error on deployment and I have no clue what's going on. I've checked my buildpacks a billion times to make sure it is in the order of Apt, Python, and R, and I have Aptfiles, init.R, and runtime.txt in my root directory. This is the error message. Help very much appreciated!
Collecting rpy2~=3.5.16 (from -r requirements.txt (line 15))
remote: Downloading rpy2-3.5.17.tar.gz (220 kB)
remote: Installing build dependencies: started
remote: Installing build dependencies: finished with status 'done'
remote: Getting requirements to build wheel: started
remote: Getting requirements to build wheel: finished with status 'error'
remote: error: subprocess-exited-with-error
remote:
remote: × Getting requirements to build wheel did not run successfully.
remote: │ exit code: 1
remote: ╰─> [34 lines of output]
remote: Traceback (most recent call last):
remote: File "/app/.heroku/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
remote: main()
remote: File "/app/.heroku/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
remote: json_out['return_val'] = hook(**hook_input['kwargs'])
remote: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
remote: File "/app/.heroku/python/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
remote: return hook(config_settings)
remote: ^^^^^^^^^^^^^^^^^^^^^
remote: File "/tmp/pip-build-env-jhoy88xq/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 334, in get_requires_for_build_wheel
remote: return self._get_build_requires(config_settings, requirements=[])
remote: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
remote: File "/tmp/pip-build-env-jhoy88xq/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 304, in _get_build_requires
remote: self.run_setup()
remote: File "/tmp/pip-build-env-jhoy88xq/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 320, in run_setup
remote: exec(code, locals())
remote: File "<string>", line 141, in <module>
remote: File "<string>", line 110, in get_r_c_extension_status
remote: File "/tmp/pip-install-a760eb7i/rpy2_c86a8ea1d3504c00a4764017850c8b04/rpy2/situation.py", line 286, in get_r_flags
remote: _get_r_cmd_config(r_home, flags,
remote: File "/tmp/pip-install-a760eb7i/rpy2_c86a8ea1d3504c00a4764017850c8b04/rpy2/situation.py", line 246, in _get_r_cmd_config
remote: output = subprocess.check_output(
remote: ^^^^^^^^^^^^^^^^^^^^^^^^
remote: File "/app/.heroku/python/lib/python3.12/subprocess.py", line 466, in check_output
remote: return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
remote: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
remote: File "/app/.heroku/python/lib/python3.12/subprocess.py", line 548, in run
remote: with Popen(*popenargs, **kwargs) as process:
remote: ^^^^^^^^^^^^^^^^^^^^^^^^^^^
remote: File "/app/.heroku/python/lib/python3.12/subprocess.py", line 1026, in __init__
remote: self._execute_child(args, executable, preexec_fn, close_fds,
remote: File "/app/.heroku/python/lib/python3.12/subprocess.py", line 1955, in _execute_child
remote: raise child_exception_type(errno_num, err_msg, err_filename)
remote: FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/R/bin/R'`
remote: [end of output]
remote:
remote: note: This error originates from a subprocess, and is likely not a problem with pip.
remote: error: subprocess-exited-with-error
remote:
remote: × Getting requirements to build wheel did not run successfully.
remote: │ exit code: 1
remote: ╰─> See above for output.
remote:
remote: note: This error originates from a subprocess, and is likely not a problem with pip.
remote:
remote: ! Error: Unable to install dependencies using pip.
remote: !
remote: ! See the log output above for more information.
remote:
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to website-name.
remote:
To https://git.heroku.com/website-name.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/website-name.git'
I have tried clearing my cache and reinstalling the buildpacks. I have r-base in my Aptfile. I have the Python version in runtime.txt. I just need rpy2 to be installed.