How to install Mono on macOS so mono works in terminal? - macos

I'm trying to get a Mono install running on a mac (OS X version 10.10.5), and while the install states that it's completed successfully, I'm not able to call mono from the terminal.
To install it, I ran uninstallMono.sh as root to ensure we didn't have any leftover cruft, then ran MonoFramework-MDK-4.0.4.1.macos10.xamarin.x86.pkg. The installer appeared to complete successfully, but an attempt to call mono returns
-bash: mono: command not found
The mono framework does appear to be installed:
Lees-Mac-Pro:Downloads kevinmack$ cd /Volumes/Macintosh\ HD/Library/Frameworks/
Lees-Mac-Pro:Frameworks kevinmack$ ls -l
total 32
lrwxr-xr-x 1 root wheel 71 Jan 20 2015 AEProfiling.framework -> ../../Applications/Motion.app/Contents/Frameworks/AEProfiling.framework
lrwxr-xr-x 1 root wheel 74 Jan 20 2015 AERegistration.framework -> ../../Applications/Motion.app/Contents/Frameworks/AERegistration.framework
lrwxr-xr-x 1 root wheel 74 Jan 20 2015 AudioMixEngine.framework -> ../../Applications/Motion.app/Contents/Frameworks/AudioMixEngine.framework
drwxr-xr-x 8 root admin 272 Sep 12 11:24 Mono.framework
lrwxr-xr-x 1 root wheel 60 Sep 9 22:16 NyxAudioAnalysis.framework -> /System/Library/PrivateFrameworks/NyxAudioAnalysis.framework
drwxr-xr-x 5 root wheel 170 Jan 20 2015 PluginManager.framework
drwxr-xr-x 8 root wheel 272 Sep 9 22:19 iTunesLibrary.framework
...but it isn't present in /usr/bin and attempting to find its executable using which mono returns nothing.

In OS X El Capitan, run the following in Terminal to support mono command
export PATH=/Library/Frameworks/Mono.framework/Versions/Current/bin/:${PATH}

Update (since this is still getting views two+ years later):
The latest versions of Mono (5.x) installation process creates a file (mono-commands) in /etc/paths.d that contains the path of:
/Library/Frameworks/Mono.framework/Versions/Current/Commands
So /usr/local/bin is no longer used...
Original
Newer versions of mono comply to the "El Capitan" requirements of not installing anything into /usr/bin and thus now /usr/local/bin is used. I am not sure which mono 4.x release that started in...
But I would assume that you do not have /usr/local/bin in your path(?), try:
export PATH=/usr/local/bin:${PATH}
which mono
which mcs
In my case, I have 4.2.0 installed:
$ which mono
/usr/local/bin/mono
$ which mcs
/usr/local/bin/mcs
$ mono --version
Mono JIT compiler version 4.2.0 (explicit/2701b19 Mon Aug 31 09:57:28 EDT 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
$ cat `which mcs`
#!/bin/sh
export PATH=$PATH:/Library/Frameworks/Mono.framework/Versions/4.2.0/bin
export PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/External/pkgconfig:/Library/Frameworks/Mono.framework/Versions/4.2.0/lib/pkgconfig:/Library/Frameworks/Mono.framework/Versions/4.2.0/share/pkgconfig:$PKG_CONFIG_PATH
exec /Library/Frameworks/Mono.framework/Versions/4.2.0/bin/mono $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/4.2.0/lib/mono/4.5/mcs.exe "$#"

It is better to use the next export:
export PATH=$PATH:/Library/Frameworks/Mono.framework/Versions/Current/bin/
You don't modify the previous order of PATH (It's very
important!!)
You will use the current version (when update
the version it isn't necessary to change the variable PATH)
Another option (best option) is to include a new line at the end of the file /etc/paths with the content:
/Library/Frameworks/Mono.framework/Versions/Current/bin
In this case, the path will be available for all users on the system.

After the first installation of Mono Framework using brew cask I found out that brew itself offers Mono (!)
I uninstalled Mono first.
$ brew cask uninstall mono-mdk
And installed it using brew install mono and removed all the configuration changes in ~/.zshrc.
Looks like it's much nicer:
$ type mono
mono is /usr/local/bin/mono
$ mono --version
Mono JIT compiler version 4.6.2 (Stable 4.6.2.7/08fd525 Tue Nov 22 22:05:18 GMT 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
I first used brew cask to install Mono Framework and had to add /Library/Frameworks/Mono.framework/Home/bin to PATH environment variable.
$ brew cask info mono-mdk
mono-mdk: 4.6.2.7
http://www.mono-project.com/
Not installed
From: https://github.com/caskroom/homebrew-cask/blob/master/Casks/mono-mdk.rb
==> Name
Mono
==> Artifacts
MonoFramework-MDK-4.6.2.7.macos10.xamarin.universal.pkg (pkg)
âžś kafunk git:(master) brew cask install mono-mdk
==> Downloading https://download.mono-project.com/archive/4.6.2/macos-10-universal/MonoFramework-MDK-4.6.2.7.macos10.xamarin.universal.pkg
######################################################################## 100,0%
==> Verifying checksum for Cask mono-mdk
==> Running installer for mono-mdk; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
Password:
==> installer: Package name is Mono Framework
==> installer: Installing at base path /
==> installer: The install was successful.
🍺 mono-mdk was successfully installed!
Since I use oh-my-zsh I defined MONO_HOME in ~/.zshrc and adjusted PATH accordingly:
export MONO_HOME=/Library/Frameworks/Mono.framework/Home
export PATH=$MONO_HOME/bin:$PATH
With that mono is available:
$ mono --version
Mono JIT compiler version 4.6.2 (mono-4.6.0-branch/08fd525 Thu Nov 10 20:28:28 EST 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: yes(3.6.0svn-mono-master/8b1520c)
GC: sgen

I've been watching this page because I too had problems with installing Mono (for the first time) on El Capitan. I found the framework was installed but the commands were not put into the /usr/local/bin. Symlinking them didn't seem to work because I would get errors when trying to use the mono command and it was looking for libraries in the wrong place.
What I finally found worked (by trial and error) was setting $PATH to the Mono framework using the command in terminal:
export PATH=/Library/Frameworks/Mono.framework/Versions/4.2.0/bin/:${PATH}
Since I'm not a programmer or coder (at least not for a long time and never on OS X), this allowed me to run Duplicati using mono (which was why I wanted it in the first place), but I'm not sure if this is the correct way to solve this or even if this should be done at all. Anyone with actual programming experience to comment or clarify?

El Capitan now protects certain system directories in "rootless" mode (a.k.a. System Integrity Protection). If you run the command ls -lO /System/Library/LaunchDaemons you'll see that the directories and files under there are now marked as "restricted."
You can disable rootless mode like this:
Reboot into recovery mode (reboot and hold down Cmd-R)
Open a terminal
Use this command: csrutil disable
Reboot and run the command that worked prior to El Capitan
Install Mono latest version.
When you're done, it is highly recommended that you re-enable SIP by following the same steps, but using csrutil enable in step 3.
I ran into a problem with the same root cause while trying to get pear/pecl modules and macports/homebrew apps installed. Those typically need to install files into /usr/include and /usr/lib, which are also now restricted.
Note: Previous answers around the Internet about this problem give you instructions for modifying NVRAM settings, but Apple stated that the NVRAM method would stop working with El Capitan's public release. The GM release has already disabled the NVRAM workaround, so this answer should get you what you need moving forward.

open .bash_profile
add export PATH=$PATH:/Library/Frameworks/Mono.framework/Versions/Current/Commands to it
done!

try installing the older version.
3.4.0 is working for me OSX (10.10.5)..
http://origin-download.mono-project.com/archive/3.4.0/macos-10-x86/

Quick Summary:
Atm, the mono framework installer only works correctly if you install it to root. It will automatically add /Library/Frameworks/Mono.framework/Versions/Current/Commands to $PATH, but I don't know if you will need to add /Library/Frameworks/Mono.framework/Versions/Current/bin/ by hand or if everything just works. (Commands is a symbolic link to bin, but it still may not work)
More in-depth:
I recently installed mono from MonoFramework-MDK-4.8.0.520.macos10.xamarin.universal.pkg. I installed it to /Volumes/osxapps/ instead of root, but the installation still expected everything to be in root. It added /Library/Frameworks/Mono.framework/Versions/Current/Commands to $PATH but everything in /Library/Frameworks/Mono.framework/ was just empty directories. All the files resided in /Volumes/osxapps/Library/Frameworks/Mono.framework/.
Furthermore, a lot of what was in /Volumes/osxapps/Library/Frameworks/Mono.framework/ including Commands were not folders but symbolic links that didn't work because they expected the folders to be in root. For example: If everything were installed in root,
/Library/Frameworks/Mono.framework/Versions/Current/Commands is a symlink to /Library/Frameworks/Mono.framework/Versions/Current/bin and /Library/Frameworks/Mono.framework/Versions/Current/ is also a symlink.
I added:
export PATH="/Volumes/osxapps/Library/Frameworks/Mono.framework/Versions/4.8.0/bin:$PATH"
to .bash_profile, in ~/, which allowed me to run the commands/executables, but they all died with errors because they were still expecting things to be in root.
So I copied the folder from /Volumes/osxapps/Library/Frameworks to /Library/Frameworks/ and that solved all the errors and things are working properly but now I have two copies of Mono.framework and I didn't want it installed in root in the first place, because root is on an ssd, and space is limited.
A better solution would be to uninstall mono according to the instructions at bottom of this page and then reinstall on root.
However, it would still be better, for me, to install on /Volumes/osxapps/, but I don't know the best way to go about doing that. (I could probably just recreate a bunch of symbolic links). I was going to tell the mono-project that their installer mucks everything up if you don't install to root, but I'm not sure the best way to go about doing that either. So, instead I have posted here, with what I have learned so far, in the hope that it could help someone else.

Related

How to know how I installed Node on macOS?

I know that I have Node installed but I don't remember if I used NVM, Brew or if I downloaded it from the official Node website.
Is there any command I can use to figure out how I installed it in the first place?
Note: I use a zsh shell on macOS
A good indicator is to check where it is installed:
ls -l $(which node)
For brew, this will yield something like
lrwxr-xr-x 1 flyx admin 30 Sep 12 17:02 /usr/local/bin/node -> ../Cellar/node/16.9.1/bin/node
NVM seems to install it somewhere in ~/.nvm but I don't know the specifics. I have no idea what the installer does.

Unable to build and install Valgrind on macOS High Sierra

I cannot install Valgrind on macOS High Sierra. It's not available through brew. I've tried with 3.10. After make install, I get this message:
configure: error: Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x and 14.x (Mac OS X 10.6/7/8/9/10)
Homebrew says:
valgrind: This formula either does not compile or function as expected on macOS
versions newer than Sierra due to an upstream incompatibility.
Error: An unsatisfied requirement failed this build.
I had the problem like this.
So, I found the solving. You should install valgrind by this code
brew install --HEAD valgrind
I have created a port of valgrind 3.13.0 to work on macOS High Sierra (10.13.x). You can get it here: https://github.com/padiakalpesh/valgrind_3.13_high_sierra
Once you have obtained the source, run the following commands from inside the source directory:
./configure
make
sudo make install
brew install Valgrind has some compatibility problem when installing on latest macOS but there is a workaround with this problem. You must be getting this error message when you try to install it using brew.
$brew install valgrind
valgrind: This formula either does not compile or function as expected on macOS
versions newer than High Sierra due to an upstream incompatibility.
Error: An unsatisfied requirement failed this build.
-------------------------------------------------------------------SOLUTION--------------------------------------------------------------
Step1: $brew edit valgrind
Step2: Find this line in the file ->(url "https://sourceware.org/git/valgrind.git")
Step3: Replace it with -> (url "git://sourceware.org/git/valgrind.git")
Step4: $brew update
Step5: $brew install --HEAD valgrind
And Done!
Let me know if it still doesn't work.
Thanks!!
I have got this working in July 2018, for reference:
https://gist.github.com/AlessandroMinali/d8316d6cc650c97027433644c2ff31ee
Edit ./configure
- 5468: applellvm-5.1|applellvm-6.*|applellvm-7.*|applellvm-8.*)
+ 5468: applellvm-5.1|applellvm-6.*|applellvm-7.*|applellvm-8.*|applellvm-9.*)
- 5879: 16.*)
+ 5879: 17.*)
Run
./autogen.sh
./configure
make
make install
Create file ~/.valgrind.supp
# false positive for any executable (it seems)
# macOS 10.12.6
# valgrind 3.13.0
{
libtrace initialization false positive
Memcheck:Param
msg->desc.port.name
fun:mach_msg_trap
fun:mach_msg
fun:task_set_special_port
fun:_os_trace_create_debug_control_port
fun:_libtrace_init
}
Create file ~/.valgrindrc
--suppressions=$HOME/.valgrind.supp
Troubleshooting
if can not read suppresion file copy and paste the contents of $HOME
if it complains about clang versions, bump the first edit up
if it complains about Darwin version, bump the second edit up
using the brew install --HEAD valgrind also worked for me, but be sure to know that it will take awhile to pull the HEAD version, and build/install.
However, no other changes were needed.
I build the git head version of Valgrind on macOS fairly regularly. If you have xcode installed then there isn't much more to it than following the instructions here.
I'll update with my build script later.
As an alternative, you might want to consider clang sanitizers. This can be enabled in xcode, or with the -fsanitize=X option (where X is address, undefined, thread, memory and a few others).
Valgrind is a rather touchy piece of software, and requires updates for each major release of macOS.
As of February 2018, there is no released version of Valgrind which supports macOS High Sierra (10.13). You will need to use a development version of Valgrind, or use alternate tools. (Apple's Instruments may have some of the functionality you are looking for.)
MacPorts version started working for me in Sep 2018!
The command, for completeness sake (completes very fast - apparently, prebuilt):
sudo port install valgrind-devel
Version:
$ valgrind --version
valgrind-3.14.0.GIT
The following worked for me using the latest Valgrind release 3.14.0 (9th October 2018) on macOS 10.13.6.
VERSION="3.14.0"
wget -O - http://www.valgrind.org/downloads/valgrind-"$VERSION".tar.bz2 | tar xjf -
cd valgrind-"$VERSION"
# use --prefix=/path/to if you want it installed somewhere in particular
./configure
make
# may need sudo
make install
# test all is working
valgrind ls -l
These instructions are taken from the README inside the Valgrind release tar ball.

Apple's vim always used instead of homebrew

I'm seeing something very odd, and honestly I'm stumped.
The version of vim that comes with mac is outdated (7.3 instead of 7.4). I'm trying to install vim from homebrew, and I want to use that one instead of the default apple version.
I ran "brew install vim". It installed correctly in /usr/local/bin/vim. All good.
When I run "which vim", it prints "/usr/local/bin/vim". The Apple version of vim is installed at /usr/bin/vim. So the which command is telling me that I'm using the homebrew version of vim.
However, when I actually run vim, it still runs the Apple version
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 9 2015 23:58:42)
Compiled by root#apple.com
...
If I run the homebrew version explicitly, I see this:
$ /usr/local/bin/vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 23 2015 18:16:35)
MacOS X (unix) version
Included patches: 1-898
Compiled by Homebrew
...
I even tried moving /usr/bin/vim to /usr/bin/vim73 to try to force using the homebrew version. However, when I did this, here is what I see when I try to run vim:
$ vim --version
-bash: /usr/bin/vim: No such file or directory
$
What is going on? How can I get it to run the homebrew version of vim?
Start a new shell session and it’ll work.
Bash caches executables’ paths so when you run vim it looks at your PATH to find the first executable with this name. It caches it and the second time you run vim it remembers vim is actually /usr/bin/vim and runs that.
Since you haven’t restarted your Bash session its cache is still the same; hence the error you’re seeing. It has nothing to do with the way you installed vim.
If you don’t want to start a new shell session, you can run hash -r to tell Bash to clear its executables memory.
You forgot an argument:
$ brew install vim --override-system-vi

How do I install Image::Magick on mac os x?

I've attempted installing with brew:
brew install imagemagick
The installation seems to have completed successfully. However, when attempting to:
use Image::Magick;
I get the following error message:
Can't locate Image/Magick.pm in #INC
I don't know much about the perl system on a mac, or where brew might have installed Image::Magick (I'm told it should have installed the perl libraries as part of the imagemagick install).
AFAIK homebrew version of ImageMagick doesn't contain perl-magick. You should install it from the sources:
go to http://www.imagemagick.org/download/perl/
download http://www.imagemagick.org/download/perl/PerlMagick-6.85.0.tar.gz
open Terminal.app
cd ~/Downloads
tar xvzf PerlMagick-6.85.0.tar.gz
cd PerlMagick-6.85
perl Makefile.PL
make
make test
make install (or sudo make install)
All the above is guessing - I'm using MacPorts. MacPorts has two ports: ImageMagick for the basic ImageMagick and p5-perlmagick for the perl bindings.
On PerlMagick-6.89-1 there are 2 Errors and "make test" with
t/filter.t ........ Failed 1/58 subtests
and
t/mpeg/read.t ..... Failed 2/2 subtests
Fix first see
http://www.imagemagick.org/discourse-server/viewtopic.php?t=29759
Second
the problem is
https://rt.cpan.org/Public/Bug/Display.html?id=102482
see code
t/mpeg/read.t there is a checksum problem
Testcode:
20 testRead( 'input.m2v',
21 'd0d08bbb6ea2f9d5d76bc134a4785f3ab25d6b03d66c64bc43b6b2a9174582d7' );
22
23 #
24 # Motion Picture Experts Group file interchange format
25 #
26 ++$test;
27 testRead( 'input.mpg',
28 'bbffb8cfbd98a111f7ff625fbc2cf49485d92640de702a2e76c0852ead39c6f1' );
I think it's no serious problem or a very local.
Therefore in 99.9% off all cases a
sudo make install
is no problem.
Hopefully next time come a fix from PerlMagick Team.

Installing rhostudio gems on osxlion gives "please install build tools"

I installed rhostudio but I can't seem to install the gems using the provided scripts.
I get
Last login: Sat Mar 24 13:43:13 on ttys001
jay-pc:~ mac$ /Volumes/RhoInstaller/Install\ gems ; exit;
Please install building tools
logout
I'm a new ruby dev...
I don't know if this is referring to java or make etc. Or something ruby or gems specific.
I have jdk installed as I use the machine for java development.
Okay yes - birryree mentioned above that xcode is needed. This is the answer. It's actually the Gnu Compiler Collection that is required so if you don't care about getting xcode you can just download the osx GCC from here to save some bandwidth:
(lion here too)
https://github.com/kennethreitz/osx-gcc-installer

Resources