Mono won't run with script or sudo

1

Whenever I try run a program like this "sudo mono Program.exe" or from a bash script. I get the error: mono: command not found.

I am running a VPS on CentOS 6 x64 bit.

Any ideas?

Skowt

Posted 2012-05-20T18:09:42.813

Reputation: 33

4Well, mono is not in your PATH. How did you install it? – slhck – 2012-05-20T18:13:43.403

Answers

2

Try the command

which mono

and see which path is returned. I'm not sure on how Mono is installed, but it's possible that you could be running the executable from your home directory, instead of somewhere like '/usr/bin'.

Try creating a new temporary user and executing mono then and see if you get the same error. It seems likely that the program isn't in a location that is included in your Path variable, so it's possible that it didn't install correctly and/or you or the installer didn't move the program to /usr/bin or /usr/local/bin

Joe Bentley

Posted 2012-05-20T18:09:42.813

Reputation: 315

Please do not do that with mv. If you later upgrade then you will have an old binary in /usr/bin and a newer one in /usr/local/bin/. Creating a softlink is a much better idea (though not the proper solution either). – Hennes – 2014-11-11T13:11:57.677

Ran the which command. Received this: /usr/local/bin/mono – Skowt – 2012-05-23T17:18:44.277

1Change the path from /usr/local/bin/mono to /usr/bin/mono using the above answer. Here's the actual command for anyone else: mv /usr/local/bin/mono /usr/bin/mono Thanks very much Joe! :D – Skowt – 2012-05-23T17:31:17.490

0

You are running sudo mono Program.exe. Lets analyse this:

Cause:

As a user you have a path. You type 'sudo (something) and your shell find the sudo binary in your path and starts it.

Sudo causes you yo switch from your user to uid 0 (root) and the path which is set for this root user.

The latter path can be difference. In which case you get the 'file not found'.

Solution:

Either specify the full path (e.g. sudo /usr/local/bin/mono Program.exe) or add /usr/local/bin to the path for root.

Hennes

Posted 2012-05-20T18:09:42.813

Reputation: 60 739