NSIS - jruby fails to access environment variables - jruby

I've made a NSIS script to create an installer for a Rails application.
The application uses JRuby and Java.
In the first section of the installer I set the environment variables: I add jruby\bin to PATH and I create JAVA_HOME variable, which points to Java\jre6.
!define JRubyBinPath "$PROGRAMFILES\${PRODUCT_PUBLISHER}\JRuby\jruby-1.6.3\bin"
Function SetEnvVars
# set JAVA_HOME
${EnvVarUpdate} $0 "JAVA_HOME" "A" "HKCU" "C:\Program Files\Java\jre6"
# add jruby to Path
${EnvVarUpdate} $0 "Path" "A" "HKLM" "${JRubyBinPath}"
FunctionEnd
Section "Pre" SEC01
Call SetEnvVars
...
SectionEnd
** All the paths are correct. **
In the second section of the installer, after packing all the application files and JRuby files, I initialize the database using the following commands:
Section "Installer" SEC02
...
SetOutPath $INSTDIR
nsExec::ExecToLog "jruby -S bundle exec rake db:create RAILS_ENV=production"
nsExec::ExecToLog "jruby -S bundle exec rake db:migrate RAILS_ENV=production"
nsExec::ExecToLog "jruby -S bundle exec rake db:seed RAILS_ENV=production"
...
SectionEnd
The problem is that when I run the installer on a clean Windows system, all the code executes correctly, except for the lines that contain commands using "jruby". I get no error in the installer window, it just won't execute those lines.
Anyway, if I manually run those commands in a console right after the installer finishes, everything works as expected.
From what I have seen so far, the problem is that the installer cannot access the environment variables until it finishes.
* What I have done so far to solve this problem is creating the main installer Installer.exe (here I pack all the files and I set the environment variables), and another executable Init.exe which initializes the database.
If I manually run these executables - first Installer.exe then Init.exe - the application installs correctly. But if I try to launch Init.exe from Installer.exe, it won't work.
However, if there would be a way to execute the "jruby" commands in a new/different thread than the one that sets the environment variables, I think the problem would be solved. But I still couldn't find the way to do that.
Thanks.

NSIS doesn't have any threading. Apparently not quite true—but in your own code, you don't get to use threads.
You may need to set PATH for the current process; I'm not familiar with ${EnvVarUpdate}, but looking at its script it doesn't seem to updates the variable in the current process. Try this:
${EnvVarUpdate} $0 PATH A HKLM "${JRubyBinPath}" # The line you already have
System::Call Kernel32::SetEnvironmentVariable(t"PATH",tr0)
Another note: you are hard-coding JRubyBinPath; are you sure you really want to do that?

Related

ModuleNotFoundError when running functional python tests despite that textX command works

I followed the set of instructions for this open source.
At step 3, I am supposed to run
py.test tests/functional/
When I do so, I get
ModuleNotFoundError: No module named 'textx'
However, when I type textx, it's definitely working as a command.
Where did I go wrong?
The PYTHONPATH is not set by py.test, see https://docs.pytest.org/en/latest/pythonpath.html#pythonpath
As described in https://github.com/igordejanovic/textX/blob/master/CONTRIBUTING.md you install textX in your virtual environment. If you omit 'pip install -e .' you get the described behavior.
As mentioned above, you can set the PYTHONPATH manually. Alternatively you can also run 'python -m pytest tests/functional' as proposed on the py.test website.
It is unclear to me why the textx command works in your example. Maybe you installed textX outside your virtual environment after creating the virtual environment?
Run export PYTHONPATH=. before running the py.test tests/functional/ and it should work.
This error may have occurred because I installed textX outside my virtual environment after creating the virtual environment.

'ALGOLIA_API_KEY' not recognized as an internal or external command

I am trying to run algolia for the first time but it seems that there is something wrong with my environment. I followed the detailed explanation here https://community.algolia.com/jekyll-algolia/getting-started.html.
I installed and configured everything that is needed from the previous steps but when I run the command
ALGOLIA_API_KEY=xxxxxxxxxxxxxx bundle exec jekyll algolia
I get an error:
'ALGOLIA_API_KEY' is not recognized as an internal or external command,
operable program or batch file.
I have been rereading the documentation for both jekyll and angolia but couldn't find anything that could be helpful.
Since you're running on Windows, you cannot set an environment variable for your command like you can do on UNIX.
As advised in this question, Setting and using variable within same command line in Windows cmd.exe, I believe you could use
set ALGOLIA_API_KEY=xxxxxxxxxxxxxx && bundle exec jekyll algolia

Scilab, backdoor error, octave conflict

I installed scilab.6.0.0 and backdoor fromscilab website (which I could not find it from Application>Module maneger>atom>Technical). I moved the backdoor file my home and from scilab command line I installed it
-->atomsInstall('/home/user/BackDoor_0.2_5.5.bin.x86_64.linux.tar.gz')
Even though, it installed backdoor successfully, when I restart the scilab I got this error message with backdoor
Start Toolbox BackDoor
Load macros
atomsLoad: An error occurred while loading 'BackDoor-0.2':
lib: Old binary lib detected. Please recompile it for Scilab 6.
As I understand I need to update the library, but I don't know how?
Would sb tell me explicitly (because I am a newbie user of scilab) how can I get over the error?
at the and I try to connect octave and scilab and when I try to run a demo script at octave I get also this error
>> sci_sim_example
Scilab connection failed
FYI: I already installed sci_cosim package (after I downloaded the package, I write to octave prompt >>pkg install sci_cosim_0.1.3.tar.gz), and I load it before running the script.
How can I recompile the lib: Old binary lib detected
Thank you so much for your help in advance
Here's what worked for me.
Download Scilab 5.5.2 (link for Linux 64bit version)
Extract the .tar.gz file in your preferred system location to install it there. Generally, my preferred location to extract / install self-contained packages is inside /opt .
You can extract the .tar.gz file using your filebrowser's graphical facilities, or on the command line; if /opt is owned by root (which it usually is) you may need to change ownership after extraction. E.g. your installation might look something like this:
cd /opt
sudo wget http://www.scilab.org/download/5.5.2/scilab-5.5.2.bin.linux-x86_64.tar.gz
sudo tar -xvzf ./scilab-5.5.2.bin.linux-x86_64.tar.gz
sudo rm scilab-5.5.2.bin.linux-x86_64.tar.gz
sudo chown $USER ./scilab-5.5.2 -R
Launch scilab by typing
/opt/scilab-5.5.2/bin/scilab &
in your terminal.
Once scilab is launched, go to Applications->Module Manager ATOMS. In the new window that comes up, click on All modules -> BackDoor -> Install.
You should get a message saying "Installation done, please restart SciLab".
Exit Scilab, and launch it again from the terminal. If you see a message:
atomsLoad: An error occurred while loading 'BackDoor-0.2':
File "/opt/scilab-5.5.2/share/scilab/contrib/BackDoor/0.2/etc/backdoor.start" does not exist.
then type the following commands in your terminal to rename the affected files:
cd /opt/scilab-5.5.2/share/scilab/contrib/BackDoor/0.2/etc/
mv BackDoor.start backdoor.start
mv BackDoor.quit backdoor.quit
Restart SciLab again. Hopefully this time it will work and SciLab will inform you that BackDoor is listening for connections at a certain port.
PS. Also note that from the octave side of things, the -auto option is no longer accepted when you perform a pkg install. You will need to load the sockets and sci_cosim packages manually each time you want to use this.

rake failure due to imagemagick

I'm seeding a development database (mysql) using rake db:seed in Rails 3. The rake task fails, stating,
Validation failed: Logo /var/folders/.../logo.png is not recognized by the 'identify' command.
When I run which identify, I get the expected path /usr/local/bin/identify. ImageMagick is indeed installed (via Homebrew), and appears to work with png images just fine from the command line.
I even rebuilt the app on another machine, thinking that my environment is borked, and I got the same error.
Is there a poltergeist in my terminal sessions?
Have you tried running a bundle exec before the rake. In the past this has often solved these sorts of problems for me. It will ensure your rails environment is loaded before running the rake task.
bundle exec rake db:seed
Hope that helps!
// Addition
Also are you using the Paperclip gem to do this import? I do remember that I needed to ensure the path to ImageMagick was set in my development.rb file to ensure this was picked up.
Eg.
Paperclip.options[:command_path] = "/usr/local/bin"

How to add path variable to job shell

I am setting up Jenkins to replace our current TeamCity CI build.
I have created a free-style software project so that I can execute a shell script.
The Shell script runs the mvn command.
But the build fails complaining that the 'mvn' command cannot be found.
I have figured that this is because Jenkins is running the build in a different shell, which does not have Maven on it's path.
My question is; how do I add the path so 'mvn' is found in my Shell script? I've looked around but can't spot where the right place might be.
Thanks for your time.
I solved this by exporting and setting the Path in the Jenkins Job configuration where you can enter shell commands. So I set the environments variable before I execute my Shell script, works a treat.
Some possible solutions:
You can call maven with an absolute path
You configure a global environment variable in the jenkins system settings with the absolute path to your maven instance, and use this in your script call (if you use the inline shell script, I don't know if those are substituted to a called script, you have to test)
You use a maven project and configure your maven instance in the jenkins system settings
ps.: Usually /bin/sh is chosen from Jenkins, if you want to switch to eg. bash, you can configure this in the jenkins system settings, in case you want to configure global environment variables.
You can use envInject plugin. It's very powerful.
I use it to install rbenv. And it can inject environment variables into your current job.
Another option to Dags suggestion is that if you're only using a single version of maven, on each slave server you could do either;
* add PATH=${PATH}:
* symlink mvn into /usr/bin with; sudo ln -s /usr/bin
I'm not at a Jenkins box at the moment, but I can find some more detailed examples if you'd like.
Jenkins is using sh by default and not bash.
This is my first time defining a jenkins maven job, and I also followed soem regular maven instructions (for running from command line...), and tried to update ~/.bashrc with M2_HOME, M2, PATH, but it didn't work because jenkins used sh and not bash. Then I found out that there is a simpler and better way built into jenkins.
After installing maven, I was supposed to configure my maven installation in jenkins.
To configure your maven installation in Jenkins:
login to jenkins web console
click Manage Jenkins --> Configure System
Under Maven, click the "Maven Installations..." button
a. Give it some name
b. and under MVN_HOME set the path to where you installed maven, for example "/usr/local/apache-maven/apache-maven-3.0.5"
Click Save button
Define a job with maven target
edit your job
Click "Add build step"
on Maven Version, enter the name you gave your maven installation (step #4 above)
set some goal like clean install