Skip to content

Commit 591e81e

Browse files
Merge pull request #83 from Adrenaline-AI/main
[Ruby] Fixed Solargraph install bug
2 parents 37f2e89 + 37359c6 commit 591e81e

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

src/multilspy/language_servers/solargraph/solargraph.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ def setup_runtime_dependencies(self, logger: MultilspyLogger, config: MultilspyC
4747
"""
4848
Setup runtime dependencies for Solargraph.
4949
"""
50-
platform_id = PlatformUtils.get_platform_id()
51-
which_cmd = "which"
52-
if platform_id in [PlatformId.WIN_x64, PlatformId.WIN_arm64, PlatformId.WIN_x86]:
53-
which_cmd = "where"
5450

5551
with open(os.path.join(os.path.dirname(__file__), "runtime_dependencies.json"), "r") as f:
5652
d = json.load(f)
@@ -74,23 +70,22 @@ def setup_runtime_dependencies(self, logger: MultilspyLogger, config: MultilspyC
7470
if result.stdout.strip() == "false":
7571
logger.log("Installing Solargraph...", logging.INFO)
7672
subprocess.run(dependency["installCommand"].split(), check=True, capture_output=True, cwd=repository_root_path)
77-
except subprocess.CalledProcessError as e:
78-
raise RuntimeError(f"Failed to check or install Solargraph. {e.stderr}")
79-
80-
# Get the solargraph executable path
81-
try:
82-
result = subprocess.run([which_cmd, "solargraph"], check=True, capture_output=True, text=True, cwd=repository_root_path)
83-
executeable_path = result.stdout.strip()
8473

85-
if not os.path.exists(executeable_path):
86-
raise RuntimeError(f"Solargraph executable not found at {executeable_path}")
74+
# Get the gem executable path directly
75+
result = subprocess.run(["gem", "which", "solargraph"], check=True, capture_output=True, text=True, cwd=repository_root_path)
76+
gem_path = result.stdout.strip()
77+
bin_dir = os.path.join(os.path.dirname(os.path.dirname(gem_path)), "bin")
78+
executable_path = os.path.join(bin_dir, "solargraph")
79+
80+
if not os.path.exists(executable_path):
81+
raise RuntimeError(f"Solargraph executable not found at {executable_path}")
8782

8883
# Ensure the executable has the right permissions
89-
os.chmod(executeable_path, os.stat(executeable_path).st_mode | stat.S_IEXEC)
84+
os.chmod(executable_path, os.stat(executable_path).st_mode | stat.S_IEXEC)
9085

91-
return executeable_path
92-
except subprocess.CalledProcessError:
93-
raise RuntimeError("Failed to locate Solargraph executable.")
86+
return executable_path
87+
except subprocess.CalledProcessError as e:
88+
raise RuntimeError(f"Failed to check or install Solargraph. {e.stderr}")
9489

9590
def _get_initialize_params(self, repository_absolute_path: str) -> InitializeParams:
9691
"""

0 commit comments

Comments
 (0)