如何在 macOS 上安装 Mono,以便 Mono 在终端中工作? [英] How to install Mono on macOS so mono works in terminal?
问题描述
我正在尝试在 Mac(OS X 版本 10.10.5)上运行 Mono 安装,虽然安装表明它已成功完成,但我无法从终端调用 mono.
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.
为了安装它,我以 root 身份运行了 uninstallMono.sh 以确保我们没有任何剩余的东西,然后运行 MonoFramework-MDK-4.0.4.1.macos10.xamarin.x86.pkg.安装程序似乎成功完成,但尝试调用单声道返回
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:单声道:找不到命令
-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
...但它不存在于 /usr/bin
中,并尝试使用 which mono
查找其可执行文件不返回任何内容.
...but it isn't present in /usr/bin
and attempting to find its executable using which mono
returns nothing.
推荐答案
更新(因为两年多后仍然有浏览量):
最新版本的 Mono (5.x) 安装过程会在 /etc/paths.d
中创建一个文件 (mono-commands
),其中包含以下路径:
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
所以 /usr/local/bin
不再使用了...
So /usr/local/bin
is no longer used...
较新版本的 mono 符合El Capitan"要求,即不在 /usr/bin 中安装任何东西,因此现在使用 /usr/local/bin.我不确定从哪个 mono 4.x 版本开始...
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...
但我会假设您的路径中没有/usr/local/bin(?),请尝试:
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
就我而言,我安装了 4.2.0:
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 "$@"
这篇关于如何在 macOS 上安装 Mono,以便 Mono 在终端中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!