aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author3uryd1ce <99762926+3uryd1ce@users.noreply.github.com>2023-08-19 00:48:10 -0600
committerGitHub <noreply@github.com>2023-08-19 08:48:10 +0200
commita51c2d063c5377ee9e58c5f9cda7c7436787be72 (patch)
treeb8a61c7726b9ba92153aed6cbb64c728ed9ec105
parentfeat(cargo): support fetching versions for git crates hosted on github (#1459) (diff)
downloadmason-a51c2d063c5377ee9e58c5f9cda7c7436787be72.tar
mason-a51c2d063c5377ee9e58c5f9cda7c7436787be72.tar.gz
mason-a51c2d063c5377ee9e58c5f9cda7c7436787be72.tar.bz2
mason-a51c2d063c5377ee9e58c5f9cda7c7436787be72.tar.lz
mason-a51c2d063c5377ee9e58c5f9cda7c7436787be72.tar.xz
mason-a51c2d063c5377ee9e58c5f9cda7c7436787be72.tar.zst
mason-a51c2d063c5377ee9e58c5f9cda7c7436787be72.zip
fix(std): use gtar if available (#1433)
Closes #1415.
-rw-r--r--README.md21
-rw-r--r--lua/mason-core/installer/managers/std.lua5
-rw-r--r--lua/mason/health.lua4
-rw-r--r--tests/mason-core/installer/managers/std_spec.lua119
4 files changed, 94 insertions, 55 deletions
diff --git a/README.md b/README.md
index fee6ab08..590545c3 100644
--- a/README.md
+++ b/README.md
@@ -42,7 +42,7 @@ Packages are installed in Neovim's data directory ([`:h standard-path`][help-sta
linked to a single `bin/` directory, which `mason.nvim` will add to Neovim's PATH during setup, allowing seamless access
from Neovim builtins (shell, terminal, etc.) as well as other 3rd party plugins.
-For a list of all available packages, see https://mason-registry.dev/registry/list.
+For a list of all available packages, see <https://mason-registry.dev/registry/list>.
## How to use installed packages
@@ -80,8 +80,22 @@ party plugins to further integrate these. The following plugins are recommended:
The _minimum_ recommended requirements are:
- neovim `>= 0.7.0`
-- For Unix systems: `git(1)`, `curl(1)` or `wget(1)`, `unzip(1)`, `tar(1)`, `gzip(1)`
-- For Windows systems: pwsh or powershell, git, tar, and [7zip][7zip] or [peazip][peazip] or [archiver][archiver] or [winzip][winzip] or [WinRAR][winrar]
+- For Unix systems:
+ - `git(1)`
+ - `curl(1)` or `wget(1)`
+ - `unzip(1)`
+ - GNU tar (`tar(1)` or `gtar(1)` depending on platform)
+ - `gzip(1)`
+- For Windows systems:
+ - pwsh or powershell
+ - git
+ - GNU tar
+ - One of the following:
+ - [7zip][7zip]
+ - [peazip][peazip]
+ - [archiver][archiver]
+ - [winzip][winzip]
+ - [WinRAR][winrar]
Note that `mason.nvim` will regularly shell out to external package managers, such as `cargo` and `npm`. Depending on
your personal usage, some of these will also need to be installed. Refer to `:checkhealth mason` for a full list.
@@ -146,7 +160,6 @@ Refer to the [Wiki](https://github.com/williamboman/mason.nvim/wiki/Extensions)
- `:MasonUninstallAll` - uninstalls all packages
- `:MasonLog` - opens the `mason.nvim` log file in a new tab window
-
# Registries
Mason's core package registry is located at [mason-org/mason-registry](https://github.com/mason-org/mason-registry).
diff --git a/lua/mason-core/installer/managers/std.lua b/lua/mason-core/installer/managers/std.lua
index d08de888..6e1a0d9e 100644
--- a/lua/mason-core/installer/managers/std.lua
+++ b/lua/mason-core/installer/managers/std.lua
@@ -1,5 +1,6 @@
local Result = require "mason-core.result"
local _ = require "mason-core.functional"
+local a = require "mason-core.async"
local fetch = require "mason-core.fetch"
local installer = require "mason-core.installer"
local log = require "mason-core.log"
@@ -108,7 +109,9 @@ end
local function untar(rel_path)
log.fmt_debug("std: untar %s", rel_path)
local ctx = installer.context()
- return ctx.spawn.tar({ "--no-same-owner", "-xvf", rel_path }):on_success(function()
+ a.scheduler()
+ local tar = vim.fn.executable "gtar" == 1 and "gtar" or "tar"
+ return ctx.spawn[tar]({ "--no-same-owner", "-xvf", rel_path }):on_success(function()
pcall(function()
ctx.fs:unlink(rel_path)
end)
diff --git a/lua/mason/health.lua b/lua/mason/health.lua
index fdd5ea07..ade8a29d 100644
--- a/lua/mason/health.lua
+++ b/lua/mason/health.lua
@@ -143,7 +143,9 @@ local function check_core_utils()
use_stderr = platform.is.mac, -- Apple gzip prints version string to stderr
relaxed = platform.is.win,
}
- check { cmd = "tar", args = { "--version" }, name = "tar" }
+
+ local tar = vim.fn.executable "gtar" == 1 and "gtar" or "tar"
+ check { cmd = tar, args = { "--version" }, name = tar }
if platform.is.unix then
check { cmd = "bash", args = { "--version" }, name = "bash" }
diff --git a/tests/mason-core/installer/managers/std_spec.lua b/tests/mason-core/installer/managers/std_spec.lua
index cf799477..dea342bc 100644
--- a/tests/mason-core/installer/managers/std_spec.lua
+++ b/tests/mason-core/installer/managers/std_spec.lua
@@ -14,69 +14,90 @@ describe("std unpack [Unix]", function()
assert.spy(ctx.spawn.gzip).was_called_with { "-d", "file.gz" }
end)
- it("should unpack .tar", function()
- local ctx = create_dummy_context()
- stub(ctx.fs, "unlink")
- installer.exec_in_context(ctx, function()
- std.unpack "file.tar"
+ describe("tar", function()
+ before_each(function()
+ stub(vim.fn, "executable")
+ vim.fn.executable.on_call_with("gtar").returns(0)
end)
- assert.spy(ctx.spawn.tar).was_called(1)
- assert.spy(ctx.spawn.tar).was_called_with { "--no-same-owner", "-xvf", "file.tar" }
- assert.spy(ctx.fs.unlink).was_called(1)
- assert.spy(ctx.fs.unlink).was_called_with(match.is_ref(ctx.fs), "file.tar")
- end)
+ it("should use gtar if available", function()
+ local ctx = create_dummy_context()
+ stub(ctx.fs, "unlink")
+ stub(vim.fn, "executable")
+ vim.fn.executable.on_call_with("gtar").returns(1)
- it("should unpack .tar.bz2", function()
- local ctx = create_dummy_context()
- stub(ctx.fs, "unlink")
- installer.exec_in_context(ctx, function()
- std.unpack "file.tar.bz2"
+ installer.exec_in_context(ctx, function()
+ std.unpack "file.tar.gz"
+ end)
+
+ assert.spy(ctx.spawn.gtar).was_called(1)
+ assert.spy(ctx.spawn.gtar).was_called_with { "--no-same-owner", "-xvf", "file.tar.gz" }
end)
- assert.spy(ctx.spawn.tar).was_called(1)
- assert.spy(ctx.spawn.tar).was_called_with { "--no-same-owner", "-xvf", "file.tar.bz2" }
- assert.spy(ctx.fs.unlink).was_called(1)
- assert.spy(ctx.fs.unlink).was_called_with(match.is_ref(ctx.fs), "file.tar.bz2")
- end)
+ it("should unpack .tar", function()
+ local ctx = create_dummy_context()
+ stub(ctx.fs, "unlink")
+ installer.exec_in_context(ctx, function()
+ std.unpack "file.tar"
+ end)
- it("should unpack .tar.gz", function()
- local ctx = create_dummy_context()
- stub(ctx.fs, "unlink")
- installer.exec_in_context(ctx, function()
- std.unpack "file.tar.gz"
+ assert.spy(ctx.spawn.tar).was_called(1)
+ assert.spy(ctx.spawn.tar).was_called_with { "--no-same-owner", "-xvf", "file.tar" }
+ assert.spy(ctx.fs.unlink).was_called(1)
+ assert.spy(ctx.fs.unlink).was_called_with(match.is_ref(ctx.fs), "file.tar")
end)
- assert.spy(ctx.spawn.tar).was_called(1)
- assert.spy(ctx.spawn.tar).was_called_with { "--no-same-owner", "-xvf", "file.tar.gz" }
- assert.spy(ctx.fs.unlink).was_called(1)
- assert.spy(ctx.fs.unlink).was_called_with(match.is_ref(ctx.fs), "file.tar.gz")
- end)
+ it("should unpack .tar.bz2", function()
+ local ctx = create_dummy_context()
+ stub(ctx.fs, "unlink")
+ installer.exec_in_context(ctx, function()
+ std.unpack "file.tar.bz2"
+ end)
- it("should unpack .tar.xz", function()
- local ctx = create_dummy_context()
- stub(ctx.fs, "unlink")
- installer.exec_in_context(ctx, function()
- std.unpack "file.tar.xz"
+ assert.spy(ctx.spawn.tar).was_called(1)
+ assert.spy(ctx.spawn.tar).was_called_with { "--no-same-owner", "-xvf", "file.tar.bz2" }
+ assert.spy(ctx.fs.unlink).was_called(1)
+ assert.spy(ctx.fs.unlink).was_called_with(match.is_ref(ctx.fs), "file.tar.bz2")
end)
- assert.spy(ctx.spawn.tar).was_called(1)
- assert.spy(ctx.spawn.tar).was_called_with { "--no-same-owner", "-xvf", "file.tar.xz" }
- assert.spy(ctx.fs.unlink).was_called(1)
- assert.spy(ctx.fs.unlink).was_called_with(match.is_ref(ctx.fs), "file.tar.xz")
- end)
+ it("should unpack .tar.gz", function()
+ local ctx = create_dummy_context()
+ stub(ctx.fs, "unlink")
+ installer.exec_in_context(ctx, function()
+ std.unpack "file.tar.gz"
+ end)
- it("should unpack .tar.zst", function()
- local ctx = create_dummy_context()
- stub(ctx.fs, "unlink")
- installer.exec_in_context(ctx, function()
- std.unpack "file.tar.zst"
+ assert.spy(ctx.spawn.tar).was_called(1)
+ assert.spy(ctx.spawn.tar).was_called_with { "--no-same-owner", "-xvf", "file.tar.gz" }
+ assert.spy(ctx.fs.unlink).was_called(1)
+ assert.spy(ctx.fs.unlink).was_called_with(match.is_ref(ctx.fs), "file.tar.gz")
end)
- assert.spy(ctx.spawn.tar).was_called(1)
- assert.spy(ctx.spawn.tar).was_called_with { "--no-same-owner", "-xvf", "file.tar.zst" }
- assert.spy(ctx.fs.unlink).was_called(1)
- assert.spy(ctx.fs.unlink).was_called_with(match.is_ref(ctx.fs), "file.tar.zst")
+ it("should unpack .tar.xz", function()
+ local ctx = create_dummy_context()
+ stub(ctx.fs, "unlink")
+ installer.exec_in_context(ctx, function()
+ std.unpack "file.tar.xz"
+ end)
+
+ assert.spy(ctx.spawn.tar).was_called(1)
+ assert.spy(ctx.spawn.tar).was_called_with { "--no-same-owner", "-xvf", "file.tar.xz" }
+ assert.spy(ctx.fs.unlink).was_called(1)
+ assert.spy(ctx.fs.unlink).was_called_with(match.is_ref(ctx.fs), "file.tar.xz")
+ end)
+
+ it("should unpack .tar.zst", function()
+ local ctx = create_dummy_context()
+ stub(ctx.fs, "unlink")
+ installer.exec_in_context(ctx, function()
+ std.unpack "file.tar.zst"
+ end)
+
+ assert.spy(ctx.spawn.tar).was_called(1)
+ assert.spy(ctx.spawn.tar).was_called_with { "--no-same-owner", "-xvf", "file.tar.zst" }
+ assert.spy(ctx.fs.unlink).was_called(1)
+ assert.spy(ctx.fs.unlink).was_called_with(match.is_ref(ctx.fs), "file.tar.zst")
+ end)
end)
it("should unpack .vsix", function()