I am running Snow Leopard and installed MacPorts. I then installed the latest (as of this writing) Scala version as:
$ sudo port install scala29
What to do after this? When I try to execute the Scala interpreter, I get:
-bash: scala: command not found
I'm using MacPorts 2.1.2 and things seems to changed a bit again.
$ sudo port select --list scala
Shows
Available versions for scala:
none (active)
scala2.9
Command suggested by nezda does not work properly:
$ sudo port select --set scala2.9
gives error
Error: The 'set' command expects two arguments: <group>, <version>
But following helps
$ sudo port select --set scala scala2.9
Activates Scala 2.9
Selecting 'scala2.9' for 'scala' succeeded. 'scala2.9' is now active.
Checking scala again
$ sudo port select --list scala
Available versions for scala:
none
scala2.9 (active)
And I can run Scala now.
This seems to have changed. On Lion + MacPorts 2.1.1, I had to do the following:
Verify this shows the version:
sudo port select --list scala
Mine showed:
Available versions for scala:
none (active)
scala29
If it is not selected, you can use this command to select it:
sudo port select --set scala scala29
Open a new terminal (ensuring $PATH is up to date) and verify scala is now 2.9.x.
Okay, so I actually had to search this since the Scala install has changed since the last time I did it. The executables should have been linked from /opt/local/bin, to use them without prefixing the folders do this:
cd /opt/local/bin
sudo scala_select scala29
Now you should be able to run the scala command from any directory.
As of January 2013 this answer is outdated, Arnost Valicek's answer is known to work.
I think it's:
sudo port select --set scala scala29
Related
I'm using EMR and can launch spark-shell, but I want to run Scala REPL. Currently when I type scala command on shell it says:
-bash: scala: command not found
How to locate and run Scala REPL give that Spark is already installed and configured?
As already told by #ernest_k, EMR doesn't come with Scala installation.
With that said, I used the steps mentioned in this blog to install Scala on EMR
# perform customary yum update
sudo yum update
# download Scala installer RPM
wget https://downloads.lightbend.com/scala/2.13.0-M5/scala-2.13.0-M5.rpm
# install Scala RPM
sudo yum install scala-2.12.5.rpm
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
I have problems building a portable executable with rust.
Running an executable simply built with cargo build on Ubuntu fails with
./test: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by ./test)
Building with rustc ... -C link-args=-static fails to link correctly (output of ld ./test):
ld: error in ./test(.eh_frame); no .eh_frame_hdr table will be created.
Is there a way around this except building on an older system with an old glibc version?
Glibc is not linked statically (much as we might have liked to, it goes out of its way to prevent this). As a result, the system libraries (libstd and such) are always dependent on the glibc version on which they were built. This is why the buildbots in the linux cluster mozilla uses are/were old versions of centos.
See https://github.com/rust-lang/rust/issues/9545 and https://github.com/rust-lang/rust/issues/7283
Unfortunately at this time I believe there is no workaround aside from making sure you build on a system with an older glibc than you're going to deploy to.
To avoid GLIBC errors, you can compile your own version of Rust against a static alternative libc, musl.
Get the latest stable release of musl and build it with option --disable-shared:
$ mkdir musldist
$ PREFIX=$(pwd)/musldist
$ ./configure --disable-shared --prefix=$PREFIX
then build Rust against musl:
$ ./configure --target=x86_64-unknown-linux-musl --musl-root=$PREFIX --prefix=$PREFIX
then build your project
$ echo 'fn main() { println!("Hello, world!"); }' > main.rs
$ rustc --target=x86_64-unknown-linux-musl main.rs
$ ldd main
not a dynamic executable
For more information, look at the advanced linking section of the documentation.
As reported in the original documentation:
However, you may need to recompile your native libraries against musl
before they can be linked against.
You can also use rustup.
Remove old Rust installed by rustup.sh
$ sudo /usr/local/lib/rustlib/uninstall.sh # only if you have
$ rm $HOME/.rustup
Install rustup
$ curl https://sh.rustup.rs -sSf | sh
$ rustup default nightly #just for ubuntu 14.04 (stable Rust 1.11.0 has linking issue)
$ rustup target add x86_64-unknown-linux-musl
$ export PATH=$HOME/.cargo/bin:$PATH
$ cargo new --bin hello && cd hello
$ cargo run --target=x86_64-unknown-linux-musl
$ ldd target/x86_64-unknown-linux-musl/debug/hello
not a dynamic executable
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 )
}
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