CLI troubleshooting
When hakocms-cli doesn’t work as expected, use the message it shows to find the cause. Every message starts with error: and is written to standard error.
command not found is shown
Section titled “command not found is shown”Cause: The folder where you put hakocms-cli isn’t in your PATH.
Fix: Add that folder to your PATH, or move the file to a folder that’s in your PATH (such as /usr/local/bin) (Install the CLI). After changing PATH, open a new terminal.
macOS blocks it from running
Section titled “macOS blocks it from running”Cause: You extracted a file downloaded in a browser with Finder, so macOS marked it to block it from running. hakocms-cli isn’t signed by Apple.
How to check: Run xattr /usr/local/bin/hakocms-cli. If com.apple.quarantine is shown, the mark is set.
Fix: Remove the mark with the following command.
xattr -d com.apple.quarantine /usr/local/bin/hakocms-clino host to connect to is shown (exit code 4)
Section titled “no host to connect to is shown (exit code 4)”error: no host to connect to; run `hakocms-cli auth login --host <url>`Cause: No connection target is set. You haven’t logged in yet, or you haven’t set HAKOCMS_HOST in CI.
Fix: Log in with hakocms-cli auth login --host https://<hostname>.hakocms.net. In CI, set the environment variables HAKOCMS_HOST and HAKOCMS_TOKEN (Log in with the CLI).
invalid or expired access token is shown (exit code 4)
Section titled “invalid or expired access token is shown (exit code 4)”error: invalid or expired access token; run `hakocms-cli auth login --host https://<hostname>.hakocms.net`Cause: The access token has expired or been revoked. This also happens when you revoke it in [アクセストークン](Access tokens) in the admin, or when you log in again to the same connection target from another computer.
How to check: Check the token’s expiration with hakocms-cli auth status.
Fix: Log in again with hakocms-cli auth login. In CI, create a new token in the admin and replace the secret variable in CI.
The browser doesn’t open, or the code isn’t found
Section titled “The browser doesn’t open, or the code isn’t found”Cause: You’re running it somewhere without a browser, such as a machine you connected to over SSH. Or the confirmation code expired (10 minutes).
Fix: Run hakocms-cli auth login --host <URL> --no-browser, then open the URL shown in a browser on your own machine. If the admin shows “この文字のログインは見つかりません” (No login found for this code), run auth login again.
unknown host name is shown (exit code 2)
Section titled “unknown host name is shown (exit code 2)”error: unknown host name `test`; run `hakocms-cli auth status` to see the hostsCause: You passed a name to --host that you haven’t logged in to.
Fix: Check the names of the connection targets you’re logged in to with hakocms-cli auth status. You can also pass a URL instead of a name.
You get 403
Section titled “You get 403”error: you do not have permission to do this (HTTP 403)Cause: Your role in the space doesn’t allow that operation. hakocms-cli runs with the same permissions as you.
With an access token created with [読み取りだけ](Read only), commands other than reading return 403 as follows.
error: this access token can only read (HTTP 403)How to check: Check your role in the [ROLE] column of hakocms-cli spaces list. What each role can do is described in Invite members and choose roles.
Fix: If your role isn’t enough, ask an owner or administrator of the space to change your role. For a [読み取りだけ] token, create the token again with [すべて(あなたと同じ)](All (same as you)).
You get 404
Section titled “You get 404”error: not found (HTTP 404)Cause: The space, content type, or entry isn’t found. Spaces you aren’t a member of also return 404.
How to check: List them in order and check the names.
hakocms-cli spaces list # space slugshakocms-cli content-types list -s <slug> # content type IDs (ENDPOINT column)hakocms-cli entries list -s <slug> -t <content type ID>Fix: Pass the space slug to --space, and the content type ID ([エンドポイント](Endpoint) on screen) to --type. Not the display names (such as “ブログ” (Blog) or “記事” (Article)).
no space given is shown (exit code 2)
Section titled “no space given is shown (exit code 2)”error: no space given; pass --space <slug> or run `hakocms-cli spaces use <slug>`Cause: You didn’t pass --space and didn’t set one with spaces use. hakocms-cli doesn’t pick a space on its own.
Fix: Set one with hakocms-cli spaces use <slug>, or add --space <slug> to the command (Log in with the CLI).
needs –force when it cannot ask is shown in CI
Section titled “needs –force when it cannot ask is shown in CI”error: `schema apply` needs --force when it cannot ask (not a terminal, or --no-input)Cause: CI isn’t a terminal, so the CLI can’t ask for confirmation.
Fix: Add --force to operations such as deleting or applying. For heavy operations such as deleting a space or content type, add --confirm <name> (CLI output and exit codes).
You get 400 or 422 when passing values
Section titled “You get 400 or 422 when passing values”error: title: is required (HTTP 400)Cause: The shape of the value doesn’t match the field type. The ID of the mismatched field appears at the start of the message.
Fix: Check the value shapes you can write in Field types and value formats. Common mistakes are as follows.
| Mistake | Fix |
|---|---|
You put a URL string in an image field (image: must be an object with url) |
--set 'image={"url":"<URL>"}' |
You want to pass a numeric string (--set code=3 becomes a number) |
--set code='"3"' |
The JSON passed to --data has the wrong shape (Failed to deserialize the JSON body) |
Make the whole value { "<field ID>": value }. For a file, use --data @post.json |
On a Linux server, the token is stored in hosts.toml
Section titled “On a Linux server, the token is stored in hosts.toml”(no system keyring is available; /home/you/.config/hakocms-cli/hosts.toml is readable only by you)Cause: Linux without a desktop doesn’t have an OS credential store (Secret Service).
Fix: You can use it as is. hosts.toml is stored with permissions that only you can read. On a server that other people also use, it’s safer not to log in and instead pass the token only when needed with the environment variable HAKOCMS_TOKEN.
If you still can’t figure it out
Section titled “If you still can’t figure it out”Check how to use the command with --help (hakocms-cli entries update --help). Contact us through the Contact us, including the output of hakocms-cli version and the message shown. Don’t include your access token (the string starting with hako_pat_) in your inquiry.