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

Win32 opam damages PATH environment variable #3599

Closed
db4 opened this issue Oct 11, 2018 · 5 comments
Closed

Win32 opam damages PATH environment variable #3599

db4 opened this issue Oct 11, 2018 · 5 comments

Comments

@db4
Copy link

db4 commented Oct 11, 2018

# opam config report
# opam-version      2.0.0
# self-upgrade      no
# system            arch=x86_64 os=win32 os-distribution=win32 os-version=10.0.17134
[ERROR] No switch is currently set. Please use 'opam switch' to set or install a switch
# read-state        OpamStd.OpamSys.Exit(50)

When building a switch with opam create switch Win32 opam.exe (but not the Linux one) reverses list order in the system PATH variable. That leads to many problems. Would be great to fix.

@rjbou
Copy link
Collaborator

rjbou commented Oct 17, 2018

it seems that you have a problem with your opam installation. No switch is set and the config report errors. Can you check the output of opam env, it should at least contains the OPAM_SWITCH_PREFIX.

On windows, opam doesn't perform any specific operation except forcing uppercase naming.
@dra27, do you confirm?

@db4
Copy link
Author

db4 commented Oct 17, 2018

it seems that you have a problem with your opam installation. No switch is set and the config report errors.

Of course it is not set: I'm trying to add the very first switch after

opam init local <private repo address> --bare --no-setup

When building OCaml compiler I see that opam reverses directory order in system PATH and it breaks the build. That's why I filed the issue.

On windows, opam doesn't perform any specific operation except forcing uppercase naming.

Not exactly:

opam/src/core/opamStd.ml

Lines 596 to 617 in f2e8e6d

let split_path_variable ?(clean=true) =
if Sys.win32 then fun path ->
let length = String.length path in
let rec f acc index current last normal =
if index = length
then let current = current ^ String.sub path last (index - last) in
if current <> "" then current::acc else acc
else let c = path.[index]
and next = succ index in
if c = ';' && normal || c = '"' then
let current = current ^ String.sub path last (index - last) in
if c = '"' then
f acc next current next (not normal)
else
let acc = if current = "" then acc else current::acc in
f acc next "" next true
else
f acc next current last normal in
f [] 0 "" 0 true
else fun path ->
let split = if clean then OpamString.split else OpamString.split_delim in
split path path_sep
At first sight the bug is here.

@dra27
Copy link
Member

dra27 commented Oct 17, 2018

Windows opam doesn’t yet work...

@dra27
Copy link
Member

dra27 commented Oct 17, 2018

You are correct about the bug - it’s already part of #3348

@db4
Copy link
Author

db4 commented Oct 17, 2018

Windows opam doesn’t yet work...

It's unfortunate. For the time being I use Andreas Hauptmann's opam mingw binary. I'm quite happy with it but once OPAM main repository switched to format 2.0, upgrade of opam binary is inevitable as well. How far is windows opam from being functional? What does and what doesn't work currently?

@AltGr AltGr closed this as completed Jul 22, 2019
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

4 participants