You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
quarto: write-manifest and deploy should recommend rsconnect when using knitr engine #565
The rsconnect-python package does not understand R content or dependencies. It probably should complain when it is provided content using the knitr engine.
Have you seen the rsconnect R package? It is able to deploy Quarto content that uses R and (if needed) create manifests. https://rstudio.github.io/rsconnect/
changed the title [-]write-manifest doesn't work for command line Quarto[/-][+]quarto: write-manifest and deploy should recommend rsconnect when using knitr engine[/+]on Mar 26, 2024
@JT-39 - Could you share more about your project? I have just tried using write-manifest against a Quarto project that uses the knitr engine and receive an (expected) error:
rsconnect write-manifest quarto .#=> Checking arguments... [OK]#=> Inspecting Quarto project... [ERROR]#=> Error: The following Quarto engine(s) are not supported: knitr
A minimal reproducible example would be really helpful.
@JT-39 - Thanks for the additional context. What about your book project tells you that there are R package dependencies? Are you using executable code blocks?
The rsconnect R package should be correctly detecting any executable R code blocks and work from there. Alternatively, if you have an renv.lock, R packages and versions are extracted from there.
A couple of things to try:
First, update rsconnect and renv R packages to the latest CRAN releases. If you happen to be using an old version of either package, your project dependencies may not be detected.
install.packages(c("rsconnect","renv"))
Second, could you share what "engines" Quarto believes it is using? We care about the engines line from the inspect output.
Sorry @aronatkins, the R package dependencies were appearing in the manifest.json after running rsconnect::writeManifest(), however this was using an older version of {rsconnect} (pre 1.2.1 - but can't remember exact version). Since upgrading to newest version 1.2.1 these dependencies are no longer listed.
I think the "engines" are listed above, but it looks like its using "markdown".
I am happy with using rsconnect::writeManifest() to create the manifest.json file in R, but just wanted to see if it could be done on the command line as I am using vscode to do my Quarto project and its a small pain to start up and enter R each time from the command line.
@JT-39 Ah. Things are more clear now. Given that you don't have R dependencies, it is correct for the manifest to lack a listing of R packages. There was an issue using an earlier version of rsconnect where it incorrectly included R packages for all Quarto content. It's also fine to use either R or Python tools to produce that manifest, since you're not using either language.
From everything you've told me, the manifest produced from the rsconnect write-manifest command should accurately describe your content.
To restate: Because your Quarto project is only Markdown content (no R or Python executable code), you can use either:
# from Rrsconnect::writeManifest()
# from the terminal using rsconnect-python
rsconnect write-manifest quarto .
Unfortunately I am still having trouble with rsconnect write-manifest quarto . from the command line.
If I use this to create my manifest.json, then try to deploy I get this build error message (In the Get application type section):
Starting: Get application type
==============================================================================
Task : Python script
Description : Run a Python file or inline script
Version : 0.236.1
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/python-script
==============================================================================
"C:\Program Files\Python311\python.exe" E:\Agents\rsconnect-01\_work\16\s\posit-deploy\scripts\application_type.py
Traceback (most recent call last):
File "E:\Agents\rsconnect-01\_work\16\s\posit-deploy\scripts\application_type.py", line 52, in <module>
r_version = data["platform"]
~~~~^^^^^^^^^^^^
KeyError: 'platform'
##[error]The process 'C:\Program Files\Python311\python.exe' failed with exit code 1
Finishing: Get application type
@JT-39 - Could you also tell me more about the application_type.py script? That filename doesn't immediately look familiar. I'll look around more in the morning.
If that's custom code, I do not believe that it should require that platform be present in the manifest. That field communicates the R version and isn't included by rsconnect-python. The rsconnect R package always adds version to the manifest, but it won't be present in manifest generated by all tools.
Hi @aronatkins , apologies for the slow response, been a busy day before the bank holiday weekend.
I haven't had a chance to look any further yet, but I will do and it will likely be next week now if thats okay?
You are right though, I think it will actually be to do with something on my side with application_type.py. I didn't write the build pipeline, but will investigate. Thanks and have a nice weekend! :)
The platform is being used to identify the R version: r_version = data["platform"]
Which is then used to determine the deployment type (i.e., if not an R based deployment use the content type and directory path rather than the manifest.json and no directory path): deploy_type = content_type if r_version is None else "manifest"
Does this help/ anyway we can not use data["platform"] (I realise this is limited info, so if needed I can check with the owner and see if I can share more).
It sounds like your deployment tools are making some assumptions about the structure of the manifest and which fields are present for different types of content.
Make sure that folks understand that the R version is optional and may not appear for Python content, so maybe they want something like:
r_version=data.get("platform")
R content will also enumerate its set of package requirements:
r_packages=data.get("packages")
With those code snippets, you'll get None when the JSON data does not contain that field.
If a manifest.json is created for static content (an HTML upload) using rsconnect::writeManifest(), that manifest will indicate an R version because it was created by the R package. The content, however, does not require R. That may or may not be an important distinction in your environment.
In case it is helpful, Connect currently believes content requires R when the following holds:
When code similar to that function returns true, the R version is used to identify the target R installation. Note that these decisions have changed over time as new content types are added and may not be what is needed in your environment.
🤖 The original report turned out to be fine: the project used Quarto's markdown engine, so the manifest from rsconnect write-manifest quarto was correct, as discussed above. The remaining question of how rsconnect-python handles the knitr engine is tracked in #786, which proposes supporting knitr content directly. Closing as a duplicate of #786. If #786 doesn't cover your case, please reopen.
Activity
aronatkins commentedon Mar 26, 2024
The rsconnect-python package does not understand R content or dependencies. It probably should complain when it is provided content using the
knitrengine.Have you seen the
rsconnectR package? It is able to deploy Quarto content that uses R and (if needed) create manifests. https://rstudio.github.io/rsconnect/From the R console, you should be able to:
Assuming you are deploying to Posit Connect, the different deployment options are discussed in the Connect User Guide: https://docs.posit.co/connect/user/quarto/
Please let us know if this guidance doesn't work for your project.
[-]write-manifest doesn't work for command line Quarto[/-][+]quarto: write-manifest and deploy should recommend rsconnect when using knitr engine[/+]aronatkins commentedon Mar 26, 2024
@JT-39 - Could you share more about your project? I have just tried using
write-manifestagainst a Quarto project that uses theknitrengine and receive an (expected) error:A minimal reproducible example would be really helpful.
JT-39 commentedon Mar 27, 2024
Hi @aronatkins,
Sure. So this is a quarto book project. The manifest.json file doesn't works from using
rsconnect write-manifest quarto .Produces a manifest.json file like this:
The manifest.json file works from using
rsconnect::writeManifest()and looks like this:Let me know if you need any more info.
aronatkins commentedon Mar 27, 2024
@JT-39 - Thanks for the additional context. What about your book project tells you that there are R package dependencies? Are you using executable code blocks?
The
rsconnectR package should be correctly detecting any executable R code blocks and work from there. Alternatively, if you have anrenv.lock, R packages and versions are extracted from there.A couple of things to try:
First, update
rsconnectandrenvR packages to the latest CRAN releases. If you happen to be using an old version of either package, your project dependencies may not be detected.Second, could you share what "engines" Quarto believes it is using? We care about the
enginesline from the inspect output.JT-39 commentedon Mar 27, 2024
Sorry @aronatkins, the R package dependencies were appearing in the manifest.json after running
rsconnect::writeManifest(), however this was using an older version of {rsconnect} (pre 1.2.1 - but can't remember exact version). Since upgrading to newest version 1.2.1 these dependencies are no longer listed.I think the "engines" are listed above, but it looks like its using "markdown".
I am happy with using
rsconnect::writeManifest()to create the manifest.json file in R, but just wanted to see if it could be done on the command line as I am using vscode to do my Quarto project and its a small pain to start up and enter R each time from the command line.Thanks for continued support.
aronatkins commentedon Mar 27, 2024
@JT-39 Ah. Things are more clear now. Given that you don't have R dependencies, it is correct for the manifest to lack a listing of R packages. There was an issue using an earlier version of rsconnect where it incorrectly included R packages for all Quarto content. It's also fine to use either R or Python tools to produce that manifest, since you're not using either language.
From everything you've told me, the manifest produced from the
rsconnect write-manifestcommand should accurately describe your content.To restate: Because your Quarto project is only Markdown content (no R or Python executable code), you can use either:
aronatkins commentedon Mar 27, 2024
@JT-39 I'm going to close this for now, but please let me know if we've misunderstood what's happening with your project.
JT-39 commentedon Mar 27, 2024
Hi @aronatkins,
Unfortunately I am still having trouble with
rsconnect write-manifest quarto .from the command line.If I use this to create my manifest.json, then try to deploy I get this build error message (In the Get application type section):
I am using rsconnect-python version 1.22.0.
I can try and create a reprex tomorrow.
aronatkins commentedon Mar 27, 2024
@JT-39 - Could you also tell me more about the
application_type.pyscript? That filename doesn't immediately look familiar. I'll look around more in the morning.If that's custom code, I do not believe that it should require that
platformbe present in the manifest. That field communicates the R version and isn't included by rsconnect-python. The rsconnect R package always adds version to the manifest, but it won't be present in manifest generated by all tools.JT-39 commentedon Mar 28, 2024
Hi @aronatkins , apologies for the slow response, been a busy day before the bank holiday weekend.
I haven't had a chance to look any further yet, but I will do and it will likely be next week now if thats okay?
You are right though, I think it will actually be to do with something on my side with
application_type.py. I didn't write the build pipeline, but will investigate. Thanks and have a nice weekend! :)aronatkins commentedon Mar 28, 2024
@JT-39 - sounds good. I'll keep this open until next week and we can reevaluate once you learn more.
JT-39 commentedon Apr 2, 2024
@aronatkins, hope you had a nice weekend.
So I looked into the
application_type.pyfile.The
platformis being used to identify the R version:r_version = data["platform"]Which is then used to determine the deployment type (i.e., if not an R based deployment use the content type and directory path rather than the manifest.json and no directory path):
deploy_type = content_type if r_version is None else "manifest"Does this help/ anyway we can not use data["platform"] (I realise this is limited info, so if needed I can check with the owner and see if I can share more).
Thanks
Jake
aronatkins commentedon Apr 2, 2024
@JT-39 Welcome back. I envy your bank holidays.
It sounds like your deployment tools are making some assumptions about the structure of the manifest and which fields are present for different types of content.
Make sure that folks understand that the R version is optional and may not appear for Python content, so maybe they want something like:
R content will also enumerate its set of package requirements:
With those code snippets, you'll get
Nonewhen the JSON data does not contain that field.If a
manifest.jsonis created for static content (an HTML upload) usingrsconnect::writeManifest(), that manifest will indicate an R version because it was created by the R package. The content, however, does not require R. That may or may not be an important distinction in your environment.In case it is helpful, Connect currently believes content requires R when the following holds:
When code similar to that function returns true, the R version is used to identify the target R installation. Note that these decisions have changed over time as new content types are added and may not be what is needed in your environment.
Let us know if you've got additional questions.
JT-39 commentedon Apr 3, 2024
@aronatkins thanks for that detailed reply.
I think it is beginning to make sense... I have relayed this info to the developer of the pipeline and can report back what he says.
You can likely close this now if you like (if I am still able to comment any updates?).
Thanks for all your help :)
tdstein commentedon Nov 10, 2026
🤖 The original report turned out to be fine: the project used Quarto's
markdownengine, so the manifest fromrsconnect write-manifest quartowas correct, as discussed above. The remaining question of how rsconnect-python handles theknitrengine is tracked in #786, which proposes supportingknitrcontent directly. Closing as a duplicate of #786. If #786 doesn't cover your case, please reopen.