1

I have a bash script that calls on R, and is mapped to a keyboard shortcut in my i3 config, like this:

bindsym $mod+q exec --no-startup-id test-r-not-working-from-within.sh

Here is a simple example that is easily verifiable, as it creates a file in /tmp/ with the ending '.testR' when the R session is successfully executed, and it also creates a file called test.testshell in /tmp/.

The script does run, as one can verify by the file created as /tmp/test.testshell, but the R session script that is supposed to run is not executed. When running the script from a terminal, however, the R session IS executed along with the shell commands.

#!/bin/bash

tmp1=$(mktemp)

echo '
library(data.table)


# troubleshoot 
  tmp1 <- tempfile(tmpdir="/tmp", fileext=".testR")
  fileConn<-file(tmp1)
  writeLines("test this is a test", fileConn)
  close(fileConn)
' >> $tmp1


# none of these two ways of doing it works when called from i3
R  < $tmp1 --vanilla
Rscript $tmp1 --vanilla




echo 'test.testshell' > /tmp/test.testshell


notify-send "test-r-not-working-from-within.sh" 



I was thinking it might be something with the $PATH, however, running gives:

which R

gives:

/usr/bin/R

So it should be in the PATH, right? Adding it manually to the PATH in my .bashrc profile does not do anything either, though:

export PATH="/usr/bin/R:~/.npm-global/bin:/usr/local/stata17:$HOME/.yarn/bin:$HOME/.cargo/bin:/home/emil/bin:/home/emil/.local/bin:$PATH"

I don't get it. Any ideas?

I'm on Manjaro Linux, fully updated.

emilBeBri
  • 121
  • 1
  • 7

0 Answers0