yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.38k stars 872 forks source link

Symlinks are not honoured #982

Closed nr0cinu closed 8 years ago

nr0cinu commented 9 years ago

Hi!

Not sure if this is a knitr issue, so I hope that fits here.

Let’s say I have a Rmd file in one directory, and then a symlink to that file in a subdirectory:

$ ls
test.Rmd
a_dir/test.Rmd -> ../test.Rmd

If I then proceed to knit a_dir/test.Rmd the working directory is the base directory. If I just copy the Rmd file to the subdirectory the working directory is the subdirectory.

It also works with hardlinks, but I would really prefer to use symlinks.

Thanks! Bela

yihui commented 9 years ago

Sorry but I did not get it. What exactly was not working?

nr0cinu commented 9 years ago

Hi,

so:

this seems to happen if the files are named identical but in different folders. I observed this by using the RStudio Knit button as well as calling rmarkdown::render.

See demo below.

I hope that makes it clear.

Thanks again! Bela

Demo:

$ ls -l *
folder1:
total 4
-rw-r--r-- 1 bela bela 709 Apr  1 06:58 file.Rmd

folder2:
total 0
lrwxrwxrwx 1 bela bela 19 Apr  1 07:00 file.Rmd -> ../folder1/file.Rmd

$ R --slave -e "rmarkdown::render('folder1/file.Rmd')" 

processing file: file.Rmd
  |.............                                                    |  20%
  ordinary text without R code

  |..........................                                       |  40%
label: unnamed-chunk-1
  |.......................................                          |  60%
  ordinary text without R code

  |....................................................             |  80%
label: unnamed-chunk-2 (with options) 
List of 1
 $ echo: logi FALSE

  |.................................................................| 100%
  ordinary text without R code

output file: file.knit.md

/usr/bin/pandoc file.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output file.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /home/bela/.R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /tmp/RtmpUOzCtz/rmarkdown-str7793c45f4e2.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/home/bela/.R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/h/highlight 

Output created: file.html

$ ls -l *
folder1:
total 664
-rw-r--r-- 1 bela bela 675296 Apr  1 07:01 file.html
-rw-r--r-- 1 bela bela    709 Apr  1 06:58 file.Rmd

folder2:
total 0
lrwxrwxrwx 1 bela bela 19 Apr  1 07:00 file.Rmd -> ../folder1/file.Rmd

$ rm folder1/file.html 
removed ‘folder1/file.html’

$ R --slave -e "rmarkdown::render('folder2/file.Rmd')"

processing file: file.Rmd
  |.............                                                    |  20%
  ordinary text without R code

  |..........................                                       |  40%
label: unnamed-chunk-1
  |.......................................                          |  60%
  ordinary text without R code

  |....................................................             |  80%
label: unnamed-chunk-2 (with options) 
List of 1
 $ echo: logi FALSE

  |.................................................................| 100%
  ordinary text without R code

output file: file.knit.md

/usr/bin/pandoc file.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output file.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /home/bela/.R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/h/default.html --variable 'theme:bootstrap' --include-in-header /tmp/RtmpaA98jT/rmarkdown-str79060dfba77.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/home/bela/.R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/h/highlight 

Output created: file.html

$ ls -l *                                             
folder1:
total 664
-rw-r--r-- 1 bela bela 675296 Apr  1 07:01 file.html
-rw-r--r-- 1 bela bela    709 Apr  1 06:58 file.Rmd

folder2:
total 0
lrwxrwxrwx 1 bela bela 19 Apr  1 07:00 file.Rmd -> ../folder1/file.Rmd
yihui commented 8 years ago

I can reproduce it, but it appears to be an rmarkdown issue instead of knitr. knitr::knit() works fine. I guess rmarkdown::render() used normalizePath() somewhere and the symlink will be resolved.

github-actions[bot] commented 3 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.