Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/rb-cli/src/commands/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ mod tests {

assert!(!env_vars.contains_key("BUNDLE_GEMFILE"));
assert!(!env_vars.contains_key("BUNDLE_APP_CONFIG"));
assert!(!env_vars.contains_key("BUNDLE_PATH"));
}

#[test]
Expand Down Expand Up @@ -177,11 +178,17 @@ mod tests {

assert!(env_vars.contains_key("BUNDLE_GEMFILE"));
assert!(env_vars.contains_key("BUNDLE_APP_CONFIG"));
assert!(env_vars.contains_key("BUNDLE_PATH"));

let bundle_gemfile = env_vars.get("BUNDLE_GEMFILE").unwrap();
assert!(bundle_gemfile.contains("Gemfile"));

let bundle_app_config = env_vars.get("BUNDLE_APP_CONFIG").unwrap();
assert!(bundle_app_config.contains(".rb"));

let bundle_path = env_vars.get("BUNDLE_PATH").unwrap();
assert!(bundle_path.contains(".rb"));
assert!(bundle_path.contains("vendor"));
assert!(bundle_path.contains("bundler"));
}
}
43 changes: 0 additions & 43 deletions crates/rb-core/src/bundler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ impl BundlerRuntime {
) -> std::io::Result<bool> {
debug!("Checking bundle synchronization status");

self.configure_local_path(butler_runtime)?;

let output = Command::new("bundle")
.arg("check")
.current_dir(&self.root)
Expand Down Expand Up @@ -120,47 +118,6 @@ impl BundlerRuntime {
}
}

/// Configure bundler to use local vendor directory
pub fn configure_local_path(
&self,
butler_runtime: &crate::butler::ButlerRuntime,
) -> std::io::Result<()> {
debug!(
"Configuring bundle path to vendor directory: {}",
self.vendor_dir().display()
);

let status = Command::new("bundle")
.args(["config", "set", "path", "--local"])
.arg(self.vendor_dir().to_string_lossy().as_ref())
.current_dir(&self.root)
.status_with_context(butler_runtime);

match status {
Ok(status) => {
if status.success() {
debug!("Successfully configured bundle path");
Ok(())
} else {
Err(std::io::Error::other(format!(
"Failed to configure bundle path (exit code: {})",
status.code().unwrap_or(-1)
)))
}
}
Err(e) => {
if e.kind() == std::io::ErrorKind::NotFound {
Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"Bundler executable not found. Please install bundler with: gem install bundler",
))
} else {
Err(e)
}
}
}
}

pub fn install_dependencies<F>(
&self,
butler_runtime: &crate::butler::ButlerRuntime,
Expand Down
4 changes: 4 additions & 0 deletions crates/rb-core/src/butler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ impl ButlerRuntime {
if let Some(bundler_runtime) = &self.bundler_runtime {
let gemfile_path = bundler_runtime.gemfile_path();
let app_config_dir = bundler_runtime.app_config_dir();
let vendor_dir = bundler_runtime.vendor_dir();

debug!("Setting BUNDLE_GEMFILE: {}", gemfile_path.display());
env.insert(
Expand All @@ -630,6 +631,9 @@ impl ButlerRuntime {
"BUNDLE_APP_CONFIG".to_string(),
app_config_dir.display().to_string(),
);

debug!("Setting BUNDLE_PATH: {}", vendor_dir.display());
env.insert("BUNDLE_PATH".to_string(), vendor_dir.display().to_string());
} else {
debug!("No bundler runtime detected - skipping bundler environment variables");
}
Expand Down
10 changes: 10 additions & 0 deletions spec/commands/sync_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ Describe 'rb sync command'
The output should include "Environment Successfully Synchronized"
The stderr should not include "[DEPRECATED]"
End

It 'does not warn when checking an already synchronized bundle'
rb -R "$RUBIES_DIR" sync >/dev/null 2>&1 || fail "initial sync should succeed"

When run rb -R "$RUBIES_DIR" x bundle check
The status should be success
The output should include "The Gemfile's dependencies are satisfied"
The output should not include "You are replacing the current local value of path"
The stderr should not include "You are replacing the current local value of path"
End
End

Context 'when running sync in non-bundler project'
Expand Down
26 changes: 26 additions & 0 deletions tests/commands/Sync.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,32 @@ gem 'rake'
Pop-Location
}
}

It "Does not warn when checking an already synchronized bundle" {
$TestSubDir = Join-Path $Script:TestDir "test-recheck-$(Get-Random)"
New-Item -ItemType Directory -Path $TestSubDir -Force | Out-Null

@"
source 'https://rubygems.org'
gem 'rake'
"@ | Set-Content -Path (Join-Path $TestSubDir "Gemfile")

Push-Location $TestSubDir
try {
$InitialOutput = & $Script:RbPath sync 2>&1
if ($LASTEXITCODE -ne 0) {
throw "Initial sync failed. Exit code: $LASTEXITCODE. Output: $($InitialOutput -join "`n")"
}

$Output = & $Script:RbPath x bundle check 2>&1

$LASTEXITCODE | Should -Be 0
($Output -join " ") | Should -Match "The Gemfile's dependencies are satisfied"
($Output -join " ") | Should -Not -Match "You are replacing the current local value of path"
} finally {
Pop-Location
}
}
}

Context "Sync in Non-Bundler Project" {
Expand Down
Loading