Errors with install_cmdstan(): Problem extracting tarball. Exited with return code: 128

Hi,

Am trying to install cmdstan via RStudio. I have looked through threads and found a close thread which does not deal with my error (quite): Cmdstan not installing - Interfaces / CmdStan - The Stan Forums (mc-stan.org).

R version 4.3.1

I have successfully installed cmdstanr package:
remotes::install_github(“stan-dev/cmdstanr”)

> install_cmdstan()
The C++ toolchain required for CmdStan is setup properly!
trying URL 'https://api.github.com/repos/stan-dev/cmdstan/releases/latest'
Content type 'application/json; charset=utf-8' length 18055 bytes (17 KB)
downloaded 17 KB

* Latest CmdStan release is v2.33.0
* Installing CmdStan v2.33.0 in C:/Users/xx.xxx/Documents/.cmdstan/cmdstan-2.33.0
* Downloading cmdstan-2.33.0.tar.gz from GitHub...
trying URL 'https://github.com/stan-dev/cmdstan/releases/download/v2.33.0/cmdstan-2.33.0.tar.gz'
Content type 'application/octet-stream' length 51049232 bytes (48.7 MB)
downloaded 48.7 MB

* Download complete
* Unpacking archive...
/usr/bin/tar: Cannot connect to C: resolve failed
Error: Problem extracting tarball. Exited with return code: 128
In addition: Warning message:
In utils::untar(dest_file, exdir = dir_cmdstan, extras = "--strip-components 1") :
  ‘tar.exe -xf "C:/Users/xx.xxx/Documents/.cmdstan/cmdstan-2.33.0.tar.gz" -C "C:/Users/xx.xxx/Documents/.cmdstan/cmdstan-2.33.0" --strip-components 1’ returned error code 128
> system("tar.exe")
/usr/bin/tar: You must specify one of the '-Acdtrux', '--delete' or '--test-label' options
Try '/usr/bin/tar --help' or '/usr/bin/tar --usage' for more information.
[1] 2
> cmdstanr::check_cmdstan_toolchain(fix=TRUE)
The C++ toolchain required for CmdStan is setup properly!
> find_rtools()
[1] TRUE
> Sys.getenv('PATH')
[1] "C:\\rtools43\\x86_64-w64-mingw32.static.posix\\bin;C:\\rtools43\\usr\\bin;C:\\Program Files\\R\\R-4.3.1\\bin\\x64;C:\\Program Files\\OpenSSH-Win64;C:\\Windows;C:\\Windows\\System32\\wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn;C:\\Program Files\\dotnet;C:\\Program Files\\Git\\cmd;C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance Toolkit;C:\\rtools43\\usr\\bin;C:\\rtools43\\mingw64\\bin;C:\\Users\\xx.xxx\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files\\RStudio\\resources\\app\\bin\\quarto\\bin;C:\\Program Files\\RStudio\\resources\\app\\bin\\postback"

Having had a spirited attempt at googling the problem am now stumped.
Please could anyone give me a pointer on where to look next?

Thanks in advance and I’m a newbie here so I hope I haven’t missed anything bvious.
Please provide this additional information in addition to your question:

  • Operating System: Windows10
  • CmdStan Version: cmdstan-2.33.0
  • Compiler/Toolkit:Rtools43

@jonah @rok_cesnovar

Weird error. Seems to imply tar isn’t working. @rok_cesnovar knows (a lot) more about Windows than I do, so he might have a good suggestions, but I checked to see if I could find any similar issues reported and the closest thing I’ve seen to this is

which ended up being solved by

(However that was with Rtools42 and it looks like you have 43, so I’m not sure if it’s relevant.)

Worst case scenario I guess you could download CmdStan and unpack it yourself and point cmdstanr to the location using set_cmdstan_path() and then run rebuild_cmdstan().

Thanks! I’ll wait to see if there’s more suggestions and if not then try to do the install manually like you said.

Hi all,

I am having trouble installing cmdstan on Windows using R (4.4.1) and RTools44. I first try the obvious approach and the script can’t unpack the archive.

> cmdstanr::install_cmdstan()
The C++ toolchain required for CmdStan is setup properly!
trying URL 'https://api.github.com/repos/stan-dev/cmdstan/releases/latest'
Content type 'application/json; charset=utf-8' length 16170 bytes (15 KB)
downloaded 15 KB

* Latest CmdStan release is v2.35.0
* Installing CmdStan v2.35.0 in D:\Users\tmeehan/.cmdstan/cmdstan-2.35.0
* Downloading cmdstan-2.35.0.tar.gz from GitHub...
trying URL 'https://github.com/stan-dev/cmdstan/releases/download/v2.35.0/cmdstan-2.35.0.tar.gz'
Content type 'application/octet-stream' length 51682840 bytes (49.3 MB)
downloaded 49.3 MB

* Download complete
* Unpacking archive...
/usr/bin/tar: Cannot connect to D: resolve failed
Error: Problem extracting tarball. Exited with return code: 128

So I tried: " Worst case scenario I guess you could download CmdStan and unpack it yourself and point cmdstanr to the location using set_cmdstan_path() and then run rebuild_cmdstan()"

When unpacking to my HOME directory, I get a warning.

‘’’

set_cmdstan_path(file.path(Sys.getenv(“HOME”), “.cmdstan”))
CmdStan path set to: D:/Users/tmeehan/Documents/.cmdstan
Warning message:
Can’t find CmdStan makefile to detect version number. Path may not point to valid installation.
‘’’

When I try to rebuild I get this:

‘’’

rebuild_cmdstan()
mingw32-make: *** No rule to make target ‘clean-all’. Stop.
mingw32-make: *** No rule to make target ‘build’. Stop.
Warning message:
Can’t find CmdStan makefile to detect version number. Path may not point to valid installation.
‘’’

Incidentally, when I check the toolchain, everything looks OK.

‘’’

check_cmdstan_toolchain(fix = TRUE)
The C++ toolchain required for CmdStan is setup properly!
‘’’

Then I tried the fix from a related thread:

cpp_options ← list(
“CXXFLAGS += -Wno-nonnull”,
“TBB_CXXFLAGS= -U__MSVCRT_VERSION__ -D__MSVCRT_VERSION__=0x0E00”
)

cmdstanr::cmdstan_make_local(cpp_options = cpp_options)
cmdstanr::rebuild_cmdstan()

The second command gives this:

‘’’

cmdstanr::cmdstan_make_local(cpp_options = cpp_options)
Error in file(file, ifelse(append, “a”, “w”)) :
cannot open the connection
In addition: Warning messages:
1: Can’t find CmdStan makefile to detect version number. Path may not point to valid installation.
2: In file(file, ifelse(append, “a”, “w”)) :
cannot open file ‘D:/Users/tmeehan/Documents/.cmdstan/make/local’: No such file or directory
‘’’

and the third gives this:

‘’’

cmdstanr::rebuild_cmdstan()
mingw32-make: *** No rule to make target ‘clean-all’. Stop.
mingw32-make: *** No rule to make target ‘build’. Stop.
Warning message:
Can’t find CmdStan makefile to detect version number. Path may not point to valid installation.
‘’’

Any suggestions for how I can get things configured correctly? Thanks in advance!

When you unpack in HOME, are you placing the contents directly in .cmdstan or is the path something like .cmdstan/cmdstan-2.35.0/? I think that is what the warning is suggesting

1 Like

Brilliant! Thanks for finding my error. So I ran:

set_cmdstan_path(file.path(Sys.getenv("HOME"), ".cmdstan/cmdstan-2.35.0/"))
rebuild_cmdstan()

and things are working now. Thanks again!

2 Likes