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

embed-resources: true fails with -o - #11068

Closed
kdheepak opened this issue Oct 15, 2024 · 12 comments · Fixed by #11071
Closed

embed-resources: true fails with -o - #11068

kdheepak opened this issue Oct 15, 2024 · 12 comments · Fixed by #11071
Assignees
Labels
bug Something isn't working
Milestone

Comments

@kdheepak
Copy link
Contributor

Bug description

Image

I get this error after the contents of the html output are printed to the terminal.

Steps to reproduce

Download this file:

https://github.com/kdheepak/kdheepak.github.io/blob/main/blog/the-egg-tower-puzzle/index.ipynb

Run quarto render index.ipynb --output -

Expected behavior

No response

Actual behavior

No response

Your environment

No response

Quarto check output

Quarto 1.5.38
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.2.0: OK
Dart Sass version 1.70.0: OK
Deno version 1.41.0: OK
Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK

@kdheepak kdheepak added the bug Something isn't working label Oct 15, 2024
@mcanouil
Copy link
Collaborator

Could you upgrade to a stable release?
You are using an old pre-release: https://github.com/quarto-dev/quarto-cli/releases/tag/v1.5.38

@mcanouil
Copy link
Collaborator

Note that I cannot reproduce at least on the development version:

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(\"hello world\")"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}

Image

@mcanouil mcanouil added the needs-repro Issues that are blocked until reporter provides an adequate reproduction label Oct 15, 2024
@kdheepak
Copy link
Contributor Author

kdheepak commented Oct 15, 2024

Thanks for the quick response and for checking.

Actually, I'm realizing it only happens with embed-resources: true.

format:
  html:
    embed-resources: true

Can you try adding the above to the same notebook?

{
  "cells": [
    {
      "cell_type": "raw",
      "metadata": {
        "vscode": {
          "languageId": "raw"
        }
      },
      "source": [
        "---\n",
        "title: The egg tower puzzle\n",
        "format:\n",
        "  html:\n",
        "    embed-resources: true\n",
        "---"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "print(\"hello world\")"
      ]
    }
  ],
  "metadata": {
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 2
}

@cscheid
Copy link
Collaborator

cscheid commented Oct 15, 2024

That latter .ipynb file appears to not be well-formed, or at least it's not doing here what you appear to be reporting:

$ quarto render issue-11068.ipynb --to html --execute
ERROR: TypeError: Cannot read properties of undefined (reading 'name')

@cscheid
Copy link
Collaborator

cscheid commented Oct 15, 2024

With a well-formed notebook that does the same thing, I still cannot repro:

{
 "cells": [
  {
   "cell_type": "raw",
   "id": "4ac0767a-170b-47cc-b84a-a8b7a4e43d9a",
   "metadata": {},
   "source": [
    "---\n",
    "format:\n",
    "  html:\n",
    "    embed-resources: true\n",
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "10db3539-d318-4837-ac73-8eedbc09f586",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello world\n"
     ]
    }
   ],
   "source": [
    "print(\"hello world\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.15"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
$ quarto render issue-11068-good.ipynb --to html --execute
Starting python3 kernel...Done

Executing 'issue-11068-good.ipynb'
  Cell 1/1: ''...Done

pandoc
  to: html
  output-file: issue-11068-good.html
  standalone: true
  embed-resources: true
  section-divs: true
  html-math-method: mathjax
  wrap: none
  default-image-extension: png

metadata
  document-css: false
  link-citations: true
  date-format: long
  lang: en

Output created: issue-11068-good.html

Note that the output has embed-resources: true.

@kdheepak
Copy link
Contributor Author

kdheepak commented Oct 15, 2024

hmm, I copy pasted your codeblock into my demo.ipynb and with the latest pre-release I'm still getting an error:

Image

Image

Image

@mcanouil
Copy link
Collaborator

Could you provide the full output of quarto check?

@cscheid
Copy link
Collaborator

cscheid commented Oct 15, 2024

Ah, sorry, this is on me.

@cscheid cscheid removed the needs-repro Issues that are blocked until reporter provides an adequate reproduction label Oct 15, 2024
@cscheid
Copy link
Collaborator

cscheid commented Oct 15, 2024

This is pretty simple - embed-resources: true is not compatible with writing to standard output, at least not right now.

@cscheid cscheid changed the title Running quarto render filename.ipynb --output - gives error embed-resources: true fails with -o - Oct 15, 2024
@cscheid cscheid self-assigned this Oct 15, 2024
@cscheid cscheid added this to the v1.6 milestone Oct 15, 2024
@cscheid
Copy link
Collaborator

cscheid commented Oct 15, 2024

The bug is here: https://github.com/quarto-dev/quarto-cli/blame/main/src/command/render/output.ts#L211

I'm a little surprised by it, because it's been there for 4 years, and there's a comment a few lines above explaining that we shouldn't remove the file precisely because it might be necessary.

@cscheid
Copy link
Collaborator

cscheid commented Oct 15, 2024

Thanks for the report! This is fixed now on main and a new 1.6 prerelease build is coming out momentarily.

@kdheepak
Copy link
Contributor Author

Thanks for the quick fix!

@mcanouil mcanouil modified the milestones: v1.6, Future Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants