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

os module uses wrong path separator in nimvm when cross-compiling #23877

Open
nocturn9x opened this issue Jul 22, 2024 · 2 comments
Open

os module uses wrong path separator in nimvm when cross-compiling #23877

nocturn9x opened this issue Jul 22, 2024 · 2 comments

Comments

@nocturn9x
Copy link

nocturn9x commented Jul 22, 2024

Description

The VM used for compile time evaluation does not appear to be using hostOS to pick which path style to use in functions like joinPath() (possibly targetOS is being used?). This is a problem I encountered while trying to cross compile my project for Windows while being on Linux: part of the code tries to statically read the contents of two JSON files into two consts and fails because the path is incorrect

import os


func buildPath: string {.compileTime.} =
    result = joinPath(currentSourcePath().parentDir(), "resources")

const x = buildPath()
echo x

Nim Version

Nim Compiler Version 2.0.4 [Linux: amd64]
Compiled at 2024-03-28
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: b47747d
active boot switches: -d:release

Current Output

\home\nocturn9x\heimdall\resources

Expected Output

/home/nocturn9x/heimdall/resources

Possible Solution

The nim compile time evaluator should use hostOS for picking the path separator to use

Additional Information

No response

@demotomohiro
Copy link
Contributor

Related issues:
#21534
#19558

A path created at compile time can be used at both compile time and run time.
I have created new path library to workaround this issue: https://github.com/demotomohiro/pathX

@juancarlospaco
Copy link
Collaborator

Add a mention to the lib in the docs? 🤔

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

3 participants