Skip to content

chore: Resolve DATA_CACHE_DIR in .env.development #306

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

Merged
merged 1 commit into from
May 12, 2025

Conversation

brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented May 12, 2025

This PR adds a default value for the required variable DATA_CACHE_DIR in .env.development.

Summary by CodeRabbit

  • Chores
    • Updated environment variable settings for cache and config paths.
    • Removed an unused development script for the review agent.
    • Simplified backend development script by removing a cache directory argument.
    • Cleaned up backend startup output by removing unnecessary console logging.

@brendan-kellam brendan-kellam requested a review from msukkari May 12, 2025 20:27
Copy link

coderabbitai bot commented May 12, 2025

Walkthrough

The updates modify environment variable settings in .env.development, remove a development script from the root package.json, adjust the backend's development watch script to simplify arguments, and clean up unused imports and logging from the backend entry point. No changes were made to exported or public entities.

Changes

File(s) Change Summary
.env.development Set DATA_CACHE_DIR to ${PWD}/.sourcebot; added commented-out CONFIG_PATH variable.
package.json Removed the dev:review-agent script from the scripts section.
packages/backend/package.json Modified dev:watch script to remove the --cacheDir argument from the yarn dev command.
packages/backend/src/index.ts Removed unused ArgumentParser import and a console.log(process.cwd()) statement.

Poem

In the warren of code, a cache path appears,
With scripts trimmed down, the clutter clears.
No more review-agent to start in a dash,
And backend logs vanish in a quiet flash.
The rabbit hops on, with code neat and bright—
Ready for work in the soft morning light!
🐇✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
.env.development (2)

26-26: Ensure environment variable expansion
Most .env loaders (e.g., dotenv) do not expand shell variables like ${PWD} by default. Verify that the project uses dotenv-expand or a similar mechanism so that DATA_CACHE_DIR resolves correctly at runtime instead of remaining the literal string.


27-27: Clarify the CONFIG_PATH placeholder
The commented-out CONFIG_PATH can be a helpful hint, but consider adding a brief inline note about when to enable it or moving detailed instructions to documentation to reduce clutter in the env file.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59cd86d and dd206f0.

📒 Files selected for processing (4)
  • .env.development (1 hunks)
  • package.json (0 hunks)
  • packages/backend/package.json (1 hunks)
  • packages/backend/src/index.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • packages/backend/src/index.ts
  • package.json
🔇 Additional comments (1)
packages/backend/package.json (1)

8-8: Remove redundant --cacheDir argument
Centralizing the cache directory via DATA_CACHE_DIR is on point. Please confirm that the backend startup sequence sources the .env.development file (or equivalent) so that process.env.DATA_CACHE_DIR is correctly picked up in development.

@brendan-kellam brendan-kellam merged commit fd65d78 into main May 12, 2025
5 checks passed
@brendan-kellam brendan-kellam deleted the bkellam/resolve_paths branch May 12, 2025 21:42
@msukkari
Copy link
Contributor

/review

Comment on lines +26 to +27
DATA_CACHE_DIR=${PWD}/.sourcebot # Path to the sourcebot cache dir (ex. ~/sourcebot/.sourcebot)
# CONFIG_PATH=${PWD}/config.json # Path to the sourcebot config file (if one exists)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding DATA_CACHE_DIR to ${PWD}/.sourcebot may cause issues in environments where PWD is not set or differs from the expected working directory. Consider allowing this to be overridden externally or document the assumption clearly. Also, if this file is sourced in contexts where PWD is not defined, it could lead to unexpected path resolution failures.

@@ -12,7 +12,6 @@
"dev:zoekt": "yarn with-env zoekt-webserver -index .sourcebot/index -rpc",
"dev:backend": "yarn with-env yarn workspace @sourcebot/backend dev:watch",
"dev:web": "yarn with-env yarn workspace @sourcebot/web dev",
"dev:review-agent": "yarn with-env yarn workspace @sourcebot/review-agent dev",
"watch:mcp": "yarn workspace @sourcebot/mcp build:watch",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the "dev:review-agent" script line should be accompanied by verification that no other scripts or documentation reference this script. If references exist, they need to be updated or removed to prevent confusion or build failures.

@@ -5,7 +5,7 @@
"main": "index.js",
"type": "module",
"scripts": {
"dev:watch": "tsc-watch --preserveWatchOutput --onSuccess \"yarn dev --cacheDir ../../.sourcebot\"",
"dev:watch": "tsc-watch --preserveWatchOutput --onSuccess \"yarn dev\"",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the --cacheDir option from the 'dev:watch' script may break functionality if 'dev' expects the cacheDir argument. Verify that the 'dev' script or the application can operate correctly without the explicit cacheDir setting before removing it.

@@ -1,7 +1,6 @@
import "./instrument.js";

import * as Sentry from "@sentry/node";
import { ArgumentParser } from "argparse";
import { existsSync } from 'fs';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import statement for 'ArgumentParser' from 'argparse' was removed. Ensure this import is not used elsewhere in this file or the removal may cause runtime errors.

@@ -37,8 +36,6 @@ process.on('unhandledRejection', (reason, promise) => {
process.exit(1);
});

console.log(process.cwd());

const cacheDir = env.DATA_CACHE_DIR;
const reposPath = path.join(cacheDir, 'repos');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removed console.log call on process.cwd() is useful for debugging the current working directory during application startup. Confirm this removal is intentional as no alternative logging has been added.

@msukkari
Copy link
Contributor

/review

Comment on lines +26 to +27
DATA_CACHE_DIR=${PWD}/.sourcebot # Path to the sourcebot cache dir (ex. ~/sourcebot/.sourcebot)
# CONFIG_PATH=${PWD}/config.json # Path to the sourcebot config file (if one exists)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid setting DATA_CACHE_DIR and CONFIG_PATH using PWD directly in the .env file as this can lead to unexpected paths if the working directory changes. Instead, set these variables dynamically in the application or in a startup script to ensure they resolve to the intended absolute path.

Comment on lines +26 to +27
DATA_CACHE_DIR=${PWD}/.sourcebot # Path to the sourcebot cache dir (ex. ~/sourcebot/.sourcebot)
# CONFIG_PATH=${PWD}/config.json # Path to the sourcebot config file (if one exists)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using ${PWD} for DATA_CACHE_DIR and CONFIG_PATH hardcodes the directory to the current working directory at load time, which may cause issues if the environment file is sourced from different locations or scripts run with different working directories. Consider using absolute paths or allowing these variables to be overridden externally with default fallbacks, for example: DATA_CACHE_DIR=${DATA_CACHE_DIR:-${PWD}/.sourcebot}.

@@ -12,7 +12,6 @@
"dev:zoekt": "yarn with-env zoekt-webserver -index .sourcebot/index -rpc",
"dev:backend": "yarn with-env yarn workspace @sourcebot/backend dev:watch",
"dev:web": "yarn with-env yarn workspace @sourcebot/web dev",
"dev:review-agent": "yarn with-env yarn workspace @sourcebot/review-agent dev",
"watch:mcp": "yarn workspace @sourcebot/mcp build:watch",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the 'dev:review-agent' script should be verified against any automation or developers' workflows that might depend on it to avoid breaking development processes.

@@ -12,7 +12,6 @@
"dev:zoekt": "yarn with-env zoekt-webserver -index .sourcebot/index -rpc",
"dev:backend": "yarn with-env yarn workspace @sourcebot/backend dev:watch",
"dev:web": "yarn with-env yarn workspace @sourcebot/web dev",
"dev:review-agent": "yarn with-env yarn workspace @sourcebot/review-agent dev",
"watch:mcp": "yarn workspace @sourcebot/mcp build:watch",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script 'dev:review-agent' was removed. Verify that this script is no longer required for development to avoid broken workflows.

@@ -5,7 +5,7 @@
"main": "index.js",
"type": "module",
"scripts": {
"dev:watch": "tsc-watch --preserveWatchOutput --onSuccess \"yarn dev --cacheDir ../../.sourcebot\"",
"dev:watch": "tsc-watch --preserveWatchOutput --onSuccess \"yarn dev\"",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the --cacheDir ../../.sourcebot argument from the dev:watch script may cause the development command to not use the intended cache directory as per the PR description about DATA_CACHE_DIR. Please verify that the environment variable or other configuration correctly sets this cache directory elsewhere, or consider retaining this argument if it is necessary for correct cache directory resolution.

@@ -5,7 +5,7 @@
"main": "index.js",
"type": "module",
"scripts": {
"dev:watch": "tsc-watch --preserveWatchOutput --onSuccess \"yarn dev --cacheDir ../../.sourcebot\"",
"dev:watch": "tsc-watch --preserveWatchOutput --onSuccess \"yarn dev\"",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the '--cacheDir ../../.sourcebot' argument from the 'dev:watch' script could lead to missing necessary cache directory settings required by the application. Confirm that the application no longer needs this argument or that it is set elsewhere in the environment or codebase. Otherwise, this change could cause runtime errors due to missing cache directory configuration.

@@ -1,7 +1,6 @@
import "./instrument.js";

import * as Sentry from "@sentry/node";
import { ArgumentParser } from "argparse";
import { existsSync } from 'fs';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unused import statement 'import { ArgumentParser } from "argparse";' instead of just deleting the line to avoid confusion or future errors.

@@ -1,7 +1,6 @@
import "./instrument.js";

import * as Sentry from "@sentry/node";
import { ArgumentParser } from "argparse";
import { existsSync } from 'fs';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unused import statement for ArgumentParser since it has been deleted from the imports, to avoid confusion or clutter in the import section.

@@ -37,8 +36,6 @@ process.on('unhandledRejection', (reason, promise) => {
process.exit(1);
});

console.log(process.cwd());

const cacheDir = env.DATA_CACHE_DIR;
const reposPath = path.join(cacheDir, 'repos');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the commented-out console.log statement or add a comment explaining why it was removed, to keep the code clean and maintainable.

@@ -37,8 +36,6 @@ process.on('unhandledRejection', (reason, promise) => {
process.exit(1);
});

console.log(process.cwd());

const cacheDir = env.DATA_CACHE_DIR;
const reposPath = path.join(cacheDir, 'repos');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed console.log(process.cwd()) statement which may have been used for debugging. Please confirm this removal is intentional and will not impact debugging or logging requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants