Skip to content

as_cmdstan_fit fails for paths using tilde expansion #796

Open
@ksvanhorn

Description

@ksvanhorn

Describe the bug
If a CSV file path starts with "~", indicating tilde expansion, cmdstanr::as_cmdstan_fit() gives an error saying the file does not exist, and (in contradiction of the previous) that the CSV file is corrupted.

To Reproduce
cmdstanr::as_cmdstan_fit(file_paths) where file_paths contains any path starting with "~/".

Expected behavior
I expect the normal tilde expansion to happen.

Operating system
macOS Ventura 13.4

CmdStanR version number
0.5.3

Additional context
Stepping through this in the debugger, the problem occurs within the function read_csv_metadata(), which calls data.table::fread(cmd = fread_cmd, ...), where fread_cmd was defined as

fread_cmd <- paste0(grep_path_quotes, " \"^[#a-zA-Z]\" --color=never \"", 
            csv_file, "\"")

The quotes placed around the file path in csv_file inhibit tilde expansion when the shell executes the command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions