Skip to content

Move all configuration to the global config dir #2079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

fnando
Copy link
Member

@fnando fnando commented Jul 18, 2025

What

Add change that will deprecate local config directories in p23. This also adds a config migration command stellar config migrate that moves over configs from local to global

Write operations (create/delete) are only done in global dir, while read operations (e.g. fetch alias) use both local (have priority, like in older versions) and global.
If local gets hit, it will print a warning.

Examples of running commands:
v23:

stellar keys ls
⚠️ Local config is deprecated and will be removed in the future
⚠️ To resolve this warning run 'stellar config migrate'
alice
alice-local
alice // Duplicated in global
alice-global
stellar network ls
⚠️ Local config is deprecated and will be removed in the future
⚠️ To resolve this warning run 'stellar config migrate'
nw-local
nw-global
local
futurenet
mainnet
testnet
ℹ️ Aliases available for network 'Test SDF Network ; September 2015'
⚠️ Local config is deprecated and will be removed in the future
⚠️ To resolve this warning run 'stellar config migrate'
contract-local: CDTVMKZEMHVAKI67N2TNV42VUH3AVUIQTSEGBYJEUEEMUSV3PIUHB4FM

ℹ️ Aliases available for network 'Test SDF Network ; September 2015'
contract-global: CAVUKMFLJNXZG2P33VBFUC6PKGJ3M5FGL5UXQWRYDE7QPX2CPJVHQVFV
stellar contract deploy --source-account alice-local --wasm ~/wasm/hello_world.wasm
⚠️ Local config is deprecated and will be removed in the future
⚠️ To resolve this warning run 'stellar config migrate'
ℹ️ Skipping install because wasm already installed
ℹ️ Using wasm hash 102431a5a5bc74bdb6bf2803c74080b67d070c522482c278a921563cb71ecc1a
⚠️ Local config is deprecated and will be removed in the future
⚠️ To resolve this warning run 'stellar config migrate'
ℹ️ Simulating deploy transaction…
ℹ️ Transaction hash is a6fb1265f2ead4d3b2e16db5e96caf88b25472ea8e1849a63091340f5e6804e4
🔗 https://stellar.expert/explorer/testnet/tx/a6fb1265f2ead4d3b2e16db5e96caf88b25472ea8e1849a63091340f5e6804e4
⚠️ Local config is deprecated and will be removed in the future
⚠️ To resolve this warning run 'stellar config migrate'
ℹ️ Signing transaction: a6fb1265f2ead4d3b2e16db5e96caf88b25472ea8e1849a63091340f5e6804e4
🌎 Submitting deploy transaction…
🔗 https://stellar.expert/explorer/testnet/contract/CBAFEDSL6LBKCWPXLZYZAMLXC37VB6ZZMHSSJBYOSGI7CMUOZIBIA4QV
✅ Deployed!
CBAFEDSL6LBKCWPXLZYZAMLXC37VB6ZZMHSSJBYOSGI7CMUOZIBIA4QV

No warning when using alice-global

stellar contract deploy --source-account alice-global --wasm ~/wasm/hello_world.wasm
ℹ️ Skipping install because wasm already installed
ℹ️ Using wasm hash 102431a5a5bc74bdb6bf2803c74080b67d070c522482c278a921563cb71ecc1a
ℹ️ Simulating deploy transaction…
ℹ️ Transaction hash is c6391b97df14ebfc43eba0027d9f8e992a8d5c4a007f3190071513782a99b0ce
🔗 https://stellar.expert/explorer/testnet/tx/c6391b97df14ebfc43eba0027d9f8e992a8d5c4a007f3190071513782a99b0ce
ℹ️ Signing transaction: c6391b97df14ebfc43eba0027d9f8e992a8d5c4a007f3190071513782a99b0ce
🌎 Submitting deploy transaction…
🔗 https://stellar.expert/explorer/testnet/contract/CDFRRKVETJK6F7ZFE762CX2CX4GYSUD2GCTYYQETJT3BU7EXSDFIBLS5
✅ Deployed!
CDFRRKVETJK6F7ZFE762CX2CX4GYSUD2GCTYYQETJT3BU7EXSDFIBLS5

User can migrate their configurations using stellar config migrate command. (This command takes care of all configs at once, but we might change it in the future)
This command will be available past protocol-23
Given local:

[~/projects/stellar-cli/.stellar]$ tree
.
├── contract-ids
│   ├── contract-duplicate.json
│   └── contract-local.json
├── identity
│   ├── alice-local.toml
│   └── alice.toml
└── network
    └── nw-local.toml

And global:

[~/.config/stellar]$ tree
.
├── config.toml
├── contract-ids
│   ├── contract-duplicate.json
│   └── contract-global.json
├── identity
│   ├── alice-global.toml
│   └── alice.toml
├── network
│   └── nw-global.toml
└── upgrade_check.json

We can run migration:

stellar config migrate
⚠️ Duplicated 'alice' identity found: it will be renamed to migrated_alice_bbc157d2
ℹ️ Moved identity from /home/ifro/projects/stellar-cli/.stellar/identity/alice.toml to /home/ifro/.config/stellar/identity/migrated_alice_bbc157d2.toml
ℹ️ Moved identity from /home/ifro/projects/stellar-cli/.stellar/identity/alice-local.toml to /home/ifro/.config/stellar/identity/alice-local.toml
ℹ️ Deleted fully migrated identity config directory /home/ifro/projects/stellar-cli/.stellar/identity
ℹ️ Moved network from /home/ifro/projects/stellar-cli/.stellar/network/nw-local.toml to /home/ifro/.config/stellar/network/nw-local.toml
ℹ️ Deleted fully migrated network config directory /home/ifro/projects/stellar-cli/.stellar/network
⚠️ Duplicated 'contract-duplicate' contract alias found: it will be renamed to migrated_contract-duplicate_b453a169
ℹ️ Moved contract alias from /home/ifro/projects/stellar-cli/.stellar/contract-ids/contract-duplicate.json to /home/ifro/.config/stellar/contract-ids/migrated_contract-duplicate_b453a169.json
ℹ️ Moved contract alias from /home/ifro/projects/stellar-cli/.stellar/contract-ids/contract-local.json to /home/ifro/.config/stellar/contract-ids/contract-local.json
ℹ️ Deleted fully migrated contract alias config directory /home/ifro/projects/stellar-cli/.stellar/contract-ids
ℹ️ Deleted fully migrated local config directory /home/ifro/projects/stellar-cli/.stellar

As the result, local config will be deleted and global will look like:

.
├── config.toml
├── contract-ids
│   ├── contract-duplicate.json
│   ├── contract-global.json
│   ├── contract-local.json
│   └── migrated_contract-duplicate_b453a169.json
├── identity
│   ├── alice-global.toml
│   ├── alice-local.toml
│   ├── alice.toml
│   └── migrated_alice_bbc157d2.toml
├── network
│   ├── nw-global.toml
│   └── nw-local.toml
└── upgrade_check.json

All duplicated files have prefix (unique to original path) to avoid accidental overriding when migrating multiple local configs (e.g. if there are multiple alice keys, one per project) -- user can rename those files later based.
Running it again will simply print that no migration is needed

stellar config migrate
✅ Config is already fully migrated

In addition, --config-dir allows to change config directory from global:

stellar keys ls --config-dir /tmp/custom-stellar
bob
stellar contract deploy --source-account bob --wasm ~/wasm/hello_world.wasm --config-dir /tmp/custom-stellar
ℹ️ Skipping install because wasm already installed
ℹ️ Using wasm hash 102431a5a5bc74bdb6bf2803c74080b67d070c522482c278a921563cb71ecc1a
ℹ️ Simulating deploy transaction…
ℹ️ Transaction hash is 3666b77f34da505ef5bda934fd98903335bde7f5a0f8d774eee88b5eadbcf1d4
🔗 https://stellar.expert/explorer/testnet/tx/3666b77f34da505ef5bda934fd98903335bde7f5a0f8d774eee88b5eadbcf1d4
ℹ️ Signing transaction: 3666b77f34da505ef5bda934fd98903335bde7f5a0f8d774eee88b5eadbcf1d4
🌎 Submitting deploy transaction…
🔗 https://stellar.expert/explorer/testnet/contract/CBT5QTT6R6WMX7NBIPHPQOO5ICF5GDM6KFCHFYP6MWHKKRTG5IX5KWB7
✅ Deployed!
CBT5QTT6R6WMX7NBIPHPQOO5ICF5GDM6KFCHFYP6MWHKKRTG5IX5KWB7
tree /tmp/custom-stellar/
/tmp/custom-stellar/
└── identity
    └── bob.toml

Finally, passing --global flag emits warning:

stellar contract deploy --source-account alice-global --wasm ~/wasm/hello_world.wasm --global --alias test
ℹ️ Skipping install because wasm already installed
ℹ️ Using wasm hash 102431a5a5bc74bdb6bf2803c74080b67d070c522482c278a921563cb71ecc1a
ℹ️ Simulating deploy transaction…
ℹ️ Transaction hash is a5b493f11999479d04c96c59f583ee93895b1a22b831cd460e424b99995d4137
🔗 https://stellar.expert/explorer/testnet/tx/a5b493f11999479d04c96c59f583ee93895b1a22b831cd460e424b99995d4137
ℹ️ Signing transaction: a5b493f11999479d04c96c59f583ee93895b1a22b831cd460e424b99995d4137
🌎 Submitting deploy transaction…
🔗 https://stellar.expert/explorer/testnet/contract/CDX2JS2A4KPZMXSVYV75W3X52NSQNC5QBHI3GJZXOGZGECFCENOQI6JN
✅ Deployed!
⚠️ Flag --global is deprecated: global config is always used
CDX2JS2A4KPZMXSVYV75W3X52NSQNC5QBHI3GJZXOGZGECFCENOQI6JN

Why

#1993

Known limitations

Warnings can not be muted with -q flag
Sometimes warnings are printed multiple times (e.g. contract deploy)

@fnando fnando force-pushed the global-config-dir branch from 6912b5d to bfcb357 Compare July 18, 2025 06:14
@fnando fnando changed the title Global config dir Move all configuration to the global config dir Jul 18, 2025
@leighmcculloch
Copy link
Member

leighmcculloch commented Jul 18, 2025

💯 So awesome we're doing this now.

As a user reading the output messages indicating that there's a local config present that needs migrating, I'd benefit from understanding what's in the local config. If it's too difficult to identify what's in the config, maybe:

⚠️ A local config was found at path "./.stellar/". Local config is deprecated and will not be loaded in the future. Configs now live only in the global config stored at "...". Run 'stellar config migrate' to migrate the local config into the global config.

@fnando
Copy link
Member Author

fnando commented Jul 18, 2025

@leighmcculloch ended up going with this:

$ stellar keys address me
⚠️ A local config was found at ".stellar".
   This behavior is deprecated and will be removed in the future.
   Run `stellar config migrate` to move the configuration to "/Users/fnando/.config/stellar".

@fnando fnando self-assigned this Jul 18, 2025
@fnando fnando moved this from Backlog (Not Ready) to In Progress in DevX Jul 18, 2025
@fnando fnando marked this pull request as ready for review July 18, 2025 16:08
@fnando fnando moved this from In Progress to Needs Review in DevX Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Review
Development

Successfully merging this pull request may close these issues.

3 participants