Skip to content

jac install does not install npm/plugin dependencies #4471

@marsninja

Description

@marsninja

Summary

When cloning an existing Jac application or deleting the .jac folder for a clean slate, users need to re-install all dependencies. Currently, jac install only installs Python/pip dependencies and does not install npm (or other plugin-registered) dependencies.

Current Behavior

  1. jac install - Only installs Python dependencies from [dependencies], [dev-dependencies], and [dependencies.git] sections
  2. jac add <package> --npm - Works for individual npm packages
  3. jac add --npm (no packages) - Installs all npm packages from [dependencies.npm]

There is no single command to install ALL dependencies (Python + npm + other plugins) at once.

Expected Behavior

jac install should install all dependencies including plugin-registered dependency types (npm, etc.), or there should be a clear flag to do so (e.g., jac install --all).

Reproduction Steps

  1. Create a client project:

    jac create --use client my-project
    cd my-project
  2. The generated jac.toml contains npm dependencies:

    [dependencies.npm]
    jac-client-node = "1.0.4"
    
    [dependencies.npm.dev]
    "@jac-client/dev-deps" = "1.0.0"
  3. Delete the .jac folder to simulate fresh clone:

    rm -rf .jac
  4. Run jac install:

    jac install --verbose

    Result: Only creates venv, npm packages are NOT installed

  5. User must separately run:

    jac add --npm

Technical Analysis

The issue is in DependencyInstaller.install_all() which only handles:

  • config.dependencies (Python packages)
  • config.dev_dependencies (Python dev packages)
  • config.git_dependencies (Git repositories)

The plugin infrastructure for install_all_handler exists in DependencyRegistry and jac-client registers an _npm_install_all_handler, but jac install never invokes these handlers.

Proposed Solution

Modify jac install to:

  1. After installing Python/Git dependencies, iterate through registered dependency types from DependencyRegistry
  2. For each registered type with an install_all_handler, call it to install those dependencies

Example code change in dependencies.impl.jac:

impl DependencyInstaller.install_all(include_dev: bool = False) -> bool {
    # ... existing Python/Git installation code ...
    
    # Install plugin dependencies (npm, etc.)
    from jaclang.project.dep_registry import get_dependency_registry
    registry = get_dependency_registry()
    for dep_type in registry.get_all().values() {
        if dep_type.install_all_handler is not None {
            try {
                dep_type.install_all_handler(self.config)
            } except Exception as e {
                console.error(f"Failed to install {dep_type.name} dependencies: {e}")
                all_success = False
            }
        }
    }
    return all_success
}

Workaround

Until this is fixed, users can create a script in jac.toml:

[scripts]
setup = "jac install && jac add --npm"

Then run: jac script setup

Environment

  • Jac version: latest (main branch)
  • OS: Linux
  • Plugin: jac-client

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions