Friday, May 18, 2012

Installing MonoDevelop 3 on Ubuntu Oneiric and Mint 12

I really like being able to develop in .NET on linux, and I think that the mono team has come a long way in its efforts to make mono-based applications production-viable.  Sadly, I'm guessing that the majority of mono developers use mac, opensuse, or windows because those are the only platforms that dependably have pre-built binaries and installers.  Since I use Mint (a variant of Ubuntu), I'd really like a simple method for installing a current version of MonoDevelop.

Recently, I needed to install Mint on my new laptop and so I payed close attention to how I installed MonoDevelop and turned it into a script -- which you can now use!  I've tested it on a fresh Mint 12, but it should also work on Ubuntu Oneiric.

The script:

  1. Installs the git client and the dependencies necessary to build MonoDevelop from source.
  2. Downloads the source code for MonoDevelop from github.
  3. Configures the build script to install the stable profile into /usr/local (/usr/local/monodevelop-3.0.1/ will be the full path).  However, you can change the defaults by editing the variables at the top of the script.  
  4. Builds and installs MonoDevelop
  5. Creates a script in $INSTALL_PREFIX/bin that simply calls the real monodevelop script.  This is because you can't just create a symbolic link.  This step has a bad smell to it - if you know a better way to do what I'm trying to do, please leave a comment.
  6. Adds two environment variables into your ~/.bashrc file
You should also know that it has a dependency on gnome-sharp2, so I don't know what to do if you're not using something based on gnome.  If you want to save some hard drive space after the install, you can delete the MonoDevelop source code directory that gets downloaded.

You can download it here: https://raw.github.com/jar349/tools/master/install-monodevelop.sh.

Don't forget to run it with sudo!


32 comments:

  1. No problem! I'm glad that you found it to be useful!

    ReplyDelete
  2. No joy for me on Lubuntu 12.04..probably a really obvious reason that I'm just ignorant of as a Linux noob?

    ReplyDelete
    Replies
    1. You're using Lubuntu, which is based on the LXDE desktop, not gnome. I mention in my post that I don't know what happens in this situation:

      "You should also know that it has a dependency on gnome-sharp2, so I don't know what to do if you're not using something based on gnome."

      I'd love to know what your exact error was so I could see what's happening. Maybe it's something simple that I could fix in my script.

      Delete
  3. Hi John, I have now installed 2.8.x from badgerports (I'll live with being slightly behind for now) which runs fine, but something in your script redirects monodevelop to the 3.0.2 directory that I failed to create..how can I undo this change? Thanks, Myles.

    ReplyDelete
    Replies
    1. Likely, you have a monodevelop script in /usr/local/bin that points to the 3.0.2 directory. Take a look at that file - if it looks like this:

      #!/bin/sh

      /usr/local/monodevelop-3.0.1/bin/monodevelop

      that's my script: delete it. If your badgerports installed correctly, then you should be good to go.

      Delete
  4. Thanks for this, it was very helpful and worked perfectly. The only issue I'm seeing is that after I exit the application, it's relaunching it. This only happens once. Strange... I'm running on Ubuntu 12.04 x64

    ReplyDelete
  5. That IS strange... is the monodevelop script in /usr/local/bin mangled or something? Does it contain two calls to monodevelop?

    ReplyDelete
  6. For ubuntu 12.04 you will need to:
    sudo apt-get install autoconf automake intltool

    ReplyDelete
  7. Edgar, I'll add those to the script, thanks!

    ReplyDelete
  8. Hello, John!
    Sorry, for my English, but I think, that there is some mistakes in your script.
    First is in
    "sudo apt-get install ***packets*** install ***packets***"
    There is second install. Please, fix it.

    ReplyDelete
  9. @egslava, thanks for catching that. I've fixed it.

    ReplyDelete
  10. Line 42 - change

    echo ("Th

    to

    (echo "Th

    And it works with every version - now installing 3.0.3.5.

    Cheers

    ReplyDelete
  11. @Sparrow: I've updated the script. That was a silly bug; thanks for the catch!

    ReplyDelete
    Replies
    1. Not at all - thanks to you for a really superb script.

      Delete
  12. thanks John,

    worked perfectly

    ubuntu 12.04 64amd

    ReplyDelete
  13. Thanks! Great work.

    Did you ever try to install Monodevelop into your user directory? There are all kinds of strange problems going on.

    First I need to install it using sudo since it fetches a lot of dependencies. It isn't able to create the 'bin/monodevelop' file. The 'bin' folder doesn't normally exist in my home folder. So I need to create a ~/bin folder manually. Then I need to delete all the monodevelop-3.0.3.5 folder that was created since it has 'root' as its owner. I don't want that in my home folder. Also I need to delete the 'monodevelop' folder the script created in order to download, compile and build the sources. That folder was also owned by 'root' and if I just execute the script again without the root rights the generated '' is again owned by root. I know I probably could use chown or something -- still I want it worry free so I just to it from scratch as user.

    After all that I execute the script a second time -- this time without sudo. Everything works except that I type in monodevelop on the console to run it. Something probably didn't work with the .bashrc file.

    Here is the output after step 2:

    Note that '/home/peter/monodevelop-3.0.3.5/share' is not in the search path
    set by the XDG_DATA_HOME and XDG_DATA_DIRS
    environment variables, so applications may not
    be able to find it until you set them. The
    directories currently searched are:

    - /root/.local/share
    - /usr/local/share/
    - /usr/share/

    make[4]: Leaving directory `/home/peter/Desktop/monodevelop/main'
    make[3]: Leaving directory `/home/peter/Desktop/monodevelop/main'
    make[2]: Leaving directory `/home/peter/Desktop/monodevelop/main'
    make[1]: Leaving directory `/home/peter/Desktop/monodevelop/main'
    $final_exit

    -------==<( Adding a monodevelop script to /home/peter )>==-------

    -------==<( Adding Environment Variables to /home/peter/.bashrc )>==-------
    ./install-monodevelop.sh: 55: ./install-monodevelop.sh: source: not found

    -------==<( Install Complete )>==-------
    To start monodevelop, just type: monodevelop
    It's up to you to create panel launchers and/or start menu entries.


    It would be very nice if the dependencies could be first installed by root and then Monodevelop using user rights in the home folder.

    ReplyDelete
  14. Haha -- I just noticed that the monodevelop-3.0.3.5 folder is still owned by root. I don't even know how that is possible??? I executed the install script without sudo.
    The compile/build folder monodevelop created by the script has the user as owner.

    I think the console had still the root password stored when I started the script. The script asks when it tries to install the dependencies for the root password...unless the console stored it.

    So I now edited the install script and commented out the Installing Dependencies part and remove the sudo from make install. Also I commented out the chown $SUDO_USER:$SUDO_USER $HOME/.bashrc line.

    ReplyDelete
  15. I hadn't really considered installing to one's home directory. I'm glad that you were able to get it to work. I guess I could add a --local argument for others who might want to do the same as you.

    I'd have to think about what to do in the case that users don't have the necessary dependencies installed.

    At any rate, thanks for updating us with the changes you made to get it to work!

    ReplyDelete
  16. Hi,
    yes it would be nice to have it working when installing it to the home directory.

    I also needed to add export XDG_DATA_HOME and XDG_DATA_DIRS to the startup script manually. Otherwise the AssemblyViewer in Monodevelop didn't work.

    Unless you want to split it into two script it has to be possible to start the script using sudo to install the dependencies but when the --local argument is used, the script shouldn't install the files as 'sudo user' anymore but as current user.

    Looking forward to using your updated script. I don't trust my own fixes ;)

    Thanks!!!

    ReplyDelete
  17. Hi John,

    My name is Tina, and I’m the community manager for Atomic Reach, a content curation platform that connects bloggers with brands looking for high-quality content. I am reaching out to you about an opportunity to be featured on http://bandofcoders.com.

    Atomic Reach is working with Band of Coders to invite a select group of bloggers to join the Band of Coders community. We’re looking for blogs on topics such as software development, web development, and lean development.

    What’s in it for you? The Band of Coders editorial team will only publish an excerpt and link to your posts so they’ll be sending new readers to your blog. It’s also a new way to interact with and reach new people, and boost your blog’s search engine ranking.

    Social Media Love for you too! Beyond having your content featured on the Band of Coder’s site, they will also be promoting your content via Facebook, Twitter, Google+, Pinterest and Tumblr!

    If you’re interested, please send me an email at tinajin @atomicreach.com with “Coders” in the subject line, and I’ll send you a link to activate your account. I’d also be happy to answer any questions.

    We look forward to you joining the Band of Coders community.

    Sincerely,
    Tina Jin
    Community Manager

    ReplyDelete
  18. Hi John, I need some help , I am a VB Senior Developer in Windows and i would like to know how to do my work in Linux Ubuntu 11.10 to start.

    I follow you excelent post, i have installed the mono IDE, i start a blank solution but when i try to add a GTK2 form i receive the message D-buss is not running and at the end of the script an error message when creating the environment variables.

    Would you can help me, My personal Email is alfredoluis.torres@gmail.com, if you can help me pls send me an email.

    I will appreciate any help.

    ReplyDelete
  19. Alfredo: What desktop environment are you running on your Ubuntu 11.10 machine?

    ReplyDelete
  20. curl -L https://gist.github.com/3713087 | bash

    ReplyDelete
  21. Thanks for the small tweaks and the additional functionality. I think it might finally be time to get a bit more complicated and update the script to optionally install F# - or to optionally install locally. Both seem like interesting things a user might want to do.

    ReplyDelete
  22. Hello, is there a way to remove it afterwards?

    ReplyDelete
  23. Yes. All you did was compile from source, so remove the /usr/local/monodevelop directory, remove the script from /usr/local/bin, and remove the XDG_DATA exports from your .bashrc file. All gone!

    ReplyDelete
  24. Thank you :) http://neurone-multithread.blogspot.it/2012/11/sviluppare-in-modo-nativo-e-in-c-su.html

    ReplyDelete
  25. What script where to find thise script? build monodevelop what should i do in thise step?

    ReplyDelete
    Replies
    1. https://raw.github.com/jar349/tools/master/install-monodevelop.sh

      Delete