Old 24th July 2007, 16:40   #1
madams
Junior Member
 
Join Date: Jun 2007
Posts: 34
ANT_HOME Problem

Hi,

I have yet another problem with my installer (posted in a thread right below this): Even though I set the ANT_HOME variable at the beginning of my main section, the installer claims ANT_HOME is invalid when I try to execute an ANT command toward the end of my main section. Here is my code snippet:

SetOutPath $INSTDIR
SetOverwrite on
File /r caTissueCore1.2\*
WriteRegStr HKLM "${REGKEY}\Components" Main 1

${if} $antHomeDir == ''
!insertmacro ZIPDLL_EXTRACT "$EXEDIR\apache-ant-1.6.0-bin.zip" "C:\" "<ALL>"
Strcpy $antHomeDir "C:\apache-ant-1.6.0"
${endif}
${if} $jboss.home.dir == ''
!insertmacro ZIPDLL_EXTRACT "$EXEDIR\jboss-4.0.0.zip" "C:\" "<ALL>"
Strcpy $jboss.home.dir "C:\JBoss-4.0.0"
${endif}
Push $antHomeDir\bin
Call AddToPath

Push JBOSS_HOME
Push $jboss.home.dir
Call WriteEnvStr

Push ANT_HOME
Push $antHomeDir
Call WriteEnvStr

call editCaTissueInstall.Properties
call editSqlConfigFiles
call editTextFilesAndLogo

StrCpy $mySQLEXE "$mySQLEXEbin\mysql.exe"
detailPrint "cmd /C $mySQLEXE -uroot -popen123 < $databaseConfigFile"

nsExec::ExecToLog 'cmd /C IF 1==1 "$mySQLEXE" -uroot -p$databaseLoginPass < $databaseConfigFile'
nsExec::ExecToLog 'cmd /C cd $INSTDIR'
nsExec::ExecToLog 'cmd /C $antHomeDir\bin\ant -f deploy.xml deploy_all_with_config'

Any help would be greatly appreciated.

Thanks!
madams is offline   Reply With Quote
Old 24th July 2007, 17:26   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You mean it is saying that the ANT_HOME environment variable does not exist?

Stu
Afrow UK is offline   Reply With Quote
Old 24th July 2007, 19:46   #3
madams
Junior Member
 
Join Date: Jun 2007
Posts: 34
The exact error I am getting is: "ANT_HOME is set incorrectly or Ant could not be located. Please set ANT_HOME."

I know that the ANT_HOME variable is getting set correctly, becuase I have checked it in System > Advanced > Environmental Variables as soon as the installer finishes. Also, if I try running the installer again after the first run fails, it works perfectly. Could it be that I have to restart the computer for the changed environmental variable settings to take effect?
madams is offline   Reply With Quote
Old 24th July 2007, 20:28   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Setting the environment variables only works for new processes started from explorer. To set it to new processed started from your process, you need to manually update the environment variables of your process.

Use:

http://nsis.sourceforge.net/Setting_...taller_Process

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 24th July 2007, 20:42   #5
madams
Junior Member
 
Join Date: Jun 2007
Posts: 34
Ok, I edited my main section with the code in the link you provided, but I am still getting the invalid ANT_HOME error. Here's the edited code:

Quote:
Section -Main SEC0000
SetOutPath $INSTDIR
SetOverwrite on
File /r caTissueCore1.2\*
WriteRegStr HKLM "${REGKEY}\Components" Main 1

${if} $antHomeDir == ''
!insertmacro ZIPDLL_EXTRACT "$EXEDIR\apache-ant-1.6.0-bin.zip" "C:\" "<ALL>"
Strcpy $antHomeDir "C:\apache-ant-1.6.0"
${endif}
${if} $jboss.home.dir == ''
!insertmacro ZIPDLL_EXTRACT "$EXEDIR\jboss-4.0.0.zip" "C:\" "<ALL>"
Strcpy $jboss.home.dir "C:\JBoss-4.0.0"
${endif}
Push $antHomeDir\bin
Call AddToPath

ReadEnvStr $R0 "PATH"
StrCpy $R0 "$R0;$antHomeDir\bin"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PATH", R0).r2'

Push JBOSS_HOME
Push $jboss.home.dir
Call WriteEnvStr

Push ANT_HOME
Push $antHomeDir
Call WriteEnvStr

ReadEnvStr $R0 "ANT_HOME"
StrCpy $R0 "$antHomeDir\bin"
System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PATH", R0).r2'

call editCaTissueInstall.Properties
call editSqlConfigFiles
call editTextFilesAndLogo

StrCpy $mySQLEXE "$mySQLEXEbin\mysql.exe"
detailPrint "cmd /C $mySQLEXE -uroot -popen123 < $databaseConfigFile"

nsExec::ExecToLog 'cmd /C IF 1==1 "$mySQLEXE" -uroot -p$databaseLoginPass < $databaseConfigFile'
nsExec::ExecToLog 'cmd /C cd $INSTDIR'
nsExec::ExecToLog 'cmd /C $antHomeDir\bin\ant -f deploy.xml deploy_all_with_config'
SectionEnd
Am I doing anything wrong?
madams is offline   Reply With Quote
Old 24th July 2007, 20:51   #6
madams
Junior Member
 
Join Date: Jun 2007
Posts: 34
Nevermind, I made a stupid syntax error in the code above and everything works perfectly now. Thanks for all your help!
madams is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump