Skip to content

Commit

Permalink
Fix local conda environments
Browse files Browse the repository at this point in the history
  • Loading branch information
yanecc committed Jun 14, 2024
1 parent 68de61d commit 71ed99f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
2 changes: 1 addition & 1 deletion hooks/post_install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ function PLUGIN:PostInstall(ctx)
makeGemsPath(sdkInfo.path)
return
end
unixInstall(sdkInfo.path, sdkInfo.version)
unixInstall(ctx.rootPath, sdkInfo.path, sdkInfo.version)
end
28 changes: 10 additions & 18 deletions lib/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ function generateTruffleRuby(version, osType, archType)
end

-- post_install.lua
function unixInstall(path, version)
function unixInstall(rootPath, path, version)
if hasValue(HomebrewRubyVersions, version) then
patchHomebrewRuby(path, version)
elseif version:match("%.m?rb$") then
Expand All @@ -388,7 +388,7 @@ function unixInstall(path, version)
elseif compareVersion(version, "9") == 0 then
patchJRuby(path)
else
mambaInstall(path, version)
mambaInstall(rootPath, path, version)
end
end

Expand Down Expand Up @@ -452,32 +452,24 @@ function patchJRuby(path)
end
end

function mambaInstall(path, version)
local macromamba = path .. "/macromamba"
function mambaInstall(rootPath, path, version)
local conda = rootPath .. "/conda"
local mamba = rootPath .. "/conda/micromamba"
local condaForge = os.getenv("Conda_Forge") or "conda-forge"
local command1 = "chmod +x " .. macromamba
local command2 = macromamba
.. " create -yqp "
.. path
.. "/temp -r "
.. path
.. " ruby="
.. version
.. " -c "
.. condaForge
local command3 = "mv " .. path .. "/temp/* " .. path
local command1 = "mv " .. path .. " " .. conda
local command2 = "chmod +x " .. mamba
local command3 = mamba .. " create -yqp " .. path .. " -r " .. conda .. " ruby=" .. version .. " -c " .. condaForge
local command4 = "mkdir -p " .. path .. "/share/gems/bin"
local command5 = "rm -rf " .. path .. "/temp " .. path .. "/pkgs " .. path .. "/etc " .. path .. "/conda-meta"
local command5 = "rm -rf " .. path .. "/etc " .. path .. "/conda-meta " .. conda

downloadMacroMamba(macromamba)
downloadMacroMamba(path .. "/micromamba")
for _, command in ipairs({ command1, command2, command3, command4, command5 }) do
local status = os.execute(command)
if status ~= 0 then
print("Failed to execute command: " .. command)
os.exit(1)
end
end
os.remove(macromamba)
end

function downloadMacroMamba(path)
Expand Down
2 changes: 1 addition & 1 deletion metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PLUGIN = {}
--- Plugin name
PLUGIN.name = "ruby"
--- Plugin version
PLUGIN.version = "0.5.0"
PLUGIN.version = "0.5.1"
--- Plugin homepage
PLUGIN.homepage = "https://github.com/yanecc/vfox-ruby"
--- Plugin license, please choose a correct license according to your needs.
Expand Down

0 comments on commit 71ed99f

Please sign in to comment.