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
Related
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'm trying desperately to give xvfb-run some resolution arguments to take screenshots of websites with wkhtmltox in different resolutions.
I'm using both xvfb-run and wkhtmltox on CentOS.
xvfb-run --server-args="-screen 0 1024x768x24" wkhtmltoimage http://www.whatismyscreenresolution.com/ /tmp/bla.png
Unfortunately my arguments are not respected by xvfb-run. It has always a resolution of 800x600. What am I doing wrong here?
Thanks for any help!
You forgot this option: --use-xserver.
So the whole command is:
xvfb-run --server-args="-screen 0 1024x768x24" wkhtmltoimage --use-xserver http://www.whatismyscreenresolution.com/ /tmp/bla.png
(I tested with wkhtmltopdf, but it should be the same with wkhtmltoimage)
Add a comma between parameters. In your case "-screen 0, 1024x768x24".
Let me know if it helped you.
Regards,
HBK
Are you running wkhtmltoimage with a patched QT? If your QT version is NOT patched, a lot of features are ignored, including any commands sent from xvfb-run.
you can check your version like so:
/usr/bin/wkhtmltoimage --version
Change the path to wherever you've stored your wkhtmltoimage file. If the returned version doesn't include "patched QT", then that's probably where you should start. You can download a patched QT version from here:
https://wkhtmltopdf.org/downloads.html
Installation of a patched QT version is not too complicated, try a variation of the following (I'm running Ubuntu 20, other distros will need tweaking):
cd ~
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
sudo dpkg -i wkhtmltox_0.12.6-1.focal_amd64.deb
sudo apt-get install -f
/usr/local/bin/wkhtmltoimage --version
Best of luck.
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 am trying to install CPAN modules on shared Linux environment without root privileges, and in particular the PDL::Graphics::Gnuplot module. The default gnuplot version is Version 3.7 patchlevel 3, but the version Version 4.6 patchlevel 3 is also installed (/opt/gnuplot-4.6.3/bin/gnuplot). When trying to install the Perl module in my local directory, it fails on the test:
unless(`gnuplot -V`)
I tried to override the default gnuplot command with an alias in .bashrc:
alias gnuplot='/opt/gnuplot-4.6.3/bin/gnuplot'
In the regular shell I get:
$gnuplot -V
gnuplot 4.6 patchlevel 3
But using Perl:
$ perl -e 'system("gnuplot -V")'
Cannot open load file '-V'
line 0: (No such file or directory)
How do I make Perl to see the new version of gnuplot?
On solution I think of is to change the system command in the Makefile and in the following files in the module.
Shell aliases only work in the interactive shell. You have other options:
Change your PATH so that the newer gnuplot's bin precedes the old one.
Make a symbolic link to the new gnuplot from your bin and make sure it comes first in PATH.
How to install Scala 2.9 nightly build on Ubuntu?
Just extract it someplace and make sure its bin subdirectory is on the PATH, as well as java.
You have to do it by hand. I usually put my builds in
/usr/share/scala
but there are other places that make sense. Anyway, I'd start off by
sudo mkdir /usr/share/scala
cd /usr/share/scala
tar zxf scala-2.9.0.r24301-b20110218020036.tgz
ln -s scala-2.9.0.r24301-b20110218020036 2.9
Now we've got Scala in place and we have a soft link to /usr/share/scala/2.9 that we can keep pointing at new builds as we unpack them.
If you have Ubuntu's out-of-date Scala installed, you'll probably want to replace or rename those commands. Ubuntu places Scala commands in /usr/local/bin/, so you need to re-point those to the right place:
sudo mv /usr/local/bin/scala /usr/local/bin/oldscala
sudo ln -s /usr/share/scala/2.9/bin/scala /usr/local/bin/scala
# same thing for scalac, fsc, scaladoc
and then you should be set. Ubuntu doesn't bother setting environment variables, and Scala works fine without it.