Why Ocaml version located on file (4.04.0) different from what terminal says (4.03.0)? - bash

I've been trying to run a program that uses graphics (which I've already posted about here). This post and other posts have led me to the conclusion that I need create a ~/.bashrc and put in it:
alias ocaml="/usr/local/Cellar/ocaml/4.03.0/bin/ocaml”
However, /usr/local/Cellar/ocaml/4.03.0/bin/ocaml is not a valid file in my system. B/c when I ran this in the terminal:
$ cd /usr/local/Cellar/ocaml/4.03.0/bin
-bash: cd: /usr/local/Cellar/ocaml/4.03.0/bin: No such file or directory
But changing the version to 4.04.0 works:
$ cd /usr/local/Cellar/ocaml/4.04.0/bin
But when I ask the terminal what ocaml I'm running:
$ which ocaml
/Users/Username/.opam/4.03.0/bin/ocaml
It says I'm running 4.03.0
And my error message when I try to run an ocaml program using graphics is :
Error: Cannot find file /Users/Username/.opam/4.03.0/lib/ocaml/graphics.cma
So it seems like my terminal is running 4.03.0 but I don't have OCaml 4.03.0 in /usr/local/Cellar/ocaml/4.03.0/bin and instead I have 4.04.0??
That to me seems very strange.
If anyone could please help me out that would be greatly appreciated! I have spent hours trying to figure out how to run graphics on my computer and I have no clue why the solutions posted in previous StackOverflow posts are not helping :(

i don't find it strange.
The alias command works only in your terminal, not for the entire system.
Probably you have "/Users/Username/.opam/4.03.0/bin/ocaml" in your PATH variable.
I suggest to do:
export PATH="/usr/local/Cellar/ocaml/4.04.0/bin:$PATH"
then:
which ocaml
and the path should be the 4.04 version

It looks like that you have multiple installations of OCaml on your machine. Some of them being installed via opam, and others either manually, or via system package management. I would suggest just to ignore the latter and focus on opam.
To use opam, you need to activate your switch. This can be done manually,
eval `opam config env`
(Note the use of backticks)
You can also put it in your profile, so that opam will be activated every time you logged in. You can even ask opam to do it for you:
opam config setup --user
Finally, if you want to run a program, out of your normal terminal environment, and do not want to depend on some pre-setup steps (i.e., on a client's machine), then you can use opam config exec:
opam config exec -- ocaml my-ocaml-script.ml

Related

Error during installation of omnetpp on MAC(5.6.1)

I found couple of answers but none of them was helpful, I downloaded omnetpp for MAC (omnetpp-5.6.1-src-macosx.tar) if i open the IDE directly I get "“Omnetpp” is damaged and can’t be opened." I tried installing it like 5 times. I found that I should execute setenv, I got this error "Error: not a login shell -- run this script as 'source setenv' or '. setenv'"
Can someone please help me with the steps to install/use omnetpp? Thank you so much in advance.
As the error message suggests:
first open a terminal window
change to the omnetpp installation directory i.e. cd ~/omnetpp-5.6.1 or similar.
source setenv
./configure
make -j4
omnetpp
You have to put the "omnetpp-5.6.1" directory right in the home path: i.e. ~/Users/yourname
Open the "doc" directory in "omnetpp-5.6.1" directory and there you can see an installation guide which helps you what to do step by step.
Do the instruction. be careful writing the command ./configure it may not work. If it doesn't you should use ./configure WITH_TKENV=no WITH_QTENV=no instead of that.
Also before you run $ make command in terminal you have to run $ . setenv .
I did the instruction but I couldn't run the software yet, then I noticed that the problem is my java version!
write:
$java -version
in your terminal it will show you the actual version your system is using, It must be java8 for running this software if it's not, try to downgrade or upgrade it to java8
I hope it helps you! GL!

bash __git_ps1 command not found

I am a beginner trying to setup a developer environment on my new Mac following the steps from this link: http://vanderveer.be/setting-up-my-perfect-developer-environment-on-osx-10-8-mountain-lion-10-8-2-final-edition/.
After executing the files from git, my terminal window now shows:
rbenv: version `1.9.3-p194' not installed
-bash: __git_ps1: command not found
The first line only shows when I open a new terminal window, while the second shows everytime I press return no matter what I type into the terminal.
I have read through many questions on stackoverflow and tried to mimic their solutions to no avail. I think I've made a mistake in installing the package from git as I am not so experienced and I think now I may have messed up the configurations, and was also wondering if there is any way to go back to default settings for bash?
Many thanks!
Allen
If you've not installed a newer version of Git on your Mac, start by doing that. You can grab the download from here: http://git-scm.com/download
Once it's installed, you should source git-completion.sh and git-prompt.sh from your ~/.profile (or ~/.bashrc, if you have it):
source /usr/local/git/contrib/completion/git-completion.bash
source /usr/local/git/contrib/completion/git-prompt.sh
That should fix the __git_ps1 error.
I'm not a Rubyist, but the rbenv error is coming from the fact that the setup in the dotfiles you are following is trying to set the default Ruby version to "1.9.3-p194". The rbenv tool is there to make a number of different Ruby versions available, but you have to install them first. In your case, I think you need to run this:
rbenv install 1.9.3-p194
After that, the version will be available, and you shouldn't see the warning anymore.

how can I run shell script line by line [duplicate]

I'll love something like Microsoft Visual Studio's line-by-line debugging in bash, with current variables values and so.
Is there any tool or way to do it? set -x and set -v are nice but not perfect.
See bashdb.
If it's installed on your system, see man bashdb.
If it's not installed, see http://bashdb.sourceforge.net
Yes. Use "bashdb" from http://bashdb.sourceforge.net/
Latest version at time of writing
http://sourceforge.net/projects/bashdb/files/bashdb/4.2-0.8/
If you are on a Mac (like I was) then you might need to install the GNU version of Bash.
I did that using "MacPorts"
http://www.macports.org/
Once you have MacPorts...
port install bash
Then follow the instructions to
./configure (in bashdb unpacked directory)
make
sudo make install
Then add the folder where bashdb can be found in your PATH

Trouble trying to install MIT-Scheme on MacOSX Snow Leopard

I am trying to install MIT-Scheme so that i can use it off my terminal instead of using an IDE, however, I am having difficulty trying to find tutorials that are actually up to date and works.
You can install MIT Scheme through Macports, and it will probably take a long time (it's compiling it from source, I think). You can also get a precompiled binary from here which will install an MIT-Scheme.app which starts Edwin an Emacs port or something which includes a Scheme debugger and REPL. But you can also start it from the command line.
Check to see where it installed to, on my machine it's here /Applications/mit-scheme.app/Contents/Resources/ but that might vary. Add this directory to your PATH by editing ~/.bash_profile and adding this:
export PATH=$PATH":/Applications/mit-scheme.app/Contents/Resources/"
Check with which mit-scheme to make sure it installed correctly.
As for Racket, there's also a precompiled binary available from here. (It might be in Macports but it might not be, or in Fink, I don't know. I try to avoid those and use Homebrew if possible.) This is a dmg file which you can extract and put wherever you want. I put mine in ~/bin and added ~/bin/racket/bin/ to my PATH as well, same process as above, but you can put it anywhere, /Applications/ or whatever.
Good luck.
This seems like a odd answer since it's about Racket for a question that was originally about MIT Scheme, but since you tried Racket too...
To run Racket from the terminal, you need to use the racket executable, which is found in the bin subdirectory. For example, if you install it at /Applications/Racket-5.1, then you'd run /Applications/Racket-5.1/bin/racket. (And you could modify your $PATH or add some symlink to make it possible to run without specifying the full path.)
You can find the detailed answer here.
Here is a short version:
Download .dmg file of MIT-Scheme. 32-bit or 64-bit based on your hardware architecture.
After installation run the following commands
For 32-bit package:
sudo ln -s /Applications/MIT\:GNU\ Scheme.app/Contents/Resources /usr/local/lib/mit-scheme-i386
sudo ln -s /usr/local/lib/mit-scheme-i386/mit-scheme /usr/bin/scheme
For 64-bit package:
sudo ln -s /Applications/MIT\:GNU\ Scheme.app/Contents/Resources /usr/local/lib/mit-scheme-x86-64
sudo ln -s /usr/local/lib/mit-scheme-x86-64/mit-scheme /usr/bin/scheme
To run MIT-Scheme from your terminal just type 'scheme' in the command prompt.

Compiled vim from source on Mac OSX and getting 'shell returned 127' error?

On my Mac OSX 10.6 machine, I started to use MacVIM for vim. Then I noticed my terminal version was different to the MacVIM version (MacVIM was 7.3 and my terminal version 7.2)... I thought they used the same vim?
I need 7.3 for some of the features. So I set about wanting to update the terminal version. I basically cloned it using Mercurial (the perferred way according to the official site) and then did the usual to compile it. This did work and I now have 7.3 in my terminal. But, on some commands when exiting, I can this error:
/bin/bash: q: command not found
shell returned 127
Press ENTER or type command to continue
...I've tried my hardest to try and fix this problem, but trying to reinstall MacVIM, deleting the vim in my /usr/local/bin and compiling again and I just can't get rid of this annoying error.
Can anyone possibly help me? Am I doing this all wrong? ...most of the time I will be using MacVIM, but it'd be nice for me to have it in the Terminal - exactly how I'd have it on my Ubuntu servers.
Any help would be fantastic!
:!q is not :q!. This is probably not a bug.
The error message you're seeing is is most likely the result of accidentally typing :!q instead of :q!, which would be user error, not a bug. :!q shells out to run q, and your shell (bash) is not finding such a command and bails with 127. (For comparison, you might try :!true, :!false, :!vim %, to get a feel of this.)
There isn't really a “fix” for this, and ! is really useful for other purposes; maybe with more practice you'll make the typo less often. You could also try using ZQ instead of :q!; this has other disadvantages (a typo ZZ will instead save the file if it's edited, and ZQ specifically is a vim extension), but at least you see this error again.
The upshot here is basically check to make sure you typed in your commands right, I guess.
I'm not sure on the exact path, but somewhere a few folders deep into the Applications/MacVim.app folder is the vim executable that will also run in a terminal (Use the -g option to launch it in GUI mode).
You should be able to throw this in your .bashrc:
alias vim=/Applications/MacVim.app/Contents/MacOS/vim
This is the homebrew formula for vim. Try these settings for "configure" or just install homebrew and install vim from there.
system "./configure", "--prefix=#{prefix}",
"--mandir=#{man}",
"--enable-gui=no",
"--without-x",
"--disable-nls",
"--enable-multibyte",
"--with-tlib=ncurses",
"--enable-pythoninterp",
"--enable-rubyinterp",
"--with-features=huge"
system "make"
system "make install"

Resources