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

Running opam env in non-cygwin bash on windows adds /cygdrive prefixes to each entry of PATH #6310

Open
gridbugs opened this issue Nov 25, 2024 · 2 comments

Comments

@gridbugs
Copy link
Contributor

I use git bash (inside the "Terminal" program) as my shell when developing ocaml on windows. Here's the output of opam env from a project with a local opam switchh;

$ opam env
OPAM_LAST_ENV='C:\Users\s\AppData\Local\opam\.last-env\env-49af62de39bcff8e1e427bfedbcf0f3f-0'; export OPAM_LAST_ENV;
OPAM_SWITCH_PREFIX='C:\Users\s\src\dune\_opam'; export OPAM_SWITCH_PREFIX;
CAML_LD_LIBRARY_PATH='C:\Users\s\src\dune\_opam\lib\stublibs;C:\Users\s\src\dune\_opam\lib\ocaml\stublibs;C:\Users\s\src\dune\_opam\lib\ocaml'; export CAML_LD_LIBRARY_PATH;
OCAML_TOPLEVEL_PATH='C:\Users\s\src\dune\_opam\lib\toplevel'; export OCAML_TOPLEVEL_PATH;
MANPATH='C:\Program Files\Git\mingw64\local\man;C:\Program Files\Git\mingw64\share\man;C:\Program Files\Git\usr\local\man;C:\Program Files\Git\usr\share\man;C:\Program Files\Git\usr\man;C:\Program Files\Git\share\man:/cygdrive/c/Users/s/src/dune/_opam/man'; export MANPATH;
PATH='/cygdrive/c/Users/s/src/dune/_opam/bin:/usr/x86_64-w64-mingw32/sys-root/mingw/bin:/cygdrive/c/Users/s/bin:/cygdrive/c/Users/s/.cargo/bin:/cygdrive/c/Users/s/.conda/bin:/cygdrive/c/Users/s/.bin:/cygdrive/c/Users/s/.local/bin:/cygdrive/c/Users/s/.local/sbin:/cygdrive/c/Program Files/Git/usr/games:/cygdrive/c/Program Files/Git/usr/local/games:/cygdrive/c/Users/s/bin:/cygdrive/c/Program Files/Git/mingw64/bin:/cygdrive/c/Program Files/Git/usr/local/bin:/cygdrive/c/Program Files/Git/usr/bin:/cygdrive/c/Program Files/Git/usr/bin:/cygdrive/c/Program Files/Git/mingw64/bin:/cygdrive/c/Program Files/Git/usr/bin:/cygdrive/c/Users/s/bin:/cygdrive/c/windows/system32:/cygdrive/c/windows:/cygdrive/c/windows/System32/Wbem:/cygdrive/c/windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/windows/System32/OpenSSH:/cygdrive/c/Program Files/Git/cmd:/cygdrive/c/Program Files/Neovim/bin:/cygdrive/c/Program Files/PowerShell/7:/cygdrive/c/Users/s/.cargo/bin:/cygdrive/c/Users/s/AppData/Local/Programs/opam/bin:/cygdrive/c/Users/s/AppData/Local/Microsoft/WindowsApps:/cygdrive/c/Users/s/AppData/Local/Microsoft/WinGet/Packages/junegunn.fzf_Microsoft.Winget.Source_8wekyb3d8bbwe:/cygdrive/c/Users/s/AppData/Local/Programs/Microsoft VS Code/bin:/cygdrive/c/Users/s/AppData/Local/Microsoft/WinGet/Packages/direnv.direnv_Microsoft.Winget.Source_8wekyb3d8bbwe:/cygdrive/c/Program Files/Git/usr/bin/vendor_perl:/cygdrive/c/Program Files/Git/usr/bin/core_perl'; export PATH;

Note that each element of PATH has /cygdrive prefixed to it despite not being in a cygwin environment. Fortunately there's an easy workaround: I run eval $(opam env | sed 's/\/cygdrive//g') to set up my environment instead.

My opam config report:

$ opam config report
# opam config report
# opam-version         2.3.0
# self-upgrade         no
# system               arch=x86_64 os=win32 os-distribution=cygwin os-version=10.0.22621
# solver               builtin-mccs+glpk
# install-criteria     -removed,-count[avoid-version,changed],-count[version-lag,request],-count[version-lag,changed],-count[missing-depexts,changed],-changed
# upgrade-criteria     -removed,-count[avoid-version,changed],-count[version-lag,solution],-count[missing-depexts,changed],-new
# jobs                 7
# repositories         1 (http) (default repo at 232a37e8b008dc04381f5e98c16badfc02ea6962)
# pinned               0
# current-switch       C:\Users\s\src\dune
# invariant            ["ocaml-base-compiler" {= "5.1.1"} | "ocaml-system" {= "5.1.1"}]
# compiler-packages    arch-x86_64.1, conf-mingw-w64-gcc-x86_64.1, flexdll.0.43, mingw-w64-shims.0.2.0, ocaml-base-compiler.5.1.1, ocaml-env-mingw64.1, ocaml-options-vanilla.1, system-mingw.1
# mingw-w64-shims:runtime-x86_64 C:\Users\s\AppData\Local\opam\.cygwin\root\usr\x86_64-w64-mingw32\sys-root\mingw\bin
# mingw-w64-shims:runtime-i686
# ocaml:native         true
# ocaml:native-tools   true
# ocaml:native-dynlink true
# ocaml:stubsdir       C:/Users/s/src/dune/_opam/lib/ocaml/stublibs;C:/Users/s/src/dune/_opam/lib/ocaml
# ocaml:preinstalled   false
# ocaml:compiler       5.1.1
@dra27
Copy link
Member

dra27 commented Nov 25, 2024

I think this is a duplicate of #6134 (although I still need to finish off the idea I'd had)

@dra27
Copy link
Member

dra27 commented Nov 25, 2024

The core issue is that opam env uses cygpath from the internal installation, but in this case it should be cygpath resolved in PATH (which would cause it to give /c/Users instead of /cygpath/c/Users)

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