Installing Rails on a Mac Shouldn't Be As Hard As It Is
cabforward.com
cabforward.com
You are installing something that by it's nature requires a bit more understanding that just clicking on a .exe. Do you want to replace the default Ruby setup, which could potentially be used by something? Do you want to install new database servers? Do you want to modify Apache? Do you want to fiddle with SSH key gens? Do you want to have to delve in and change items of your .bash_profile? Do you trust an automated installer to be able to do it reliably on every single machine?
I'm not sure I'd have the confidence in something not going wrong and then sitting there with a half broken machine wondering what. At least this way at every step you can do the install > check & verify > confirm steps and make sure it's all business as normal.
I don't think it inherently require anything like that for _installing_.
There is essential complexity (e.g the complexity of developing a RoR app), and accidental, inessential, complexity.
Installation not being a one click / command process is inessential complexity. It's just that the people involved (and the people NOT involved) have failed to make it any better.
For example, one can install Apache/PHP/MySQL on a Mac in a single package in 1 minute (via MAMP).
jtm@vertex ~ $ find /usr/share -iname *.php | wc -l
165
jtm@vertex ~ $ find /usr/share -iname *.rb | wc -l
5855
Even if you don't use OS X Server, Ruby.framework has been part of the API since Leopard [1], so applications can (and do) depend on it.[1] https://developer.apple.com/library/mac/#documentation/MacOS...
> [...] accidental, inessential, complexity [...]
Sure, but when that complexity is so utterly minuscule, what's the point in shielding users from it? Especially when you could argue that it benefits the user who will, at the very least, roughly know what's powering his application?Well the default installation shouldn't. The default installation should be for someone who just wants to try Ruby out, that will just set things up to work, and won't interfere with anything else on the system (except for integrating with the webserver you're using). Like PHP does. Then they can mess around with Ruby, and as they learn about it, go back and change the installation or re-install as necessary.
> Do you trust an automated installer to be able to do it reliably on every single machine?
Well, yeah. Isn't that what installers are for? They're written by the team that developed the software. I assume they have a much better idea of how to properly install it than I do!
The hangup is usually installing the dependencies. I remember on Ubuntu this involved hunting down one library that wasn't listed on the RVM wiki. Maybe that needs to be fixed with either more documentation on the RVM wiki or a Ubuntu RVM package (that package probably already exists).
On OS X it requires getting GCC to work, again maybe that needs to be clearer on the RVM wiki.
On windows - well on windows I just install a Ubuntu VM and go back to that installation.
But fixing those simple things (documentation, possibly RVM package) is far easier than creating a whole new installation process.
Ruby does come with Mac. Ruby is not Rails. The default installation allows anyone to try Ruby.
I see this process somewhat analogous to learning a new musical instrument, like a violin. A professional violinist may care to customize many aspects of the instrument to meet his or her needs, including the turning of the instrument (perhaps he cares to set A to 416 to emulate Baroque turning). A beginner, by contrast, would just like to be handed a well tuned instrument ready to learn and experiment. Now, would it kill that beginner to set and tune his own set of strings, or maybe given the options to set his violin to Baroque turning as well? Certainly not - though the necessity and benefits of such an exercise would surely be lost on many beginners.
I'm really surprised Rails isn't just another component in the Heroku toolbelt. The default Ruby version in OS X is always outdated, the database preferred by Heroku (postgres) is also outdated in OS X, and getting the latest XCode or re-installing it to install brew to install postgres and changing the order of execution in the PATH to make sure it picks up the right version is a prescription for despair and angst. RVM only solves the Ruby and gem versioning problem.
Also see this relevant (and relatively recent) update on the project: http://yehudakatz.com/2012/06/05/tokaido-status-update-imple...
Often people come in having (naturally) tried to install it from their distro's package manager. First we have to explain to them why this is a bad idea and persuade them to remove it. Then, often they have tried to install it from source, passing some fucked up value to --prefix, and they have to be helped to clean that mess up.
Then we tell them to use rvm, but someone pipes up about rbenv and friends and we have to explain the differences. Then it turns out that they didn't have openssl-dev or something installed so they have to recompile ruby again, or someone has to try and remember the magic spell to compile the openssl bit of ruby separately, which nobody ever can.
THEN it turns out that all they want to do with ruby is run redmine, which has some other specific requirements that nobody in the channel knows or cares about.
Basically, when yehuda katz finishes that project of his, freenode will be measurably happier, although the problems with OS packages will remain, I imagine forever.
The real root of the problem is that a lot of the things which make the ruby ecosystem highly dysfunctional are the same things that make it so great. Primarily the fast pace.
Now we have rvm's and gemsets and bundles and additionally people trying to foist off alternatives to some of these, and the whole thing is beginning to look like an unholy mess.
Meanwhile, Debian/Ubuntu's package management continues to work pretty well at what it does.
Also, it's a good idea to use a development environment that's not too far from what you're running in production.
But what it does moves at about 10% of the speed of the ruby community (at least post-Rails). I'm not saying that the ruby culture is better—it obviously has serious consequences for stability and leads to all manner of headaches. However it does mean that if a new and better idea of how to do something comes out, Ruby is probably one of the first places you can use it in production.
My feeling is that the benefits outweigh the costs if and only if you are a full-time developer in a paradigm that Ruby is good for (eg. traditional web development). If you are just dabbling in the language then Ruby will continuously pull the rug out from under you. And if you are just trying to install some software as an end-user, then Ruby is probably one of the worst possible platforms.
http://serverfault.com/questions/405994/state-of-the-art-dep...
And you're either stuck with this Mongrel-derived nonsense that is incapable of utilizing the computing power of the server to dynamically (de)allocate resources, requiring you to pick numbers at setup time, or you've got Passenger, which gets that right, but basically nails your deployment to one and only one Ruby.
(Yes, I've not had the best of days...does it show?)
I guess I'm lucky in that I only need one Ruby; I can't see an easy solution for using more than one at once.
$ /usr/bin/ruby -e "$(/usr/bin/curl -fksSL http://bit.ly/HyK0NG)
That looks terrifying.Are you saying you audit every piece of unsigned code you run?
I admit that putting bit.ly into the chain of trust is quite a bold step, but is it really that different to, say, the rubygems server? Or your wireless router?
EDIT: also, LOL at "mundanes."
Imagine your ISP's router gets backdoored.
Imagine if the server you got your bash from gets backdoored.
Imagine if the rails repo gets backdoored.
Imagine if the plant where apple images the macbook HDDs gets backdoored.
Imagine all the people, living for today...
(But yeah, personally, I'd forgo the bit.ly part as its unnecessary.)
Although, I wonder how hard it would be to set up some text with CSS that looks like one string, but is actually another. e.g. the user would see
https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb
but when copied-and-pasted is revealed to actually be something like https://raw.github.com/mxel/homebrew/master/Library/Contributions/install_homebrew.rbYou're downloading and running in one go. If someone puts a badfile up for 1 minute, then restore it to normal, and you get hosed, it's pretty hard to check that, because the download link looks fine now. You cannot try to figure out what happened or who did it to try to track down the culprit.
Indeed, using signed code is massively preferable, and it is increasingly common.
I was about to write that you can't operate running only signed code, but if you consider git hashes a form of signing then I suppose you largely can these days. However, running unsigned code is still so common that I don't think you can really single out people who pipe curl into sh.
What else would you suggest I do to make it less terrifying?
e.g. Deploying to Heroku is in fact very easy. Ok you have to mess around with ssh keys, but you don't want that to be automagic - you want to have some understanding of why what you are doing is secure, and why anyone else can't access your code.
Until then, all the conversation about standards, best practices, and tutorials are far less accessible.
If a technology is truly supposed to be accessible it needs to actually, be accessible instead of carrying an air of superiority, otherwise software continues to suffer.
I'm also not sure where the idea is coming from that Rails shouldn't be accessible to developers. If you have some wider posts or links I'd love to read some more.
I published it to help others avoid the pain I went through, and to share what I've learned so far. Given that it has had over 15,000 views so far (mostly search traffic), I'd say it's doing its job.
A few weeks ago, I used my own tutorial to set up a new MacBook Pro, and noticed that the latest version of the Xcode Command Line Tools and Homebrew seem to play well now. Originally, the separate CLT download from Apple and Kenneth Reitz's osx-gcc-installer resulted in errors when installing Homebrew, but I'm planning on trying them again soon and updating my tutorial with my findings.
I'm also planning on evaluating the new RailsInstaller for Mac, but when starting out, I recommend learning the hard way to understand what each tool does and to pick up some basic command line skills.
Uh, what? http://railsinstaller.org/ has a Mac version too!
It's right on their home page (if you're browsing from a Mac; it shows you the Windows version if you're browsing from Windows...)
https://github.com/downloads/railsinstaller/railsinstaller-n...
If I'm working on my own projects tho, running ruby local on OS X is the way to go. Much less overhead.
Personally, I just installed Arch Linux on my Air. With the SSD, it boots in seconds, even on an encrypted root. I can use whatever window manager I want, and all the tools I need for work are there or easily accessible. No hoops, no tricks, no outsmarting the operating system.
Requires sign in, but free otherwise.
1. Editorialized headline
2. It's easier than this article-- you don't have to install XCode: https://github.com/kennethreitz/osx-gcc-installer/
3. There are some smart folks working hard to make it easier: http://www.kickstarter.com/projects/1397300529/railsapp
And we should care because?
The article is fine, the headline is correct (even if editorialized), and it can potentially save new users some time.
"I'm coming from a Windows world, where installing Rails and all the tools is as easy as hitting up RailsInstaller.org, downloading an .exe file, and having my environment set up in a few minutes."
I titled my article "Read This Before Installing Rails" because Rails is not just a Ruby gem, it is a complex and rapidly evolving ecosystem. Sure, if you want to see Rails running on your Mac you can use the installed system Ruby 1.8.7 and "gem install rails". But if you want to do development, you'll need to update (and keep updated) all the related gems and packages that are an essential part of the Rails habitat. Judging from the comments and help requests I see, that's not easy.
Packages such as RailsInstaller, Cinderella or the BitNami RubyStack are great but they inevitably slip further and further behind the evolving state of the Rails ecosystem. I'm hoping the design of Yehuda Katz's Tokaido will avoid this issue. In the meantime, yes, it's difficult to install (and keep current) a useful and fully functioning Rails development environment on a Mac (or any other machine!). I say that from the experience of attempting to keep my "Installing Rails" article current.
For example, would you like to develop using Ruby 1.9.3 (the current recommended version) and deploy to Heroku (which now supports Ruby 1.9.3)? You'll need to update to the unreleased 1.2.0.pre.1 bundler (which requires a "gem uninstall" not a "gem update"). That's true today. Maybe it'll change tomorrow.
A rapidly evolving ecosystem is not a bad thing. Rails is a powerful, widely used, and well-supported development platform. The constant changes bring increased utility. If you can keep up and find the right advice. The author's article is sound and offers some of that good advice.
user@brand-new-mac $ which rails
/usr/bin/rails
What? OSX has shipped with (some version of) Rails since Leopard. You don't need to install a compiler or compile anything to use Rails on a Mac. It comes with sqlite3, too. $ /usr/bin/rails
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
> The basic database program that Rails uses is SQLLite3, and you will need to install this to work with it.yet Tiger had sqlite3 already.
What's more, Ruby is installed already. One can 'gem install rails' and have the latest version landing in /Library/Ruby/Gems
At least that was what happened when I tried to install rails on my brand new macbook air.
To be fair though, open source software hates me. This has been pretty much the same experience I've had every single time I've tried to install anything with gem install, apt get or yum install. On every flavor of linux/unix on any box I've ever touched.
You should be running a fairly recent version to keep up with patches or match your server, you should be running RVM so you can keep a gemset and use bundler, and you should use homebrew to make installing other packages easier.
Not that any of that is difficult, and you're right to a degree: you can get started learning using one command and go from there.
It's really not that complicated.
Why not develop against a VM running the same OS as your server?
I think very few Rails apps need to run on OS X, however.
This hasn't solved the problem of Ruby being difficult to install, it's just added ANOTHER problem of having to learn to install a VM manager and a whole new OS, plus using up far more system resources. Seems to me like that's just making things worse.
It solves the problem of Rails being hard to install on OS X... because it obviates the need to install Rails on OS X. And there's no new OS to learn -- the VM runs the same thing as your server. If you don't know how to use the OS that's running on your production server, that's a bigger problem.
I've been developing this way for years. Additional benefits include: you can easily have multiple VMs with different configurations, you can snapshot/backup/restore a VM very easily, crashing a VM doesn't crash your computer, and it's relatively easy to share a fully configured VM with another developer (even if their primary OS is something totally different).
Similarly, when you start a new web app, of course a monolithic framework like Rails is great and is flexible enough to roll in all your business logic. Somewhere around 50k lines though, you start getting that ball of mud feeling and managing changes across the entire code base starts to become onerous. At that point you realize the sysadmin overhead, and cost of defining and maintaining slow-moving services interfaces allows you to turn your ten-person team into ten ten-person teams and get a reasonable productivity multiple out of the deal.
It's a major barrier to learning and I hate that it's as complex as it is. Should be turn-key.
Now try installing rails on a windows machine; that's the real pain in the ass.
working through these things was a huge help and eye opening experience for me. being new to OOP and web app development it seems like there is a never ending list of things to learn, and everyone out there with their computer science degree has the knowledge already that i am missing. so i guess it is encouraging to see a list of things that this "engineyard training provider" is struggling with, and i worked through it all and have a pretty good grasp on now.
Ultimately, putting your dev environment on a server image makes way more sense.
Much of the time, development can be done in all sorts of ways that needs little connection to the final production environment.