Repository navigation
ConfigService: process environment wins over .env - #48
Merged
Merged
Conversation
.env values were written over os.environ unconditionally, so the PORT=3000 that `nitrostack init` puts in .env overrode the PORT a host passes when starting the server. NitroStudio starts a second project on 3001; it bound 3000 anyway and died with "address already in use" (NITSTD-222). Keys already in the process environment are now kept, as with python-dotenv and Node's dotenv. .env still fills keys the process doesn't set, and defaults stay lowest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the root cause of NitroStudio NITSTD-222 (a second MCP started on 3001 binds 3000 and dies with "address already in use").
Cause:
ConfigService.__init__wrote every.envkey overos.environ, so thePORT=3000thatnitrostack initputs in.envoverrode thePORTa host passes at start-up.resolve_http_port()then returned 3000.Change: keys already in the process environment are kept, as with python-dotenv and Node's dotenv.
.envstill fills keys the process doesn't set; defaults stay lowest.Note: projects vendor the SDK (
vendor/nitrostack), so existing projects need their copy refreshed to get this.Testing
test_config_process_env_wins_over_env_file(.env PORT=3000+ envPORT=3001→ config andresolve_http_port()are 3001; file-only keys and defaults still apply) andtest_config_env_file_port_applies_when_process_has_none. The first fails without the change.pytest tests, dev extras)..env PORT=3000, started withPORT=3007: binds 127.0.0.1:3007 with this change, 127.0.0.1:3000 without.🤖 Generated with Claude Code