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

Windows: ODIN_ROOT environment variable incompatible with output of odin root #4728

Open
karl-zylinski opened this issue Jan 20, 2025 · 4 comments

Comments

@karl-zylinski
Copy link
Contributor

karl-zylinski commented Jan 20, 2025

Context

    Odin:    dev-2025-01:1613728a6
    OS:      Windows 10 Professional (version: 22H2), build 19045.5371
    CPU:     Intel(R) Core(TM) i7-6950X CPU @ 3.00GHz
    RAM:     32674 MiB
    Backend: LLVM 18.1.8

Expected Behavior

Putting this in .bat file should produce a valid value for ODIN_ROOT:

for /f "delims=" %%i in ('odin.exe root') do set "ODIN_ROOT=%%i"

Current Behavior

If you run odin compiler after doing the above, then:

Error:

Invalid ODIN_ROOT, directory does not exist, got c:\SDK\Odin\

Odin compiler uses ODIN_ROOT, but it only works if there is no slash at the end. But slash at the end is how odin root writes it! So if you set ODIN_ROOT equals to the value of odin root then your environment is broken until you restart cmd.exe or similar.

Failure Information (for bugs)

Build a hellope program using this batch script:

@echo off

for /f "delims=" %%i in ('odin.exe root') do set "ODIN_ROOT=%%i"

rem Useful for stuff like this:
rem copy "%ODIN_ROOT%\core\sys\wasm\js\odin.js" "odin.js"

odin build .
@laytan
Copy link
Collaborator

laytan commented Jan 20, 2025

I think there's a bit of a misunderstanding how it works here. What you do here doesn't make much sense to do. ODIN_ROOT is used to overwrite the default path. if you want Odin to use the output of odin root as the root, you don't set ODIN_ROOT (because it's evidently already the right path).

Doing ODIN_ROOT=$(odin root) means you are basically saying set ODIN_ROOT to what is already the root.

That being said, we should allow the ODIN_ROOT environment variable to have a slash or not have one.

@karl-zylinski
Copy link
Contributor Author

@laytan I've seen build scripts from a few people that do this. ODIN_ROOT is a common variable name to choose in a batch script, since the command is odin root, so you just turned the command into screaming snake case. One can do this without being aware of what ODIN_ROOT is for, but then the compiler is for very unclear reasons suddenly broken.

@laytan
Copy link
Collaborator

laytan commented Jan 20, 2025

Right, it is a natural name to assign to, indeed.

@laytan
Copy link
Collaborator

laytan commented Jan 20, 2025

I even did it myself in the wgpu example :p , but my lack of experience with batch/Powershell meant I didn't know that would automatically be an environment variable.

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

2 participants