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

Simplify windows script #2262

Merged
merged 1 commit into from Apr 19, 2020
Merged

Conversation

reganheath
Copy link
Contributor

@reganheath reganheath commented Apr 18, 2020

setlocal not required as not setting rebarscript
rebarscript not required as we can use %~dpn0 directly
%~dpn0 is (d)irectory, (p)ath and (n)ame of script file, without e(x)tension.

NOTE: On windows, a clean clone of rebar3, bootstrap.bat, rebar3 escriptize, followed by rebar3 ct fails producing a rebar3.crashdump.

It also constantly says
===> Rebar3 detected a lock file from a newer version. It will be loaded in compatibility mode, but important information may be missing or lost. It is recommended to upgrade Rebar3.

Is that normal for master?

edit: corrected (e)xtension -> e(x)tension in description

@ferd
Copy link
Collaborator

ferd commented Apr 19, 2020

  1. Which WIndows version? I do not get that issue on Windows 10 here (or at least I didn't last week).
  2. That message should happen if you're actually building with an older rebar3 than the one you bootstrap; old rebar versions know when they work with an outdated lock file and crash.

This leads me to think you've got an older version somewhere and that explains the crashing you see. This issue happened after compiler changes when the compiler modules themselves changed and older ones were on disk and they kept having problems with internal structures between what's loaded and on disk.

Also as a personal view, %~dpn0 sounds a lot less clear than the existing thing, though I guess I'm not using windows nearly enough to know what's the most idiomatic.

@ferd ferd merged commit aaf5844 into erlang:master Apr 19, 2020
@reganheath reganheath deleted the improve_windows_script branch April 19, 2020 10:04
@reganheath
Copy link
Contributor Author

1. Windows 10. (10.0.18362.0, Microsoft Windows NT 10.0.18362.0)
2. I have rebar3 3.13.1 in my PATH.. ahh, I see what's happening. clone and bootstrap work fine, producing rebar3 and rebar.cmd. But..

PS C:\Development\Erlang\tmp\rebar3> rebar3 version                                                                                   ===> Rebar3 detected a lock file from a newer version. It will be loaded in compatibility mode, but important information may be missing or lost. It is recommended to upgrade Rebar3.
rebar 3.13.1 on Erlang/OTP 21 Erts 10.2

This is a powershell thing. If you want to run a local script you need .\ on the front, otherwise it prefers one from PATH.

PS C:\Development\Erlang\tmp\rebar3> .\rebar3.cmd version                                                                             rebar 3.14.0-rc1+build.4594.refaaf5844 on Erlang/OTP 21 Erts 10.2

So, the rebar3 ct I run uses the older one from PATH, not the local script.
If I run it as .\rebar3.cmd ct it works fine.

@reganheath
Copy link
Contributor Author

reganheath commented Apr 19, 2020

Also as a personal view, %~dpn0 sounds a lot less clear than the existing thing, though I guess I'm not using windows nearly enough to know what's the most idiomatic.

I think it depends on whether you're familiar with the string replace syntax that was there previously, or the options available on variable expansion (~%dpnx etc). Once you learn of the latter, you find yourself using them everywhere and they become 2nd nature (in my experience).

The best reference I've ever found (if you bookmark nothing else, bookmark this :P)
https://www.robvanderwoude.com/battech.php

This page covers this in particular:
https://www.robvanderwoude.com/ntcall.php

@reganheath
Copy link
Contributor Author

Leaving this here as others might find it useful.

If you add the following to your powershell profile (notepad $profile to edit it)

# Alias to ensure we run the correct rebar3
Set-Alias -name rebar3 -value RunRebar3

# Run any local rebar3.cmd in preference to the one in the path
function RunRebar3
{
    if (test-path .\rebar3.cmd) {
        .\rebar3.cmd $args
    }
    else {
        rebar3.cmd $args
    }
}

then you will avoid the issue I had of not running the rebar3 I had just built.

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

Successfully merging this pull request may close these issues.

None yet

2 participants