hexpm / hex

Package manager for the Erlang ecosystem.
https://hex.pm
977 stars 187 forks source link

Replit: "Unpacking tarball failed: inner tarball error, not owner" error #1051

Open sgerrand opened 2 months ago

sgerrand commented 2 months ago

💁 I've been experiencing strange problems when using Elixir on Replit

Observed behaviour

With the following mix.exs (shamelessly stolen from Wojtek's Req docs):

Mix.install([
  {:req, "~> 0.5.0"}
])

Req.get!("https://api.github.com/repos/wojtekmach/req").body["description"]

The following error is returned:

* creating /home/runner/Test-Hex-package-fetching-errors/.mix/archives/hex-2.1.1
Resolving Hex dependencies...
Resolution completed in 0.178s
New:
  finch 0.19.0
  hpax 1.0.0
  jason 1.4.4
  mime 2.0.6
  mint 1.6.2
  nimble_options 1.1.1
  nimble_pool 1.1.0
  req 0.5.6
  telemetry 1.3.0
* Getting req (Hex package)
** (Mix.Error) Unpacking tarball failed: inner tarball error, not owner
    (mix 1.16.3) lib/mix.ex:580: Mix.raise/2
    (hex 2.1.1) lib/hex/scm.ex:180: Hex.SCM.update/1
    (hex 2.1.1) lib/hex/scm.ex:246: Hex.SCM.checkout/1
    (mix 1.16.3) lib/mix/dep/fetcher.ex:64: Mix.Dep.Fetcher.do_fetch/3
    (mix 1.16.3) lib/mix/dep/converger.ex:229: Mix.Dep.Converger.all/8
    (mix 1.16.3) lib/mix/dep/converger.ex:162: Mix.Dep.Converger.init_all/8
    (mix 1.16.3) lib/mix/dep/converger.ex:146: Mix.Dep.Converger.all/4
    (mix 1.16.3) lib/mix/dep/converger.ex:89: Mix.Dep.Converger.converge/4

This appears to be caused by the type of filesystem that Replit exposes and I suspect that they're mounting it with things like mtime turned off.

Source Replit repo

Expected behaviour

Hex fetches dependencies successfully.

sgerrand commented 2 months ago

I suspect that this issue may be related in some way to #624 (and others) as I've encountered similar issues when using mix new to create a new project in the same Replit repo:

$ mix new testapp
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating lib
* creating lib/testapp.ex
* creating test
* creating test/test_helper.exs
* creating test/testapp_test.exs

Your Mix project was created successfully.
You can use "mix" to compile it, test it, and more:

    cd testapp
    mix test

Run "mix help" for more commands.
~/Test-Hex-package-fetching-errors$ cd testapp
~/Test-Hex-package-fetching-errors/testapp$ mix deps.fetch
Compiling 1 file (.ex)
** (EXIT from #PID<0.94.0>) an exception was raised:
    ** (File.Error) could not touch "/home/runner/Test-Hex-package-fetching-errors/testapp/_build/dev/lib/testapp/ebin/Elixir.Testapp.beam": not owner
        (elixir 1.16.3) lib/file.ex:631: File.touch!/2
        (elixir 1.16.3) lib/kernel/parallel_compiler.ex:334: anonymous fn/3 in Kernel.ParallelCompiler.write_module_binaries/3
        (elixir 1.16.3) lib/enum.ex:1264: anonymous fn/3 in Enum.flat_map/2
        (stdlib 4.3.1.4) maps.erl:411: :maps.fold_1/3
        (elixir 1.16.3) lib/enum.ex:2540: Enum.flat_map/2
        (elixir 1.16.3) lib/kernel/parallel_compiler.ex:260: Kernel.ParallelCompiler.spawn_workers/3
        (mix 1.16.3) lib/mix/compilers/elixir.ex:1002: anonymous fn/9 in Mix.Compilers.Elixir.compiler_loop/6
sgerrand commented 2 months ago

If I simulate the underlying calls like @nicbet did earlier, then I have a whole bunch of :undefined atoms returned:

defmodule XFile do
  require Record
  Record.defrecord(:file_info,  Record.extract(:file_info, from_lib: "kernel/include/file.hrl"))
end

require XFile

finfo = XFile.file_info(mtime: :calendar.universal_time())
iex(4)> finfo = XFile.file_info(mtime: :calendar.universal_time())

{:file_info, :undefined, :undefined, :undefined, :undefined,
 {{2024, 9, 18}, {13, 45, 40}}, :undefined, :undefined, :undefined, :undefined,
:undefined, :undefined, :undefined, :undefined}
ericmj commented 2 months ago

Can you check with replit to see if they have any ideas on why this might time and how to work around it. If the reason is because they have a filesystem with limited functionality I bet they have ran into this before.

sgerrand commented 2 months ago

Of course. This was their support team's response to date:

Thank you for contacting Replit Support.

This is a strange one as it looks to be a package issue as opposed to a Replit issue. There are already bugs around this in Elixir, though not exactly this invocation: https://github.com/elixir-lang/elixir/issues/8875

The suggestion in that thread is that mtime was turned off on the filesystem, giving the impression writes were not possible.

Sorry we couldn't be of more help, but you can try posting the issue with Elixir to see if they have solutions or workarounds.

I've asked them for more information about the filesystem that is currently made available for Replit's repls to narrow down the cause(s).

ericmj commented 2 months ago

Following up in https://github.com/elixir-lang/elixir/issues/8875.