gtsave() error only for html files and only when you provide path

Created on 3 Mar 2020  路  6Comments  路  Source: rstudio/gt

This works fine for both...

## PNG
mtcars %>% gt() %>% gtsave(
  filename = 'mtcars_gtsave.png'
  # , path = 'assets'
  )
### HTML
mtcars %>% gt() %>% gtsave(
  filename = 'mtcars_gtsave.html'
  # , path = 'assets'
)

...but uncomment path args and the html file will fail to get written...

## PNG
mtcars %>% gt() %>% gtsave(
  filename = 'mtcars_gtsave.png'
  , path = 'assets'
  )
### HTML
mtcars %>% gt() %>% gtsave(
  filename = 'mtcars_gtsave.html'
  , path = 'assets'
)

Here is the error:

Error in base::file(file, open = "w+b") : cannot open the connection
In addition: Warning message:
In base::file(file, open = "w+b") :
  cannot open file 'assets/mtcars_gtsave.html': No such file or directory
[2] Intermediate [2] Medium 鈾笌 Critical 鈽癸笌 Bug

Most helpful comment

I have the same issue and I confirmed that my folder did indeed exist before running this, also when running the following instead of using path=output_folder:

coefs_tbl %>% gt() %>% gtsave(glue("{output_path}/table_lsdv.html"))

All 6 comments

Just a question: when you were trying this, did assets directory exist in your working directory? The reason I ask is because I don't believe gtsave() will create new directories for you. However, even if that's the case, I believe there should at least be an error message here stating as much. And that's on me.

I have the same issue and I confirmed that my folder did indeed exist before running this, also when running the following instead of using path=output_folder:

coefs_tbl %>% gt() %>% gtsave(glue("{output_path}/table_lsdv.html"))

This one should have the bug label @rich-iannone

I believe the bug is upstream here https://github.com/rstudio/htmltools/issues/165

@kendonB I agree! Will change the labels on this and fix soon.

Hello
I just installed the dev version from github and I still have the problem:

gtsave(filename = "02_tableau_1.html", path = "3-R-ACM")

Error in base::file(file, open = "w+b") : 
  impossible d'ouvrir la connexion
De plus : Warning message:
In base::file(file, open = "w+b") :
  impossible d'ouvrir le fichier '3-R-ACM/02_tableau_1.html' : No such file or directory

the folder 3-R_ACM exists in my Rproject. The error occurs both with a .R or a Rmdfile, whether it is stored in the root folder or in the target folder 3-R_ACM .

Thanks !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rich-iannone picture rich-iannone  路  4Comments

thisisnickb picture thisisnickb  路  5Comments

steveputman picture steveputman  路  3Comments

vikram-rawat picture vikram-rawat  路  3Comments

jestarr picture jestarr  路  3Comments