Intellij sbt shell is not loading my environment variables - scala

My sbt shell in Intellij did not have all of my environment variables in scope. This would cause the execution of my code to fail whenever a made a reference to an env var that was not available.

Turns out, you need to set your environment variables in a ~/.zshrc file. Note, that Intellij does not load these from a .bash_profile or .bashrc file.
Just create a .zshrc file in your home directory, add an env variable like so:
export MY_VAR="test"
Then you need to completely restart your IDE. Now, when you start your sbt shell, those variables will be in scope.

Related

Shell script exporting Hadoop library classpath does not working

I am trying to develop Python client which interacts with Hadoop file system 3.3 using pyarrow package. My OS is CentOS 8 and IDE is Eclipse pydev. The sample code is simple.
from pyarrow import fs
hdfs = fs.HadoopFileSystem('localhost', 9000)
But the prerequisite command has to be executed for the successful python codes running. The command is
# export CLASSPATH=`$HADOOP_HOME/bin/hdfs classpath --glob`
Whenever I run Eclipse IDE, I have to execute the above export CLASSPATH command before Eclipse. To prevent this inconvenience and to automate the IDE configuration, I make the shell script file like below,
#! /bin/bash
export CLASSPATH=$(/usr/local/hadoop/bin/hdfs classpath --glob)
echo $CLASSPATH
When I execute this script, output messages from shell script are correct. But when I execute the Eclipse on the next line, the above pyarrow Python codes do not work successfully. I have no idea of this failure.
When I execute the export CLASSPATH command on the shell itself, the Python codes on Eclipse work correctly. But when I execute shell script, the Eclipse Python codes throws errors.
Update
I enter the [Run Configurations] menu and choose [Environment] tab. I click [Add] and input the below values onto [New Environment Variable] Dialog.
Name : CLASSPATH
Value : $(/usr/local/hadoop/bin/hdfs classpath --glob)
But my configuration is not correct, the same errors are still brought again.
I attach the image of my IDE configuration.
As mentioned in comments, in eclipe's "Run Configurations" menu, you need to add en environment variable entry for called CLASSPATH.
The value must be whatever the shell returns when you run this command:
/usr/local/hadoop/bin/hdfs classpath --glob
Don't try to put $(/usr/local/hadoop/bin/hdfs classpath --glob), it will be interpreted as a string an won't work.

Append to PATH environment variable in Eclipse

How can I append or prepend a custom directory to the PATH environment variable in Eclipse CDT?
I am referring to the environment variables which can be specified at these locations:
for the C/C++ build environment
for C/C++ launch configurations
for external tool launch configurations
The custom directory should be prepended or appended to the PATH environment variable used by Eclipse itself (referred to as "native environment").
Attempting to set it the usual way (PATH=/my/custom/directory:${PATH}) does not work for launch configurations.
In a launch configuration you can use the env_var variable with the argument PATH:
${env_var:PATH}
Since plug-ins can contribute variables (e.g. git_branch by EGit) there is no documentation with a list of all variables and their arguments. In the New/Edit Environment Variable dialog, if you click Variables... and select the env_var variable, there is the following description at the bottom of the dialog (in my view the screenshot with env_var without arguments shown in the C/C++ Development User Guide is not correct here):
Returns the value of an environment variable. An environment variable
name must be specified as an argument.
In the C/C++ build environment, I would assume this would work too. But you've already found out that ${PATH} works here for sure.

Installing Maven 3.1.1 on Maverick and working with eclipse-Kepler TLM terminal plugin

I recently installed OS X 10.9 Mavericks. As it does not come with Maven pre installed, I installed Maven 3.1.1 manually. I exported maven and set its path in .bash_profile. It is accessible from command line. But it is not accessible from within eclipse TLM terminal plugin or Wicked Shell plugin.
One workaround I got is, I added same export statement in .bashrc and it is accessible now from within eclipse aforementioned terminal plugins. Is there any better solution for it? Can anybody explain how many .bash* files are there in mac and when each one is initialised ?
In order to have eclipse pick up the new addition to your PATH, you need to edit /etc/launchd.conf to set the environment variable explicitly. Environment variable substitutions such as $PATH will not work. To correct do an echo $PATH in terminal and copy what it returns. Then, add this line to the launchd.conf file and restart your machine.
setenv PATH <your echo $PATH results here>
After, all should return to normal in eclipse. Hope this helps!

Roo setup, can't execute roo from project folder

I'm making a GWT app with roo (new to me) and it's late at night so I'm clearly missing something but I just created a new project folder and am trying to run roo.bat (works fine when I execute the bin directory) but it won't go. I keep getting this error:
C:\springsource\spring-roo-1.1.4.RELEASE\newProject> ../bin/roo.bat
'..' is not recognized as an internal or external command,
operable program or batch file.
Am I on crazy pills? I guess this is more of a windows command line issue but it should work (on Vista btw). Is there something about Roo.bat that won't let itself be executed from another directory or something weird?
Try this if helps:
http://www.youtube.com/watch?v=PJe7NHbZeUw
Go to Start, My Computer, right click, Properties, Advanced Definitions, Environment Variables.
In User Variables, create JAVA_HOME, ROO_HOME, MAVEN_HOME and the path should be the installation of those apps.
Then in System Variables add also the path of roo, maven and Java separated by semicolon ;.
Then go to start menu, type cmd, place it on desktop, like C:\Users\Martinho\Desktop
type mkdir myApp then enter
cd myApp
finally type roo.
There it is roo shell
Hope this helps.
Don't create your projects within the Roo installation. Instead, set an environment variable as ROO_HOME which points to the Roo installation, and add %ROO_HOME%/bin to your system path.
This makes it possible to run Roo console from any location.

Running ant through eclipse it doesn't find environment variables, but running ant through terminal is fine

When i run ant through Eclipse some targets build fine, but ones that need a specific environment variable i.e. SOME_SDK that i set in my .profile file won't work. Even if i try to echo out ${env.JAVA_HOME}, Ant through eclipse will just print out that string. But if i run ant through the terminal (i.e. ant sometarget), it will find JAVA_HOME and SOME_SDK and echo those paths out. Ive checked eclipse that it's pointing to the same ant that is in my environment path (/usr/share/java/ant-1.8.1). Any ideas?
Thanks
When you open a terminal, the environment variables in your .profile get loaded. When you start Eclipse via the windowing system it is not being run under your user account, so your .profile is not available to Eclipse at runtime.
At least that's the case on my linux machine and I'm guessing its the same on a Mac. I put the environment variables that Eclipse needs to see in the /etc/profile file, which gets loaded at system startup.
You can specify variables in your Ant run configuration (Run As > Ant Build... > Environment tab).
I'm thinking that the Eclipse IDE environment handling is a bit spoiled, at least in *nix environments. Although similar to Kevin's case, what I'm finding is that although I do create a separate run profile and -successfully - run the test/install goals (maven instead of ant here, but that's negligible noise), and specify the JAVA_HOME environment variable for that run profile, the project does not validate the POM file.
All I'm left with is two separate choices:
use the /etc/profile approach, or
Edit eclipse.ini file including the system property there.
I think the latter is a cleaner workaround since it affects a configuration file that is only for the problematic application after all. Nevertheless, Eclipse should use the variables found in the user's path and leave us at ease to produce :)
What you need to do is remove the java.exe from c:\Windows\System32.
The reason is, in your %PATH% environment variable, it includes c:\Windows\System32, which has a java.exe file. If you run c:> java -version from a command prompt, you'll see that the version you're running does not match the jdk version.
Once you've done this, you will need to add: %JAVA_HOME%/bin to the %PATH% environment variable, so you can execute the java.exe from the jdk when running apps. Be sure to restart any application (including the command prompt) before expecting it to pick up the change.
Add this line to ~/.bashrc (or you can use another profile file):
alias start-eclipse='open /Applications/eclipse/Eclipse.app'
(Don't forget to run source ~/.bashrc)
If you run start-eclipse from the command line, all environment variables will be picked up. This way, you only need to maintain a single set of environment variables across both command-line and eclipse environments.
NOTE: Stolen from Chris Fegley's answer at Launch mac eclipse with environment variables set