cloudfoundry / r-buildpack

Cloud Foundry buildpack for R
Apache License 2.0
9 stars 24 forks source link

Multiple Buildpack issue #4

Closed yavoan closed 6 years ago

yavoan commented 6 years ago

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version? cf-cli: 6.37 cf-api: 2.94.0

What version of the buildpack you are using? Running multiple buildpacks https://github.com/cloudfoundry/r-buildpack https://github.com/cloudfoundry/nodejs-buildpack#v1.6.3

If you were attempting to accomplish a task, what was it you were attempting to do? Attempting to run a R-script from node.

What did you expect to happen? Expected the script to execute as it does on my local machine. (From googling this error it seems its possible that where R is moved after installing and it can't find the binary, the location of the R script is correct; I know this because it works on my local machine)

What was the actual behavior? [ERR] Rscript execution error: No such file or directory

Please confirm where necessary:

I think the problem is that the R installation is being moved from /tmp/contents136751112/deps/0... to /home/vcap/deps/0... And Rscript is not able to be run when the installation and binary is moved. The paths are hardbaked in on installation unfortunately

cf-gitbot commented 6 years ago

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/158731606

The labels on this github issue will be updated when the story is started.

astrieanna commented 6 years ago

@yavoan Can you share how you're attempting to call the R-script? It sounds like you're using a static path when you need to use an environment variable (probably $DEPS_DIR).

yavoan commented 6 years ago

@astrieanna I was calling it with something like this const Rtask = child_process.spawn('Rscript', ['script.r', xdim, ydim, zdim, skuList, oids])

I ended up just building the R environment in a cflinuxfs2 docker instance (in /home/vcap/app), and then pushing the installation folder up to pivotal and setting environmental variables in the manifest. This solution was also a lot faster to deploy because the rbuildpack takes 10 minutes to install R and all the packages

jfeeny commented 6 years ago

@yavoan we're going to close this issue as it seems you've found a workaround - if you want us to dig deeper into the problem, feel free to reopen the issue with a sample app provided.

nathanweeks commented 11 months ago

This is still an issue with r-buildpack v1.2.6. strace seems to imply that R was built such that R_HOME = /usr/local/lib/R, though the R installation ends up in the deps directory:

vcap@host:~$ /tmp/lifecycle/shell
vcap@host:~$ type R
R is /home/vcap/deps/0/bin/R
vcap@host:~$ type Rscript
Rscript is /home/vcap/deps/0/bin/Rscript
vcap@host:~$ strace -f ./Rscript ~/app/app.R
...
execve("/usr/local/lib/R/bin/R", ["/usr/local/lib/R/bin/R", "--no-echo", "--no-restore", "--file=/home/vcap/app/app.R"], 0x7fff9b7233d0 /* 31 vars */) = -1 ENOENT (No such file or directory)
...
vcap@host:~$ ls /usr/local/lib/R/bin/R
ls: cannot access '/usr/local/lib/R/bin/R': No such file or directory

The R script itself is updated to handle relocation to the deps directory (I think in the code block below); however, Rscript (which is a binary) is not:

https://github.com/cloudfoundry/r-buildpack/blob/8f90d9cfdbdf0a7eadca9b95c27e4dbd9bf22caf/src/r/supply/supply.go#L133-L144

Absent a fix, it is worth at least a documentation update stating that Rscript is unsupported.