Where was scala_home homebrew installed on OSX? - scala

I can't get scalac working despite scala successfully opening scala> in the terminal.
I suspect this is something to do with setting scala_home in my .bash_profile, on my mac.
What is the correct value for SCALA_HOME, or how do I find that correct value? (it was homebrewed)
And is the method to scale-compile the following:
to cd into the lower src folder and scalac IntroducingScala.HelloWorld.scala?

Homebrew usually tells you where it installs if you do brew info <name>. It's usually points at /usr/local/opt/<name>, which will be a symlink to the current version you're running.
When I run brew info scala it also comes with a helpful caveat:
==> Caveats
To use with IntelliJ, set the Scala home to:
/usr/local/opt/scala/idea

we can usually know the path using below:
which scala

Related

How to fix diesel_cli link libpq.lib error with Postgres tools installed in Docker?

I'm trying (for hours now) to install the cargo crate diesel_cli for postgres. However, every time I run the recommended cargo command:
cargo install diesel_cli --no-default-features --features postgres
I wait a few minutes just to see the same build fail with this message:
note: LINK : fatal error LNK1181: cannot open input file 'libpq.lib'
error: aborting due to previous error
error: failed to compile `diesel_cli v1.4.1`, intermediate artifacts can be found at `C:\Users\<user name here>\AppData\Local\Temp\cargo-installUU2DtT`
Caused by:
could not compile `diesel_cli`.
I'm running postgres in a docker container and have the binaries on my C:\pgsql with the lib and bin directories both on the PATH so I can't figure out why it's not linking. What else could be required they didn't mention in the docs?
In my case the installation was successful but when I tried to run it this error occured.
maybe this would work for others who have the same problem:
open PowerShell
type in setx PQ_LIB_DIR "C:\Program Files\PostgreSQL\13\lib" (or any other path to your PostgreSQL lib)
restart your PC
run again
I had the same issue with WSL, if you're on Linux probably you could find PostgreSQL lib location and add it to your environment variables.
Update:
The answer below is a work around for older versions. Please check the possibility to execute cargo clean first
Original Version
Adding the folder to the PATH variable didn't help, at least in my case, as by some reason it is not used in the /LIBPATH parameter passed to link.exe.
In my case it was C:\Users\<username>\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib
You can see it in the beginning of the error message.
Copy libpq.lib in there and it will be used from there.
After installation diesel would require some other assemblies. Copy libcrypto-1_1-x64.dll, libiconv-2.dll and libssl-1_1-x64.dll into the folder showed after where diesel command execution
I had the same error on Ubuntu and for me the following install fixed the issue:
sudo apt install libpq-dev
No need to move files around, just add C:\Program Files\PostgreSQL\14\lib and C:\Program Files\PostgreSQL\14\bin to your PATH. Installing and running diesel should have no problems.
Note: your paths may be different, and remember to close/reopen your terminal so the PATH variable is updated.
(Tested on Windows 10)
To give clear steps for windows:
Add C:\Users<username>.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib in the path in environment variables
Copy libpq.lib that is in C:\Program Files\PostgreSQL\14\lib (obviously this is with version 14) and paste it in C:\Users<username>.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib
If you've attempted to cargo build (or anything that runs the build scripts for libpq rust crate) when your environment was invalid, then you need to do a cargo clean after fixing your environment otherwise you'll still get the libpq.lib not found error even when it's in your PATH. The other answers where you copy the file into another directory are just hacks
You can instead add the path to .../lib to the compilers' library search paths, using RUSTFLAGS environment variable. It works both for installing diesel_cli and for building your projects.
RUSTFLAGS='-L /usr/local/pgsql/lib' cargo build
On Windows with EDB installer, the path contains a space, so use CARGO_ENCODED_RUSTFLAGS instead. For PowerShell:
$env:CARGO_ENCODED_RUSTFLAGS = "-L`u{1f}C:\Program Files\PostgreSQL\14\lib"

I am trying to set up Kafka in my local mac

I have unzipped the kafka_2.12-2.5.0 version and started zookeeper and when I am trying to start kafka using the command
"bin/zookeeper-server-start.sh config/zookeeper.properties" i am getting the following eror:
/Users/manig/Desktop/kafka_2.12-2.5.0/bin/kafka-run-class.sh: line 317: /Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home#/bin/java: No such file or directory
/Users/manig/Desktop/kafka_2.12-2.5.0/bin/kafka-run-class.sh: line 317: exec: /Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home#/bin/java: cannot execute: No such file or directory.
I tried adding double quotes around the JAVA term like this: "$JAVA" and also changing the classpath to cygpath -wp $CLASSPATH but still getting the same above error
can someone please help me with this..!
Try to set your Java ClassPath properly using the below commands. It was not able to recognize you JDK.
export JAVA_HOME="$(/usr/libexec/java_home)"
or
export JAVA_HOME=`/usr/libexec/java_home`
cygpath is for Cygwin, not Mac.
If you want to install on a Mac, just use brew install kafka
Or use Docker

Error: version `GLIBCXX_3.4.21' not found

I am trying to compile matconvnet-1.0-beta20 with Matlab 2016a on Ubuntu 16.04. Initial phase of compilation works fine:
untar('http://www.vlfeat.org/matconvnet/download/matconvnet-1.0-beta20.tar.gz') ;
cd matconvnet-1.0-beta20
run matlab/vl_compilenn
The error happens when I run vl_simplenn(network, image) which gives following error:
Invalid MEX-file '/home/matconvnet-1.0-beta20/matlab/mex/vl_nnconv.mexa64':
/usr/local/MATLAB/R2016a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version
`GLIBCXX_3.4.21' not found (required by /home/matconvnet-1.0-beta20/matlab/mex/vl_nnconv.mexa64)
To understand the cause of problem, I run /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBC which doesn't give any output bash: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: Permission denied
Also more /usr/lib/x86_64-linux-gnu/libstdc++.so.6 gives no output:
******** /usr/lib/x86_64-linux-gnu/libstdc++.so.6: Not a text file ********
I did some research and found some possible solutions:
http://it.mathworks.com/matlabcentral/newsreader/view_thread/162466
The problem is that MATLAB secretly changes LD_LIBRARY_PATH on startup
to point to the MATLAB version of GLIBC++, so that GLIBC++ 3.4.9 can
no longer be found. The solution is to modify matlab/bin/.matlab7rc.sh
so that "LDPATH_PREFIX" contains the path to the version of GLIB
installed with your compiler, then this is found before the
matlab-supplied library.
so I edited /usr/local/MATLAB/R2016a/bin/.matlab7rc.sh and modified LDPATH_PREFIX='' in 195th line to LDPATH_PREFIX='/usr/lib/x86_64-linux-gnu'.
After applying this change, the problem still exist.
As suggested here, I copied .matlab7rc.sh to current working directory of project, but still error persist.
https://askubuntu.com/questions/719028/version-glibcxx-3-4-21-not-found
According to first answer, running this command
ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6 usr/local/MATLAB/R2014a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6
gives an error:
ln: failed to create symbolic link 'usr/local/MATLAB/R2014a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6': No such file or directory
Seems like second solution suggests changes of LD_PRELOAD path in .matlab7rc.sh, but it is not anywhere inside the file.
How to tell mex to link with the libstdc++.so.6 in /usr/lib instead of the one in the MATLAB directory?
From Matlab directory in /usr/local/MATLAB/R2016a/bin$ I run
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/libstdc++.so.6
but the problem still exist.
Maybe there I didn't apply the solution in the correct way Or maybe there is another solution elsewhere that I didn't find. Please let me know, I am very confused!!!
You need before execute (matlab in my case) add path of library:
In console execute this:
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6 matlab
I had the same problem.
In my case, to solve it, I first ran "locate" to list all the possible versions of the library in the system.
locate libstdc++
As an example, I report the result on my system
I then set the most recent version of "lib" by exporting the environment variable:
export LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21"
So, the fullpath of the library to be set depends on where it is allocated in your system.
There are 2 possible solutions:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/libstdc++.so.6
Install this package:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
MAYBE the second solution you mentioned really works, but you have done it before. So you cannot operate in the same way again because you have ever linked /usr/lib/x86_64-linux-gnu/libstdc++.so.6 to usr/local/MATLAB/R2014a/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6. TRY rebooting?
Also, you use MATLAB R2016a, but this command applies to R2014a. Was it that you ignore this point?

How to reconfigure version of scala on ubuntu?

I installed scala with apt-get install scala. ans figure out another trouble where exactly scala home is now?
this Where is SCALA_HOME on Ubuntu? question suggest:
/usr/share/java
I want to be sure and downloaded and untarred last scala version.
all this I put at /opt/scala and added to system environment.
But now I have default installed version of scala. I don't know how to set version to new location?
Here is how it looks:
nazar#nazar-desktop:~$ scala -version
Scala code runner version 2.9.2 -- Copyright 2002-2011, LAMP/EPFL
nazar#nazar-desktop:~$ echo $SCALA_HOME
/opt/scala/scala-2.10.3
I want to turn installed version from 2.9.2 to untarred one.
how to solve this trouble?
I personally wouldn't bother.
The binary incompatibilities across major versions mean you'll likely want more than one version available if you ever work on more than one project.
My advice is to install the latest version of SBT and use that to manage versions at a per-project level. You'll still be able to get a REPL via sbt console
If you put $SCALA_HOME/bin at the front of your PATH variable, like this:
export PATH="$SCALA_HOME/bin:$PATH"
that should fix it.
However, you need to type hash -r in each terminal window in which you have tried to run scala, to make the change take effect.
I untarred scala in /usr/local then made scala a symbolic link to scala-2.10.0
The reason for this is to make an upgrade easier, just alter the symlink
Next, I added /usr/local/scala/bin to the PATH in .bashrc
After this, typing scala in a term gives me the prompt
To install scala into eclipse was considerably more complicated but I got that to work too, by untarring stuff into /usr/local
I didn't bother with apt-get on .deb packages as I run Ubuntu LTS and as far as I know there are no ppa that track a current version
Also, this SCALA_HOME thing: there is a function in the shell script "scala" that finds it in this way
findScalaHome () {
# see SI-2092 and SI-5792
local source="${BASH_SOURCE[0]}"
while [ -h "$source" ] ; do
local linked="$(readlink "$source")"
local dir="$( cd -P $(dirname "$source") && cd -P $(dirname "$linked") && pw
d )"
source="$dir/$(basename "$linked")"
done
( cd -P "$(dirname "$source")/.." && pwd )
}

How to set properly SCALA_HOME in a macport installed scala

I have installed multiple versions of Scala (2.9 and 2.10) on my mac (OS X 10.7.5) using macports. I like this way because can switch easily between these two versions by the simple "port select" command.
But, the SCALA_HOME environment variable does not get set automatically with this command.
Is there a proper nice macport command to set correctly the SCALA_HOME variable?
If no, what directory should the SCALA_HOME point to in a macport installed scala?
Thanks
EDIT:
Until now the best way I found is with a shell script that looks what is the current scala command and adjust the SCALA_HOME variable accordingly. I run it always after switching the Scala version.
Here is the important command in the script. I'm not an expert shell programmer, therefore I'll be thankful for any suggestion:
export SCALA_HOME=$(ls -l `which scala` | gawk 'match($0, "(/opt/local/share/.*)/bin/scala", a) {print a[1]}')
I don't know of a way to have MacPorts do it for you, but Scala is installed at /opt/local/share/scala-2.10/ for me. So I added
export SCALA_HOME="/opt/local/share/scala-2.10/"
to my ~/.profile and everything seems to be working for me now (although you'd have to switch change your $SCALA_HOME every time you switch versions).
OK, until now the best solution I found is to run following command after changing scala version:
export SCALA_HOME=$(ls -l `which scala` | gawk 'match($0, "(/opt/local/share/.*)/bin/scala", a) {print a[1]}')
I have included that command also in my .bash_profile so my SCALA_HOME always points to the scala version I am using currently.
This command uses gawk 4.1.1 installed from MacPorts.
Currently when scala is installed via brew it's path set to
/usr/local/Cellar/scala/[version]
So SCALA_HOME could be defined as follows:
export SCALA_HOME=$(greadlink -f $(dirname "$(greadlink -f $(which scala))")/../../)
p.s: You need to install 'greadlink' for that since the regular readlink doesn't support the 'f' flag.
if you are installing the versions with home brew you can simply:
brew switch scala 2.10.3