spinframework / spinframework/spin

Provide a way to script finding where Spin keeps data

Open
#2,959 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
6.5k
Forks
310
Avg merge
1d 20h
Merged PRs (30d)
24

Description

From #2555. The context is bundling as part of a third party installer and still making sure that everything is set up nicely (and in isolation!).

Where does spin store the plugins and templates

Ideally I wouldn't need to know, but since I can't use the cli to query if templates and plugins have been installed or not, I needed to check the filesystem.

I could not find a way to find the directory from the command itself, like I can do with e.g. docker:

$ docker info -f json | jq -r .DockerRootDir
/var/lib/docker

It would be nice to have a similar spin info subcommand that provides the data directory location, e.g.

$ spin info --json | jq -r .SpinAppData
/Users/jan/Library/Application Support/spin

The rules for locating the data directory are complex

Since I can't query the spin app data location, I have to hard-code the rules from the spin app into the installer:

Linux: $HOME/.local/share/spin
macOS: $HOME/Application Support/spin
Windows: %LOCALAPPDATA%\spin

Unfortunately it gets more complicated: On Linux it will be $XDG_DATA_HOME/spin if XDG_DATA_HOME is defined. https://github.com/fermyon/spin/pull/1494 makes the location dependent on installation by Homebrew, and https://github.com/fermyon/spin/issues/641 promises to make things even more complex.

I think replicating all these rules in a 3rd-party installer is bad, but it gets even worse when you consider GUI applications. They are not started from the user's shell, but e.g. on macOS from launchd on behalf of Finder.app. Those apps don't inherit the user's shell environment variables. You could try to look up the default shell for the user from /etc/passwd and then run a login shell as a subprocess to query the environment variables, but this is getting just too convoluted, and is still not guaranteed to be correct 100% of the time either.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how the Spin CLI currently locates its app-data directory and how subcommands expose information. Compare the platform and environment-variable rules described in the issue, then define completion as a queryable info command that reports the effective data directory for the current installation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.