posit-dev / publisher

MIT License
5 stars 0 forks source link

Run "init" if config file can't be found #405

Closed mmarchetti closed 11 months ago

mmarchetti commented 11 months ago

When publishing a directory that doesn't contain a config file, the CLI advises to use the publish init command. That's confusing because publish is the command to publish. It should recommend running the client's init command without the word publish.

Logs:

bin/darwin/arm64/connect-client-0.0.dev2-232-g2e06533e-darwin-arm64 publish test/sample-content/fastapi-simple/
time=2023-11-29T10:57:30.947-05:00 level=INFO msg="Client version" version=0.0.dev2-232-g2e06533e
time=2023-11-29T10:57:30.947-05:00 level=INFO msg="Development mode" mode=dev
time=2023-11-29T10:57:30.947-05:00 level=INFO msg="Development build" DevelopmentBuild=true
time=2023-11-29T10:57:30.948-05:00 level=INFO msg="Loading rsconnect accounts" path=/Users/kgartland/Library/Preferences/org.R-project.R/R/rsconnect
time=2023-11-29T10:57:30.950-05:00 level=INFO msg="Loading rsconnect-python accounts" path="/Users/kgartland/Library/Application Support/rsconnect-python/servers.json"
time=2023-11-29T10:57:30.950-05:00 level=ERROR msg="Error running command" error="couldn't load configuration 'default' from 'test/sample-content/fastapi-simple/'; run 'publish init' to create an initial configuration file"

 couldn't load configuration 'default' from 'test/sample-content/fastapi-simple/'; run 'publish init' to create an initial configuration file

Running publish init says:

> bin/darwin/arm64/connect-client-0.0.dev2-232-g2e06533e-darwin-arm64 publish init
time=2023-11-29T10:58:19.941-05:00 level=INFO msg="Client version" version=0.0.dev2-232-g2e06533e
time=2023-11-29T10:58:19.941-05:00 level=INFO msg="Development mode" mode=dev
time=2023-11-29T10:58:19.941-05:00 level=INFO msg="Development build" DevelopmentBuild=true
time=2023-11-29T10:58:19.942-05:00 level=INFO msg="Loading rsconnect accounts" path=/Users/kgartland/Library/Preferences/org.R-project.R/R/rsconnect
time=2023-11-29T10:58:19.943-05:00 level=INFO msg="Loading rsconnect-python accounts" path="/Users/kgartland/Library/Application Support/rsconnect-python/servers.json"
time=2023-11-29T10:58:19.943-05:00 level=ERROR msg="Error running command" error="couldn't load configuration 'default' from 'init'; run 'publish init' to create an initial configuration file"

 couldn't load configuration 'default' from 'init'; run 'publish init' to create an initial configuration file

Originally posted by @kgartland-rstudio in https://github.com/rstudio/publishing-client/issues/402#issuecomment-1832192979

mmarchetti commented 11 months ago

After some discussion, we are leaning toward running init automatically if there's no config file present when publish or publish-ui are invoked.

tdstein commented 11 months ago

Should the init command be top-level? i.e., bin/darwin/arm64/connect-client-0.0.dev2-232-g2e06533e-darwin-arm64 init?

kgartland-rstudio commented 11 months ago

Should the init command be top-level? i.e., bin/darwin/arm64/connect-client-0.0.dev2-232-g2e06533e-darwin-arm64 init?

It is, but if you don't have a toml file the error you get reads:

 ... run 'publish init' to create an initial configuration

so the error text just needs to be updated