-
Notifications
You must be signed in to change notification settings - Fork 87
feat: add yarn and bun light cli support #2131
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
feat: add yarn and bun light cli support #2131
Conversation
WalkthroughThe find_light_bin function now resolves symlinks to the light binary and traverses upward from the resolved path to locate a bin directory containing account_compression.so, improving path derivation beyond simple directory manipulation. Devenv behavior remains unchanged. Tests added for non-devenv scenarios. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
f2656af to
cbe4904
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (2)
.github/workflows/sdk-tests.ymlis excluded by none and included by nonejs/stateless.js/src/programs/system/layout.tsis excluded by none and included by none
📒 Files selected for processing (1)
sdk-libs/program-test/src/utils/find_light_bin.rs(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
sdk-libs/**/*.rs
📄 CodeRabbit inference engine (CLAUDE.md)
Unit tests in sdk-libs must not depend on light-test-utils; integration tests must be located in sdk-tests/
Files:
sdk-libs/program-test/src/utils/find_light_bin.rs
🧠 Learnings (16)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run Light system program compression tests using `cargo test-sbf -p system-test -- test_with_compression` and `cargo test-sbf -p system-test --test test_re_init_cpi_account` to test compressed account operations
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.803Z
Learning: Applies to sdk-tests/sdk-ctoken-test/**/Cargo.toml : Use path references in Cargo.toml dependencies pointing to `/Users/ananas/dev/light-protocol2/sdk-libs/` for light-ctoken-sdk, light-ctoken-types, light-sdk, light-sdk-types, and light-program-test
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run account-compression tests using `cargo test-sbf -p account-compression-test` to test core account compression program (Merkle tree management)
📚 Learning: 2025-12-07T03:17:28.803Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.803Z
Learning: Applies to sdk-tests/sdk-ctoken-test/**/Cargo.toml : Use path references in Cargo.toml dependencies pointing to `/Users/ananas/dev/light-protocol2/sdk-libs/` for light-ctoken-sdk, light-ctoken-types, light-sdk, light-sdk-types, and light-program-test
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-12-06T00:50:31.314Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-06T00:50:31.314Z
Learning: Applies to program-libs/**/*.rs : Unit tests in program-libs must not depend on light-test-utils; tests requiring light-test-utils must be located in program-tests/
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-12-06T00:50:31.314Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-06T00:50:31.314Z
Learning: Applies to sdk-libs/**/*.rs : Unit tests in sdk-libs must not depend on light-test-utils; integration tests must be located in sdk-tests/
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-12-06T00:50:31.314Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-06T00:50:31.314Z
Learning: Applies to programs/**/*.rs : Unit tests in programs must not depend on light-test-utils; integration tests must be located in program-tests/
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-12-06T00:49:57.458Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-token-test/CLAUDE.md:0-0
Timestamp: 2025-12-06T00:49:57.458Z
Learning: Applies to sdk-tests/sdk-token-test/**/*test.rs : Tests should use light-ctoken-sdk functions from sdk-libs/compressed-token-sdk for testing ctoken instructions
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-11-24T17:56:00.229Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/CLAUDE.md:0-0
Timestamp: 2025-11-24T17:56:00.229Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/Cargo.toml : Depend on light-account-checks crate for account validation and discriminator checks
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-12-07T03:17:28.803Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-12-07T03:17:28.803Z
Learning: Applies to sdk-tests/sdk-ctoken-test/src/{lib,main}.rs : Structure Solana BPF projects with src/lib.rs containing the program entrypoint and instruction handlers
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-11-24T17:56:00.229Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/CLAUDE.md:0-0
Timestamp: 2025-11-24T17:56:00.229Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/Cargo.toml : Use light-merkle-tree-reference crate as dev dependency for reference implementation of indexed Merkle trees and generating constants
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run Light system program compression tests using `cargo test-sbf -p system-test -- test_with_compression` and `cargo test-sbf -p system-test --test test_re_init_cpi_account` to test compressed account operations
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-11-24T17:56:00.229Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/CLAUDE.md:0-0
Timestamp: 2025-11-24T17:56:00.229Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/Cargo.toml : Depend on light-compressed-account crate for compressed account types and utilities
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run E2E extended tests after building the small compressed token program using `pnpm --filter lightprotocol/programs run build-compressed-token-small` followed by `cargo test-sbf -p e2e-test -- --test test_10_all`
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run system CPI V1 tests using `cargo test-sbf -p system-cpi-test` to test Cross-Program Invocation with Light system program V1
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run account-compression tests using `cargo test-sbf -p account-compression-test` to test core account compression program (Merkle tree management)
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: All integration tests in the program-tests directory depend on `program-tests/utils` (light-test-utils) for shared test infrastructure, except `zero-copy-derive-test`
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run Light system program address tests using `cargo test-sbf -p system-test -- test_with_address` to test address-based operations
Applied to files:
sdk-libs/program-test/src/utils/find_light_bin.rs
🔇 Additional comments (3)
sdk-libs/program-test/src/utils/find_light_bin.rs (3)
7-8: LGTM: Imports appropriately scoped.The addition of
fsfor symlink operations and scoping ofprocess::Commandwithin the non-devenv block is clean and correct.
67-94: LGTM: Test module appropriately validates the functionality.The test is correctly scoped to non-devenv builds and includes helpful diagnostic output. The conditional assertions (lines 84-92) are good practice since the light CLI may not be installed in all test environments.
The test complies with the coding guideline that unit tests in sdk-libs must not depend on light-test-utils.
34-45: Traversal logic is sound, but verify across package managers.The upward directory traversal correctly locates the bin/ directory containing
account_compression.so. The validation check on line 41 ensures the right directory is found.However, verify this works correctly across different package manager layouts (npm, yarn, pnpm, bun) as they may have different directory structures.
Run the following script to verify the package structures:
#!/bin/bash # Description: Test find_light_bin with different package managers if available echo "=== Testing light binary resolution ===" # Check if light is installed if ! command -v light &> /dev/null; then echo "light CLI not found - skipping verification" exit 0 fi echo "Light binary location:" which light echo -e "\nChecking if it's a symlink:" if [ -L "$(which light)" ]; then echo "Yes, symlink to:" readlink "$(which light)" echo "Resolved path:" readlink -f "$(which light)" else echo "No, regular file" fi echo -e "\nSearching for account_compression.so near light binary:" fd -t f "account_compression.so" "$(dirname $(dirname $(which light)))" 2>/dev/null | head -5
| // Follow the symlink to find the actual script location. | ||
| // This works for npm, bun, and yarn which all create symlinks from their | ||
| // bin directory to the actual script in the package. | ||
| let symlink_target = fs::read_link(&light_path).ok()?; | ||
|
|
||
| Some(node_modules_bin.canonicalize().unwrap_or(node_modules_bin)) | ||
| // Resolve relative symlinks (e.g., "../lib/node_modules/...") | ||
| let resolved_path = if symlink_target.is_relative() { | ||
| let parent = light_path.parent()?; | ||
| parent.join(&symlink_target).canonicalize().ok()? | ||
| } else { | ||
| symlink_target.canonicalize().ok()? | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical: Breaks direct installations by assuming symlink.
Line 24 uses fs::read_link(&light_path).ok()? which immediately returns None if light is not a symlink. This breaks scenarios where:
- The
lightbinary is copied directly to a bin directory - It's installed without package managers (direct download/build)
- It's a hard link rather than a symbolic link
The function should handle both symlinks and regular files.
Apply this diff to handle both cases:
- // Follow the symlink to find the actual script location.
- // This works for npm, bun, and yarn which all create symlinks from their
- // bin directory to the actual script in the package.
- let symlink_target = fs::read_link(&light_path).ok()?;
-
- // Resolve relative symlinks (e.g., "../lib/node_modules/...")
- let resolved_path = if symlink_target.is_relative() {
- let parent = light_path.parent()?;
- parent.join(&symlink_target).canonicalize().ok()?
- } else {
- symlink_target.canonicalize().ok()?
- };
+ // If light is a symlink (npm, bun, yarn), follow it to the actual script.
+ // Otherwise, use the binary path directly.
+ let resolved_path = if let Ok(symlink_target) = fs::read_link(&light_path) {
+ // Resolve relative symlinks (e.g., "../lib/node_modules/...")
+ if symlink_target.is_relative() {
+ let parent = light_path.parent()?;
+ parent.join(&symlink_target).canonicalize().ok()?
+ } else {
+ symlink_target.canonicalize().ok()?
+ }
+ } else {
+ // Not a symlink, use the path directly
+ light_path.canonicalize().ok()?
+ };📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Follow the symlink to find the actual script location. | |
| // This works for npm, bun, and yarn which all create symlinks from their | |
| // bin directory to the actual script in the package. | |
| let symlink_target = fs::read_link(&light_path).ok()?; | |
| Some(node_modules_bin.canonicalize().unwrap_or(node_modules_bin)) | |
| // Resolve relative symlinks (e.g., "../lib/node_modules/...") | |
| let resolved_path = if symlink_target.is_relative() { | |
| let parent = light_path.parent()?; | |
| parent.join(&symlink_target).canonicalize().ok()? | |
| } else { | |
| symlink_target.canonicalize().ok()? | |
| }; | |
| // If light is a symlink (npm, bun, yarn), follow it to the actual script. | |
| // Otherwise, use the binary path directly. | |
| let resolved_path = if let Ok(symlink_target) = fs::read_link(&light_path) { | |
| // Resolve relative symlinks (e.g., "../lib/node_modules/...") | |
| if symlink_target.is_relative() { | |
| let parent = light_path.parent()?; | |
| parent.join(&symlink_target).canonicalize().ok()? | |
| } else { | |
| symlink_target.canonicalize().ok()? | |
| } | |
| } else { | |
| // Not a symlink, use the path directly | |
| light_path.canonicalize().ok()? | |
| }; |
Summary by CodeRabbit
Release Notes
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.