Configuration/ Token isn't being detected in workspace + Home dir being created inside workspace

OS: MacOS Tahoe 26.2 (25C56)

After following the CLI Walkthrough, I setup my token. When I’m outside my workspace, the configuration is present:

pwd
/Users/ray/code
❯ exercism configure

You have configured the Exercism command-line client:

Config dir:                       ~/.config/exercism
Token:         (-t, --token)      ...
Workspace:     (-w, --workspace)  /Users/ray/code/exercism
API Base URL:  (-a, --api)        https://api.exercism.org/v1

However, when I’m inside the workspace, the configuration is missing.

pwd
/Users/ray/code/exercism
❯ exercism configure
Error: There is no token configured. Find your token on https://exercism.org/settings/api_cli, and call this command again with --token=<your-token>.

To fix this, on running exercism configure --token=YOUR_TOKEN, the home directory ~ was being incorrectly created inside my workspace.

Looking at the code, I discovered this happened because the path ~/.config/exercism was being treated as relative path instead of expanding ~ to home directory.

I added a fix and it worked locally. Will be happy to send a PR!

In your shell, do you have either of these environment variable set: EXERCISM_CONFIG_HOME or XDG_CONFIG_HOME ?

If yes, does it contain a literal tilde?

ref: cli/config/config.go at 47588cb78733d60cf45aa33c52790adff9d562a4 · exercism/cli · GitHub

Note that bash does not replace a tilde inside quotes:

$ foo=~/bin
$ declare -p foo
declare -- foo="/home/glennj/bin"

$ foo="~/bin"
$ declare -p foo
declare -- foo="~/bin"

I believe zsh works the same way.

2 Likes

In your shell, do you have either of these environment variable set: EXERCISM_CONFIG_HOME or XDG_CONFIG_HOME ?

Just checked. Yes, XDG_CONFIG_HOME contains ~/.config.

Wherever you define that, either take ~ out of the quotes, or use $HOME instead.

3 Likes

This fixed. Thank you!

1 Like