Skip to content

Commit 5694472

Browse files
fix: windows config location (#8)
1 parent a5a5ab2 commit 5694472

4 files changed

Lines changed: 58 additions & 11 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ This extension contributes the following settings:
8888

8989
* `goose.enable`: enable/disable this extension
9090

91+
## Configuration File Location
92+
93+
Goose's CLI and this extension look for a configuration file containing
94+
`GOOSE_PROVIDER` and `GOOSE_MODEL` values. The default locations are:
95+
96+
* **Linux/macOS:** `~/.config/goose/config.yaml`
97+
* **Windows:** `%APPDATA%\Block\goose\config\config.yaml` (e.g. `C:\Users\<you>\AppData\Roaming\Block\goose\config\config.yaml`)
98+
99+
Ensure this file exists and is populated with valid values before starting the extension.
100+
91101
----
92102

93103
## Support

docs/DEVELOPMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ For architectural details, see [ARCHITECTURE.md](./ARCHITECTURE.md).
88

99
1. Clone the repository
1010
2. Navigate to the project root directory
11-
3. Install dependencies: `npm install`
11+
3. Install dependencies: `npm install` (this installs devDependencies like `rimraf` used by build and test scripts)
1212
4. Install webview dependencies: `cd webview-ui && npm install && cd ..`
1313
5. Build the extension and webview: `npm run compile`
1414
6. Open the project root in VSCode: `code .`

src/test/unit/configReader.test.ts

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,12 @@ describe('ConfigReader Tests', () => {
183183
const pathUsed = readFileSpy.firstCall.args[0];
184184

185185
assert.ok(
186-
pathUsed.includes('AppData') &&
187-
pathUsed.includes('Roaming') &&
186+
pathUsed.includes('AppData') &&
187+
pathUsed.includes('Roaming') &&
188188
pathUsed.includes('Block') &&
189189
pathUsed.includes('goose') &&
190-
pathUsed.includes('config')
190+
pathUsed.includes('config') &&
191+
pathUsed.endsWith('config.yaml')
191192
);
192193

193194
// Restore environment
@@ -197,4 +198,43 @@ describe('ConfigReader Tests', () => {
197198
delete process.env.APPDATA;
198199
}
199200
});
201+
202+
it('should fallback to Roaming when APPDATA is undefined', () => {
203+
const readFileSpy = sinon.spy();
204+
205+
const mockWinOs: OS = {
206+
homedir: () => 'C:\\Users\\test',
207+
platform: () => 'win32'
208+
};
209+
210+
const mockWinFs: FileSystem = {
211+
existsSync: () => true,
212+
readFileSync: (path) => {
213+
readFileSpy(path);
214+
return 'GOOSE_PROVIDER: "databricks"\nGOOSE_MODEL: "claude-3-7-sonnet"';
215+
}
216+
};
217+
218+
// Ensure APPDATA is undefined
219+
const originalAppData = process.env.APPDATA;
220+
delete process.env.APPDATA;
221+
222+
readGooseConfig(mockWinFs, mockWinOs);
223+
224+
sinon.assert.calledOnce(readFileSpy);
225+
const pathUsed = readFileSpy.firstCall.args[0];
226+
227+
assert.ok(
228+
pathUsed.includes('AppData') &&
229+
pathUsed.includes('Roaming') &&
230+
pathUsed.includes('Block') &&
231+
pathUsed.includes('goose') &&
232+
pathUsed.includes('config') &&
233+
pathUsed.endsWith('config.yaml')
234+
);
235+
236+
if (originalAppData) {
237+
process.env.APPDATA = originalAppData;
238+
}
239+
});
200240
});

src/utils/configReader.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,10 @@ export function getConfigPath(os: OS = osDefault): string | null {
3838

3939
switch (os.platform()) {
4040
case 'win32':
41-
// Windows path: ~\AppData\Roaming\Block\goose\config\config.yaml
42-
const appData = process.env.APPDATA;
43-
if (!appData) {
44-
logger.error('Could not determine APPDATA directory on Windows.');
45-
return null; // Return null if APPDATA is not set
46-
}
47-
// Use appData instead of homeDir for the base path on Windows
41+
// Windows path: %APPDATA%\Block\goose\config\config.yaml
42+
// Fallback to the typical Roaming path if APPDATA is undefined
43+
const appData = process.env.APPDATA ||
44+
path.join(homeDir, 'AppData', 'Roaming');
4845
configPath = path.join(appData, 'Block', 'goose', 'config', 'config.yaml');
4946
break;
5047
case 'darwin': // macOS

0 commit comments

Comments
 (0)