I heard from someone that they had to do the special instructions to install the custom make in Rtools on Windows to get cmdstanr working. Is this still the case? If so can we add those directions to https://mc-stan.org/cmdstanr/ ?
Did they do it recently (last month or so)?
current requirements for Windows are:
Install cmdstan will let you know if anything is not setup correctly. You can also run check_cmdstan_toolchain() before that, though that is called inside install_cmdstan()
We can automatically do the following:
What we still currently have no automatic workaround for is:
Ooo, okay, thanks for the feedback I'll try to clarify what happened.
The version should be 0.2+ and you will have that features.
@rok-cesnovar Have you ever heard of something like this:
INFO: Could not find files for the given pattern(s).
cp bin/windows-stanc bin/stanc.exe
When someone runs:
install_cmdstan(overwrite = TRUE)
This is just a warning from the cmdstan makefiles. We should clean it (I thought I cleaned up all of them). But it should not cause problems.
Please make a cmdstan issue, else we will forget.
Its also not related to the line below.
the path where cmdstan is installed is too long (less rare but rare)
Windows has a possibility to use the inner path, which is always short + doesn't have any spaces.
Also there is a trick to add specific chars before the path which causes Windows to ignore long path checks. We use these in CmdStanPy
Can you link me to what you use. I was wondering how we could use the old DOS-style short paths like "C:\Prog~1" but never found a way (didnt look hard enough I guess).
We use this in CmdStanPy
def windows_short_path(path: str) -> str:
"""
Gets the short path name of a given long path.
http://stackoverflow.com/a/23598461/200291
On non-Windows platforms, returns the path
If (base)path does not exist, function raises RuntimeError
"""
if platform.system() != 'Windows':
return path
if os.path.isfile(path) or (
not os.path.isdir(path) and os.path.splitext(path)[1] != ''
):
base_path, file_name = os.path.split(path)
else:
base_path, file_name = path, ''
if not os.path.exists(base_path):
raise RuntimeError(
'Windows short path function needs a valid directory. '
'Base directory does not exist: "{}"'.format(base_path)
)
import ctypes
from ctypes import wintypes
# pylint: disable=invalid-name
_GetShortPathNameW = ctypes.windll.kernel32.GetShortPathNameW
_GetShortPathNameW.argtypes = [
wintypes.LPCWSTR,
wintypes.LPWSTR,
wintypes.DWORD,
]
_GetShortPathNameW.restype = wintypes.DWORD
output_buf_size = 0
while True:
output_buf = ctypes.create_unicode_buffer(output_buf_size)
needed = _GetShortPathNameW(base_path, output_buf, output_buf_size)
if output_buf_size >= needed:
short_base_path = output_buf.value
break
else:
output_buf_size = needed
short_path = (
os.path.join(short_base_path, file_name)
if file_name
else short_base_path
)
return short_path
And in installing we add this \\?\
if platform.system() == 'Windows':
# fixes long-path limitation on Windows
target = r'\\?\{}'.format(target)
r"" <-- raw string so we don't need to escape each \
You could probably use this
https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/shortPathName
Most helpful comment
Ooo, okay, thanks for the feedback I'll try to clarify what happened.