Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False warning for missing (articles) images in README.md #2194

Closed
maelle opened this issue Sep 12, 2022 · 3 comments · Fixed by #2494
Closed

False warning for missing (articles) images in README.md #2194

maelle opened this issue Sep 12, 2022 · 3 comments · Fixed by #2494
Labels
bug an unexpected problem or unintended behavior home 🏠
Milestone

Comments

@maelle
Copy link
Collaborator

maelle commented Sep 12, 2022

For a README.Rmd with

knitr::include_graphics("vignettes/data_sources.png")

a first run of build_site() leads to

Warning message:
Missing images in 'README.md': 'articles/data_sources.png'pkgdown can only use images in 'man/figures' and 'vignettes' 

The image is then present. It is very close to #1980 so should the fix be an extension of 8b2f4d0 to vignettes/ images?

cc @mcguinlu

@maelle maelle added the bug an unexpected problem or unintended behavior label Sep 12, 2022
@maelle
Copy link
Collaborator Author

maelle commented Sep 12, 2022

@maelle maelle added this to the 2.1.0 milestone Oct 20, 2022
@slowkow
Copy link

slowkow commented Jun 24, 2023

I also want to report that I have observed different behavior for pkgdown::build_site() when I change only the location of the folder that contains my package.

When I am developing my package, the location of the folder with all my code is:

~/Dropbox/path with spaces/some long path/mypackage

When I run build_site():

  • I get the weird warnings about missing images (there are none, I checked each and every one).
  • The warning message contains an incorrect path that does not exist, and this path contains ../../../../... (To me, this indicates that there must be a bug in the code that tries to guess the parent folder of an image.)
  • One image — that is not missing — fails to appear in the vignette's html, and I inspected the <img> element to find out that it contains that erroneous ../../../../../.. path.

So, I decided to check what happens when I run this instead:

cp -r "~/Dropbox/path with spaces/some long path/mypackage" /tmp/
cd /tmp/mypackage
# now run pkgdown::build_site()

Now the result is different:

  • I still get the weird warnings about missing images.
  • The paths falsely reported as missing no longer contain ../../../../...
  • The image successfully appears in the vignette's html!

I hope this report helps you to gain more insight into the problem. Good luck!

If I have more time to debug this in the future, I'll try to share what I have learned.

@hadley
Copy link
Member

hadley commented Apr 16, 2024

Hmmmm, the problem is that build_home_index() is called before build_articles(), so the images are missing at the time the check is done. And we can't just replicate copy_figures() because there are no images to even copy yet.

So I think the best option is likely to move check_missing_images() to build_site_local() after both readme and articles have been built. Might be worth wrapping this in a new check_site() function where in the future we can add other code that can only be run after all pages are generated.

hadley added a commit that referenced this issue Apr 24, 2024
We can't know if the images in a readme exist until we have built the rest of the site. We worked around this a bit for images in `man/figures` but that strategy doesn't work for articles since we actually need to build them. So now we just check in a new step at the end of `build_site()`.

Fixes #2194
hadley added a commit that referenced this issue May 7, 2024
We can't know if the images in a readme exist until we have built the rest of the site. We worked around this a bit for images in `man/figures` but that strategy doesn't work for articles since we actually need to build them. So now we just check in a new step at the end of `build_site()`.

Fixes #2194
SebKrantz pushed a commit to SebKrantz/pkgdown that referenced this issue Jun 1, 2024
We can't know if the images in a readme exist until we have built the rest of the site. We worked around this a bit for images in `man/figures` but that strategy doesn't work for articles since we actually need to build them. So now we just check in a new step at the end of `build_site()`.

Fixes r-lib#2194
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior home 🏠
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants