Skip to content

MyCoder is not recognizing my config file #397

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
F-Educere opened this issue May 4, 2025 · 2 comments
Open

MyCoder is not recognizing my config file #397

F-Educere opened this issue May 4, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@F-Educere
Copy link

F-Educere commented May 4, 2025

I created a configuration file like this in ~/.config/mycoder, however, it keeps pointing out a configuration error to consume the anthropic api, even though I didn't define the usage as being this:

`
// mycoder.config.js
export default {
// GitHub integration
githubMode: true,

// Browser settings
headless: true,
userSession: false,

// System browser detection settings
browser: {
// Whether to use system browsers or Playwright's bundled browsers
useSystemBrowsers: true,

// Preferred browser type (chromium, firefox, webkit)
preferredType: 'chromium',

// Custom browser executable path (overrides automatic detection)
// executablePath: null, // e.g., '/path/to/chrome'

},

// Model settings
provider: 'openai',
model: 'deepseek-r1:7b',
maxTokens: 4096,
temperature: 0.7,

// Custom settings
// customPrompt can be a string or an array of strings for multiple lines
customPrompt: '',
// Example of multiple line custom prompts:
// customPrompt: [
// 'Custom instruction line 1',
// 'Custom instruction line 2',
// 'Custom instruction line 3',
// ],
profile: false,

// Base URL configuration (for providers that need it)
baseUrl: 'https://ollama.sv3.cloud.atla.pro/ollama', // Example for Ollama

// MCP configuration
mcp: {
servers: [
{
name: 'example',
url: 'https://mcp.example.com',
auth: {
type: 'bearer',
token: 'your-token-here',
},
},
],
defaultResources: ['example://docs/api'],
defaultTools: ['example://tools/search'],
},
};
`

when executing the command:

mycoder "Implement a React component that displays a list of items"

I get the following error:
`[Sentry] You are using Node.js in ESM mode ("import syntax"). The Sentry Node.js SDK is not compatible with ESM in Node.js versions before 18.19.0 or before 20.6.0. Please either build your application with CommonJS ("require() syntax"), or upgrade your Node.js version.
Detected 2 browsers on the system
Available browsers:

  • Chrome (chromium) at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
  • Firefox (firefox) at /Applications/Firefox.app/Contents/MacOS/firefox
    GitHub mode is enabled but there are issues with git/gh CLI tools:
  • GitHub CLI is not available. Please install gh CLI.
    GitHub mode requires git and gh CLI tools to be installed.
    Please install the missing tools or disable GitHub mode with --githubMode false

An error occurred:
Error: Error calling Anthropic API: 401 {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}
Error: Error calling Anthropic API: 401 {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}
at AnthropicProvider.generateText (file:///Users/saviocamacam/.nvm/versions/node/v18.17.1/lib/node_modules/mycoder/node_modules/mycoder-agent/src/core/llm/providers/anthropic.ts:184:13)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at toolAgent (file:///Users/saviocamacam/.nvm/versions/node/v18.17.1/lib/node_modules/mycoder/node_modules/mycoder-agent/src/core/toolAgent/toolAgentCore.ts:142:45)
at executePrompt (file:///Users/saviocamacam/.nvm/versions/node/v18.17.1/lib/node_modules/mycoder/src/commands/$default.ts:187:20)
at Object.handler (file:///Users/saviocamacam/.nvm/versions/node/v18.17.1/lib/node_modules/mycoder/src/commands/$default.ts:280:5)
0
[Token Usage Total] Root: input: 0 cache-writes: 0 cache-reads: 0 output: 0 COST: $0.00
Forcing exit after 5000ms timeout`

@bhouston
Copy link
Member

bhouston commented May 4, 2025

Issue Triage Analysis

Thank you for reporting this issue with MyCoder's configuration handling. I've investigated the problem and found the likely cause of the error you're experiencing.

Issue Classification

  • Type: Bug
  • Labels: bug, configuration

Root Cause Analysis

The issue appears to be related to the configuration file format and how environment variables are handled. Here's what's happening:

  1. Your configuration file correctly specifies provider: 'openai' and model: 'deepseek-r1:7b'
  2. However, MyCoder is still trying to use the Anthropic API, as evidenced by the error message: Error calling Anthropic API: 401 {"type":"error","error":{"type":"authentication_error","message":"invalid x-api-key"}}

The problem is likely caused by one of these factors:

  1. Configuration File Format: Your configuration file is using ESM format (export default {...}), but you're placing it in ~/.config/mycoder. According to the documentation, the file should be named config.js (not mycoder.config.js) when placed in this directory.

  2. Default Provider Override: Even though you're specifying OpenAI as the provider, the default provider in MyCoder is Anthropic. If your configuration isn't being loaded correctly, it falls back to using Anthropic.

  3. Missing Environment Variable: The code shows that MyCoder checks for the ANTHROPIC_API_KEY environment variable even when another provider is specified, before it fully initializes the actual provider you've chosen.

Recommended Solutions

Try these solutions in order:

  1. Rename your configuration file: Change ~/.config/mycoder/mycoder.config.js to ~/.config/mycoder/config.js

  2. Use CommonJS format: If you're using Node.js before 18.19.0 or 20.6.0, modify your config file to use CommonJS format:

    // ~/.config/mycoder/config.js
    module.exports = {
      // Your configuration here
      provider: 'openai',
      model: 'deepseek-r1:7b',
      // ...other settings
    };
  3. Specify provider directly in command: As a workaround, you can override the provider directly in the command:

    mycoder --provider openai "Implement a React component that displays a list of items"
    
  4. Set base URL for OpenAI-compatible API: If you're using a local model or API that's OpenAI-compatible, make sure to set the baseUrl parameter correctly:

    provider: 'openai',
    model: 'deepseek-r1:7b',
    baseUrl: 'https://your-api-endpoint.com/v1',

Additional Information

The error message also indicates:

  1. GitHub mode is enabled but GitHub CLI (gh) is not installed
  2. There's a Sentry SDK compatibility issue with ESM in Node.js

Please let us know if any of these solutions work for you or if you need further assistance.

@F-Educere
Copy link
Author

F-Educere commented May 4, 2025

Thanks for the support and for responding so quickly, but even after renaming the configuration file to the one suggested above, the error ANTHROPIC_API_KEY environment variable is not set occurs. This error does not only occur when I pass the parameters in the command. I have been trying to avoid using the official Anthropic and OpenAI APIs, but I wanted to use my Ollama server that is exposed on the internet at https://ollama.sv3.cloud.atla.pro/ollama, with an API Key for authentication, is that possible?

Image

I tried using a local proxy solution

Image

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants