I have a script called foo.R that includes another script other.R, which is in the same directory:
#!/usr/bin/env Rscript
message(\
I also had this problem, and none of the above solutions worked for me. Maybe with the source or things like that, but it was not clear enough.
I found this, for me elegant, solution:
paste0(gsub("\\", "/", fileSnapshot()$path, fixed=TRUE),"/")
The important thing in that is the fileSnapshot() that gives you a lot of information about a file. It returns a list of 8 elements. When you pick path as the list element, the path is returned with \\ as separator, so the rest of the code is just to change that.
I hope this helps.