How to install Mono on macOS so mono works in term

2019-01-21 06:28发布

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.

标签: macos mono
8条回答
三岁会撩人
2楼-- · 2019-01-21 06:54

It is better to use the next export:

export PATH=$PATH:/Library/Frameworks/Mono.framework/Versions/Current/bin/

  1. You don't modify the previous order of PATH (It's very important!!)
  2. 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.

查看更多
做个烂人
3楼-- · 2019-01-21 06:54

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.
                                                                    
查看更多
来,给爷笑一个
4楼-- · 2019-01-21 07:05

In OS X El Capitan, run the following in Terminal to support mono command

export PATH=/Library/Frameworks/Mono.framework/Versions/Current/bin/:${PATH}
查看更多
爷、活的狠高调
5楼-- · 2019-01-21 07:09

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:

  1. Reboot into recovery mode (reboot and hold down Cmd-R)
  2. Open a terminal
  3. Use this command: csrutil disable

Reboot and run the command that worked prior to El Capitan

  1. 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.

查看更多
做自己的国王
6楼-- · 2019-01-21 07:10

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.

查看更多
可以哭但决不认输i
7楼-- · 2019-01-21 07:10

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/

查看更多
登录 后发表回答