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

Knitr imgur upload fails sporadically during reprex generation #1828

Closed
atakanekiz opened this issue Apr 4, 2020 · 3 comments
Closed

Knitr imgur upload fails sporadically during reprex generation #1828

atakanekiz opened this issue Apr 4, 2020 · 3 comments
Labels
question Questions (which should belong to forums instead of Github)

Comments

@atakanekiz
Copy link

atakanekiz commented Apr 4, 2020

Hello,

I have seen two previous posts about an issue that sounded similar #1495, #1436, #1514 and tidyverse/reprex#168, but I think my problem is different.

I'm trying to generate a reprex that includes plots and I get Bad Request (HTTP 400) error. Interestingly, this problem starts happening if I generate multiple reprexes in a short span of time, and then, it seems to go away again.

This chunk does not fail

library(ggplot2)


p <- ggplot(iris) +
    geom_point(aes(x=Sepal.Width, y=Sepal.Length))

###### p

However, this one fails

library(ggplot2)


p <- ggplot(iris) +
    geom_point(aes(x=Sepal.Width, y=Sepal.Length))

p

The error stack looks like this:

 Stack trace:

 Process 14288:
 1. reprex::reprex()
 2. reprex:::reprex_render(r_file, std_file)
 3. callr::r_safe(function(input) { ...
 4. callr:::get_result(output = out, options)
 5. throw(newerr, parent = remerr[[2]])

 x callr subprocess failed: Bad Request (HTTP 400). Failed to upload to imgur. 

 Process 14768:
 17. (function (input)  ...
 18. rmarkdown::render(input, quiet = TRUE, envir = globalenv())
 19. knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
 20. knitr:::process_file(text, output)
 21. base:::withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),  ...
 22. knitr:::process_group(group)
 23. knitr:::process_group.block(group)
 24. knitr:::call_block(x)
 25. knitr:::block_exec(params)
 26. base:::unlist(wrap(res, options))
 27. knitr:::wrap(res, options)
 28. knitr:::wrap.list(res, options)
 29. base:::lapply(x, wrap, options)
 30. knitr:::FUN(X[[i]], ...)
 31. knitr:::wrap.recordedplot(X[[i]], ...)
 32. knitr:::in_base_dir(run_hook_plot(files[[1]], reduce_plot_opts(options)))
 33. knitr:::in_dir(d, expr)
 34. knitr:::run_hook_plot(files[[1]], reduce_plot_opts(options))
 35. knitr:::hook(x, options)
 36. knitr:::hook_plot_md_base(x, options)
 37. base:::sprintf("![%s](%s%s)", cap, base, .upload.url(x))
 38. knitr:::.upload.url(x)
 39. (opts_knit$get("upload.fun"))(x)
 40. httr::stop_for_status(resp, "upload to imgur")
 41. base:::stop(http_condition(x, "error", task = task, call = call))
 42. (function (e)  ...

 x Bad Request (HTTP 400). Failed to upload to imgur. 

I tried

  • Reinstalling xml2, httr, knitr (from github development branch), reprex
  • Restarting the R session, computer
  • Turn lights off and on, and do happy feet dance. Didn't help at all...

Side note: When I was working on generating a reprex for this post, after failing a couple of times, the plot-containing reprex went through and generated an output. Weird...

I'd appreciate any input.

Best,
Atakan

SessionInfo

> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.3.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3        pillar_1.4.3      compiler_3.6.2    prettyunits_1.1.1 remotes_2.1.1     tools_3.6.2       testthat_2.3.2   
 [8] digest_0.6.25     pkgbuild_1.0.6    pkgload_1.0.2     tibble_2.1.3      lifecycle_0.2.0   gtable_0.3.0      memoise_1.1.0    
[15] evaluate_0.14     pkgconfig_2.0.3   rlang_0.4.5       reprex_0.3.0      cli_2.0.2         rstudioapi_0.11   curl_4.3         
[22] xfun_0.12         dplyr_0.8.4       withr_2.1.2       knitr_1.28.2      desc_1.2.0        fs_1.3.2          devtools_2.2.2   
[29] tidyselect_1.0.0  grid_3.6.2        rprojroot_1.3-2   glue_1.4.0        R6_2.4.1          processx_3.4.2    fansi_0.4.1      
[36] rmarkdown_2.1     sessioninfo_1.1.1 farver_2.0.3      purrr_0.3.3       callr_3.4.2       clipr_0.7.0       magrittr_1.5     
[43] whisker_0.4       scales_1.1.0      backports_1.1.5   ps_1.3.2          ellipsis_0.3.0    htmltools_0.4.0   usethis_1.5.1    
[50] assertthat_0.2.1  colorspace_1.4-1  labeling_0.3      munsell_0.5.0     crayon_1.3.4     
@atakanekiz atakanekiz changed the title Knitr imgur upload fails during reprex generation Knitr imgur upload fails sporadically during reprex generation Apr 4, 2020
@yihui
Copy link
Owner

yihui commented Jun 3, 2020

Thanks for patiently trying everything (including turning on/off lights and dancing)! Unfortunately I don't have an idea here. I tried a few times and wasn't able to reproduce the issue once. Sorry.

@cderv
Copy link
Collaborator

cderv commented Jan 29, 2021

@atakanekiz is this still happening regularly ?

I can't reproduce either.

@cderv cderv added the question Questions (which should belong to forums instead of Github) label Jan 29, 2021
@yihui yihui closed this as completed Mar 24, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Questions (which should belong to forums instead of Github)
Projects
None yet
Development

No branches or pull requests

3 participants