Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dhall cannot parse Windows absolute path #151

Open
to-omer opened this issue May 24, 2022 · 1 comment
Open

Dhall cannot parse Windows absolute path #151

to-omer opened this issue May 24, 2022 · 1 comment

Comments

@to-omer
Copy link

to-omer commented May 24, 2022

状況

$ snowchains r t
Error: Could not evalute `C:\Users\path-to-config\snowchains.dhall`

Caused by:
     --> 3:15
      |
    3 | let config = C:\Users\path-to-config\snowchains.dhall␊
      |               ^---
      |
      = expected import_alt, bool_or, natural_plus, text_append, list_append, bool_and, natural_times, bool_eq, bool_ne, combine, combine_types, equivalent, prefer, arrow, or let_binding

発生個所

snowchains/src/config.rs

Lines 173 to 185 in d65d411

serde_dhall::from_str(&format!(
r"let relativePathSegments = {}
let config = {}
in {{ service = config.detectServiceFromRelativePathSegments relativePathSegments
, contest = config.detectContestFromRelativePathSegments relativePathSegments
, problem = config.detectProblemFromRelativePathSegments relativePathSegments
, language = config.detectLanguageFromRelativePathSegments relativePathSegments
}}
",
rel_path_components, path,
))

@to-omer
Copy link
Author

to-omer commented May 25, 2022

snowchains/src/config.rs

Lines 96 to 127 in d65d411

fn find_snowchains_dhall(cwd: &Path, rel_path: Option<&Path>) -> anyhow::Result<String> {
let path = if let Some(rel_path) = rel_path {
let rel_path = rel_path.strip_prefix(".").unwrap_or(rel_path);
let path = cwd.join(rel_path);
ensure!(path.exists(), "`{}` does not exist", path.display());
path
} else {
cwd.ancestors()
.map(|p| p.join("snowchains.dhall"))
.find(|p| p.exists())
.with_context(|| {
format!(
"Could not find `snowchains.dhall` in `{}` or any parent directory",
cwd.display(),
)
})?
};
let path = path
.into_os_string()
.into_string()
.map_err(|path| anyhow!("The config path must be valid UTF-8: {:?}", path))?;
if path.chars().any(|c| c.is_whitespace() || c.is_control()) {
bail!(
"The config path must not contain whitespace and control characters: {:?}",
path,
);
}
Ok(path)
}

ここで相対パスにして replace('\\', "/") をすると回避はできそうです

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant