Archive: NSIS 3.0a0


NSIS 3.0a0
Yep. It's finally here.

Get your download at the usual place:

http://nsis.sourceforge.net/Download

Among many bug fixes and new features, the biggest one is probably Jim Park's Unicode. Wizou and Anders have merged it back to the main version and it's now available as an optional Unicode true command. So thank you Jim, thank you Wizou for merging it back in and thank you Anders for wrapping it all up and making sure NSIS 3 happens.

Next on plan is fixing whatever we broke (like linux build) and x64 by David Golub (partially already available in SVN and on David's BitBucket).

Please let us know of any broken parts of loose screws :)

P.S.

Check out our Twitter feed by Yathosho.


Absolutely awesome! Many thanks to the NSIS team for putting in so many hours, and congratulations for reaching this important milestone. I'm hoping to go play with it soon!


Awesoooooooooome!!!

Quick question for plug-ins: all old plug-ins are now automatically treated as x86, aren't they?

Second question: Is .chm manual working for you correctly?


I'm an eternal optimist but I admit I was worried we'd seen the last major build, as the project really seemed to be losing momentum. I love NSIS, this is frelling great news! Thank you devs for all your work! :up:


Cool, thanks! :)

I have just quickly tried 3.0a0, and a simple project compiled, but another, somewhat larger one wouldn't because !searchparse and !searchreplace failed. I then reinstalled 2.46, and then the project compiles just fine, so it would seem !searchparse and !searchreplace are broken.

!searchparse error:

!searchparse: starting string "#define VERSIONINFO_VERSION    " not found in file!


Failing NSIS source code line:
!searchparse /file ../resource.h '#define VERSIONINFO_VERSION    ' VER_MAJR ',' VER_MN ',' VER_BG ','


Relevant line from ../resource.h:
#define VERSIONINFO_VERSION    1,3,0,0 // 1.3.0


!searchreplace error:
Usage: !searchreplace [/ignorecase] output_name source_string substring replacestring


Failing NSIS source code line:
!searchreplace VER_FN "${VER_STR}" "." ""

Originally posted by T.Slappy
Quick question for plug-ins: all old plug-ins are now automatically treated as x86, aren't they?
If you mean Ansi vs Unicode then yes, everything starts out as Ansi but NSIS\Plugins\*.dll is not searched anymore, you would have to move them into the correct subdirectory...

Originally posted by T.Slappy
Second question: Is .chm manual working for you correctly?
What do you mean?


Originally posted by TaleTN
I have just quickly tried 3.0a0, and a simple project compiled, but another, somewhat larger one wouldn't because !searchparse and !searchreplace failed. I then reinstalled 2.46, and then the project compiles just fine, so it would seem !searchparse and !searchreplace are broken.
They are stricter in what they accept but it is of course possible that there is a bug in the new code.

Hmm I cannot edit my previous post so I am adding found issues here, most of them are from manual:

UnsafeStrCpy command is not documented (however I suppose the same behaviour as StrCpy)

The 'new' ReserveFile explanation is very vague:

Plugins in ${NSISDIR}\Plugins have to be reserved with ReserveFile /plugin
Maybe it is better to say "use /plugin switch anytime you use ReserveFile for reserving the .dll file".
Also plug-ins are now stored in ${NSISDIR}\Plugins\<architecture>-<Charset> so this may be confusing for users.

And again thanks for the great work!

Great work!

Maybe it is a good idea to copy already installed plugin's from a NSIS 2.x installation to the new plugin location (at least the ansi plugin's) in the NSIS installer?

jpderuiter


Originally posted by Anders
They are stricter in what they accept but it is of course possible that there is a bug in the new code.
Then I guess there is a bug in the !searchparse code, because I have this very simple text file (meh.h):

#define APP_VERSION 1,2,3
#define LONG_VERSION 1,2,3,4


Which I fails to parse correctly with this equally simple NSIS script:

!searchparse /file meh.h `#define APP_VERSION ` VER_MAJOR `,` VER_MINOR `,`
# Bug: Found "#define APP_VERSION 1,2,", so VER_MAJOR should be "1" and
# VER_MINOR "2". However, VER_MINOR is "2,3".

!searchparse /file meh.h `#define LONG_VERSION ` LONG_MAJOR `,` LONG_MINOR `,` LONG_BG `,`
# Bug: Should have found "#define LONG_VERSION 1,2,3,", but instead says
# "#define LONG_VERSION " not found.

Name "meh ${VER_MAJOR}.${VER_MINOR} (${LONG_MAJOR}.${LONG_MINOR}.${LONG_BG})"
OutFile "meh.exe"
Section
SectionEnd

didn't think i'd live to see this, good job everybody!

i'm glad that the anchors for commands in the html help finally changed from chapters to something more readable. would've been better though to use the literal command names - #StrCpy rather than #strcpy, #!ifdef rather than #if. i can think of several scenarios where this could be come useful, for instance a command lookup from an editor.


Great work!!!!!!!!!!!!!!!!

Maybe able to upgrade LZMA(LZMA2)?


Originally posted by jiake
Maybe able to upgrade LZMA(LZMA2)?
there has been a discussion about that

Originally posted by Yathosho
there has been a discussion about that
Thank you.
Compression code does look outdated.

I think I fixed searchparse

Originally posted by TaleTN
!searchreplace error:
Usage: !searchreplace [/ignorecase] output_name source_string substring replacestring


Failing NSIS source code line:
!searchreplace VER_FN "${VER_STR}" "." ""


!define VER_STR a.b.c.d
!searchreplace VER_FN "${VER_STR}" "." ""
!warning "|${VER_FN}|"

gives me:

!searchreplace: "VER_FN"="abcd"
warning: !warning: |abcd| (test.nsi:22)

so you need to provide a full example that actually fails for me to fix this

Very much appreciated folks, keep up the good work!


Originally Posted by Anders (Post 2935419) so you need to provide a full example that actually fails for me to fix this
Here you go:

meh.h:
#define VERSIONINFO_STR "1.3.0"


meh.nsi:
# Sets VER_STR to "1.3.0".
!searchparse /file meh.h '#define VERSIONINFO_STR "' VER_STR '"'

# VER_FN should be "130", but returns usage error instead.
!searchreplace VER_FN "${VER_STR}" "." ""

Name "meh"
OutFile "meh.exe"
Section
SectionEnd

After a short work with NSIS 3 I noticed my favourite feature is still not implemented:


Var /GLOBAL myVariable "initial value"


I think this is often used: "initial value" could be optional parameter.

Originally posted by T.Slappy
After a short work with NSIS 3 I noticed my favourite feature is still not implemented:
Var /GLOBAL myVariable "initial value"

I think this is often used: "initial value" could be optional parameter.
I believe there is a feature request for Var Foo, Bar, Baz but I don't think we found a good syntax to express this, /GLOBAL makes things confusing etc.

Setting an initial value is probably not going to happen, NSIS currently uses a PE section trick to allocate the variables with no code at runtime. If you want this feature so bad you can just use a macro in .onInit...

Congrats on finally moving up to version 3 alpha!


Very good to have it all in one place. I like also the streamlining since 2.46. Math.dll -- much smaller. Thanks. :)

I found a minor problem. (I hope minor.)

${NSIS_CHAR_SIZE} is always 1.

So,

!if"${NSIS_CHAR_SIZE}"=2

Unicodetrue
!endif
does not work.

Originally posted by TaleTN
Here you go:
With !searchparse fixed I get 130 as the result...

Originally posted by bnicer
${NSIS_CHAR_SIZE} is always 1.
This is by design, ${NSIS_CHAR_SIZE} is mainly for code that interacts with the system plugin. ${NSIS_CHAR_SIZE} changes after "Unicode true"...

Originally posted by Anders
With !searchparse fixed I get 130 as the result...
Yay, great! :up: I guess there was nothing wrong with !searchreplace then, but it was also caused by a bug in !searchparse?

Quote:


there's always a warning when a script contains ${NSIS_VERSION}, i guess it doesn't like the "a" in v3.0a0


Originally posted by Yathosho
there's always a warning when a script contains ${NSIS_VERSION}, i guess it doesn't like the "a" in v3.0a0
Please post code examples and compiler warnings when reporting issues...

Originally posted by Anders
Please post code examples and compiler warnings when reporting issues...
!if ${NSIS_VERSION} < "v3.0"
!endif


will produce

1 warning:
Invalid number: "v3.0a0" (C:\Users\jan\Desktop\test.nsi:1)

That warning is because it can't parse "v3.0a0" (or "v3.0") as an integer because it isn't.

Stu


Originally posted by Yathosho
!if ${NSIS_VERSION} < "v3.0"
!endif
Like Afrow UK said, it gives you a warning because it failed to parse the input as a number. The warning is new but it will fail to parse under 2.46 as well.

Originally Posted by 2.46 fails this !undef NSIS_VERSION
!define NSIS_VERSION "v3.0" ;a0"
!if ${NSIS_VERSION} < v4.0
!warning "${NSIS_VERSION} <"
!else
!warning "${NSIS_VERSION} >="
!endif
You probably want something like:
!if "${NSIS_PACKEDVERSION}" > 0x2046000
Unicode True
!else
!if "${NSIS_CHAR_SIZE}" < 2 ; This takes care of the Unicode fork?
!warning "Unicode not supported, creating ANSI installer"
!endif
!endif

When comparing NSIS_PACKEDVERSION you should check against the last version that did not have the feature you are after, if you do it this way you should be compatible all the way back to v2.15. If you do it the other way with !if ${NSIS_PACKEDVERSION} >= 0x3000000 it will be parsed as 0 >= 0 (true) on older versions!

It is important to note that unofficial svn builds might not set NSIS_VERSION nor NSIS_PACKEDVERSION at all.


Quote:

${NSIS_CHAR_SIZE} changes after "Unicode true"... I should have tried it first. It isn't a problem, only different. Thanks.

!if 0x2046000 >= "${NSIS_PACKEDVERSION}"
!error "You need NSISv3+"
!endif
;Or
!if ! "${NSIS_PACKEDVERSION}" > 0x2046000
!error "You need NSISv3+"
!endif I'm not sure what the fork will do in the future, you might even want to use !if ! "${NSIS_PACKEDVERSION}" > 0x2999999

The format of NSIS_VERSION was never set in stone, v3.4.5 would be a legal version and there can be a letter or word suffix etc...

Respected developers!
Please, make possibility of translation of the text for "NSIS Error".
It always in English.... Add opportunity to change the text of this error.
thanks.

http://i48.tinypic.com/2vljpc8.png


Originally posted by Redo89
Please, make possibility of translation of the text for "NSIS Error".
It always in English.... Add opportunity to change the text of this error.
thanks.
This has been asked before, this string is used before translations have been loaded. If you want to change the string, use a hex editor...

what file to edit hex editor? the compiled installer? It will cause CRC error!
I don't want to disable CRC check

And you are right, about this problem many times wrote. I don't understand why developers can't add opportunity to change this message...

Sorry for bad English!


in need some advice on how to best debug an installer generated with this alpha version. i have one installer that produces problems: it compiles, but upon running it crashes with no error message whatsoever. i commented out all used plugins (MoreInfo, System and ToolTips) and even the custom UI it uses - no success. a look at process monitor shows a couple of errors/warnings (NAME COLLISION, FILE LOCKED WITH ONLY READERS, FAST IO DISALLOWED and BUFFER OVERFLOW). the installer quits with error code -1073741819 (and google doesn't know about that). i checked with the last working version and it produces the same results in process monitor, but the installer works as desired.


Originally posted by Yathosho
in need some advice on how to best debug an installer generated with this alpha version. i have one installer that produces problems: it compiles, but upon running it crashes with no error message whatsoever. i commented out all used plugins (MoreInfo, System and ToolTips) and even the custom UI it uses - no success. a look at process monitor shows a couple of errors/warnings (NAME COLLISION, FILE LOCKED WITH ONLY READERS, FAST IO DISALLOWED and BUFFER OVERFLOW). the installer quits with error code -1073741819 (and google doesn't know about that). i checked with the last working version and it produces the same results in process monitor, but the installer works as desired.
Can you create a minimal sample with the same issue? Does MessageBox in .onInit work? Unicode/Ansi?

Originally posted by Anders
Can you create a minimal sample with the same issue? Does MessageBox in .onInit work? Unicode/Ansi?
okay, thanks to your advise i could narrow down the problem

1. it works when i compile an ansi version

2. when i compile a unicode version, this segment is causing the problem:
        ${If} ${AtLeastWin2000}
StrCpy "$settingsINI" "$APPDATA\RunWithParameters\settings.ini"
StrCpy "$historyINI" "$APPDATA\RunWithParameters\history.ini"
StrCpy "$defaultsINI" "$APPDATA\RunWithParameters\defaults.ini"
IfFileExists "$APPDATA\RunWithParameters\mydefaults.ini" 0 +2
StrCpy "$mydefaultsINI" "$APPDATA\RunWithParameters\mydefaults.ini"
${ElseIf} ${AtMostWinME}
StrCpy "$settingsINI" "$EXEDIR\settings.ini"
StrCpy "$historyINI" "$EXEDIR\history.ini"
StrCpy "$defaultsINI" "$EXEDIR\defaults.ini"
IfFileExists "$EXEDIR\mydefaults.ini" 0 +2
StrCpy "$mydefaultsINI" "$EXEDIR\mydefaults.ini"
${EndIf}

Originally posted by Yathosho
2. when i compile a unicode version, this segment is causing the problem:
Does not crash for me (tested in a section), please provide a full .nsi

As far as the code goes, what about NT4?

Originally posted by Anders
Does not crash for me (tested in a section), please provide a full .nsi
see attachment, should include everything to compile

Originally posted by Anders
As far as the code goes, what about NT4?
good point, thanks

Originally posted by Yathosho
see attachment, should include everything to compile
My guess is that the crash is in nsArray, please provide sample code that does not use 3rd-party plugins if you want me to investigate further...

Originally posted by Anders
My guess is that the crash is in nsArray, please provide sample code that does not use 3rd-party plugins if you want me to investigate further...
as i said before, i already tried and commented out all plugins and the ui - to no success

By using Messageboxes you can narrow it down to the ForEachIn loop in line 318.

I don't know nsArray, but are you allowed to use StrCpy with it (line 304, 310 and 314)?


Archive: NSIS 3.0a0


i'm getting the same problem with this simple script

; Settings ---------------------------------
OutFile "installer_name.exe"
RequestExecutionLevel user
Unicode true
!include LogicLib.nsh
!include WinVer.nsh
; Pages ------------------------------------
Page instfiles
; Sections ---------------------------------
Section "section_name"
Quit
SectionEnd
; Functions --------------------------------
Function .onInit
${If} ${AtLeastWin2000}
MessageBox MB_OK "${__LINE__}"
${EndIf}
FunctionEnd


seems only to happen on my main windows installation (windows 7 with all patches). works just fine in a vm with windows 2003, on virtualized windows 7 i get as far as the messagebox before the program terminates with an error message (see attachment).

As said in my previous post, I get a crash on your script with nsArray, which you are mixing with StrCpy.

For the Kernelbase.dll error:
http://answers.microsoft.com/en-us/w...c-51ed8d70f749


Working on the crash now. It appears to be coming from nsArray.

Originally posted by jpderuiter
I don't know nsArray, but are you allowed to use StrCpy with it (line 304, 310 and 314)?
I very much doubt that this would cause a crash - the value passed to the plug-in at run time should be no different when passing it via a variable or a hard coded string.

Stu

Originally posted by jpderuiter
As said in my previous post, I get a crash on your script with nsArray, which you are mixing with StrCpy
the executable runs fine when i comment out the first if-statement in onInit, also the ansi version never caused any problems.

i think the bug is caused by WinVer.nsh. when i comment its line 197, my compiled executable does not crash. this is the line:
System::Call kernel32::GetVersionEx(pr0)i.r3

The last example doesn't crash for me either. Can you maybe attach the compiled installer too?


...


Sorry, my crashes happen because I commented out onGUIInit, because I wanted to test it without parameters.

Yatosho, does your script crash when using /help as parameter?


Fixed the memory access violation in nsArray which occurred in the ForEachIn loop (nsArray::Iterate). I tested by running with /install and then running subsequent debugging executions with the default INI file as an argument. I don't get any crashes now.

Edit: I should mention the crash came about because an invalid array name is being used in your ForEachIn loop - it resulted in a NULL pointer in the plug-in and subsequent violation where validation was missing. This should not be an issue now.

Stu


Originally posted by jpderuiter
The last example doesn't crash for me either. Can you maybe attach the compiled installer too?
attached

Yatosho, does your script crash when using /help as parameter?[/QUOTE]

yes

ok, i did some more testing as getting different results on different windows installations seemed strange. computer is virus free, so i renamed my old nsis directory (i installed nsis 3 over nsis 2) and did a clean install of 3.0a. now everything compiles and runs fine. still find it a bit weird (ANSI worked, WinVer seems to have caused this), but for me it's sorted. thanks for all advice.


I had problem with an installer, where ANSI worked as opposed to UNICODE, that was caused by WinVer. The installer didn't crash, but the ${If} ${AtLeastWin'X'} conditions failed, UNICODE. Though, unlike in Yathosho's example, my script had a mistake. I was including WinVer.nsh before I declared Unicode true/false.

I thought of posting this earlier in response to Yathosho, but it didn't seem related. Maybe it is (worth looking into)? If the Unicode true declaration comes after an included file, a compiler error message would be in order, even though it's an avoidable mistake. I wonder as well if it should be necessary to declare Unicode when the script file is encoded in UNICODE. Make Unicode an optional command?


Thanks Yathosho and bnicer for tracking this down.

The compiler should abort if you use a plugin before switching unicode mode but WinVer does some size calculations when you include it and those are later passed to System::Call, I'll try to come up with a fix for this...


I'm trying to digitally sign the installer using the new !finalize command.
Everything works well as long as I don't use "%1" in the command line. If "%1" is used, makensis.exe crashes...

My code goes like this:
!finalize '"${__FILEDIR__}\SignTool.exe" sign /s MY_CERTSTORE /t "http://timestamp.globalsign.com/scripts/timstamp.dll" /d "Description" /du "http://www.blahblah.com" /v "%1"'

Btw, congratulations for reviving NSIS!


WinVer should be a able to deal with switching modes now but it really is best if the unicode mode is set before files are !included

Originally posted by mariusnegrutiu
Everything works well as long as I don't use "%1" in the command line. If "%1" is used, makensis.exe crashes...
Fixed...

Is there filesize >2GB support in 3.0a?
Or will it come with x64 branch?


Originally posted by extremecarver
Is there filesize >2GB support in 3.0a?
Or will it come with x64 branch?
No and I'm guessing no, the top bit is already used to store data...

thanks for the answer. Well then I hope it will be changed/enabled after x64 intregration sometimes. It would be much better than having the installer call external .zip/7z files (which on top can only be bzip/lzma and not lzma2) to unpack because they don't fit into the 2GB limit.


Just want to say thank you for everyone's work. :)

BTW can I use/install both NSIS 2 and NSIS 3 in one PC?
Would like my project to keep running and be able to test NSIS 3 to tell if I found a bug.
So amazing that NSIS 3 exist. Even NSIS 2 is already amaze me. :)


Originally posted by yoachan
BTW can I use/install both NSIS 2 and NSIS 3 in one PC?
Would like my project to keep running and be able to test NSIS 3 to tell if I found a bug.
So amazing that NSIS 3 exist. Even NSIS 2 is already amaze me. :)
The startmenu and add/remove programs entries will be taken over, other than that it should not be a problem. Makensis itself does not depend on any kind of system configuration...

are there plans to move the examples (and maybe includes) to the user space? on any modern windows version, the examples won't compile due to lack of privileges. just saying.


Originally posted by Yathosho
are there plans to move the examples (and maybe includes) to the user space? on any modern windows version, the examples won't compile due to lack of privileges. just saying.
Probably not, who would do the copy to $appdata, MakeNSISw?

Originally posted by Anders
Probably not, who would do the copy to $appdata, MakeNSISw?
the installer, of course!

Yes, on Windows 8 you have to run MakeNSISw as an administrator (even with UAC disabled) otherwise it cannot build the example scripts (cannot open output file). Your best bet is just to move the NSIS install directory and change the registry value (or install to AppData).

Stu


Originally posted by Yathosho
the installer, of course!
No, the installer cannot do that, UAC gets in the way (Wrong user) and does not work for other users on the same machine.

considering that nsis 3.0 is a new major release, i guess it's forgivable to demand a clean install from the user (or offer optional migration). then again, i don't see any harm in allowing both app data and program files, even at the same time (app data would override program files, and program files would serve as fallback.) as a side effect, that would allow different users using different nsis setups, though admittedly that's a small target audience.

one thing is clear: the current situation can be annoying. nobody wants to move scripts all the time or edit the outfile location. a compiler asking for elevation would be equally annoying.

also, must i remind you how often you have advised users to keep data and program files separate? :)


Originally posted by Yathosho
also, must i remind you how often you have advised users to keep data and program files separate? :)
Do as I say, not as I(We) do :)

I have a rewritten version of the installer that allows per-user installs, not sure if we will adopt it though...