Bundler: "Failed to build gem native extensions", "Cannot allocate memory" - ruby-on-rails

I'm trying to get Rails working on Ubuntu for Windows(beta). I installed RVM, updated my ruby to 2.3.0, and installed Rails without any problem. When I try to generate a new Rails project, it goes well until Bundler runs. I am getting an identical error for many of my Gems. Here is a specific instance:
Installing byebug 9.0.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/djllap/.rvm/gems/ruby-2.3.0/gems/byebug-9.0.5/ext/byebug
/home/djllap/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160801-16013-15q7ntv.rb extconf.rb
Cannot allocate memory - /home/djllap/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160801-16013-15q7ntv.rb extconf.rb 2>&1
Gem files will remain installed in /home/djllap/.rvm/gems/ruby-2.3.0/gems/byebug-9.0.5 for inspection.
Results logged to /home/djllap/.rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/byebug-9.0.5/gem_make.out
I haven't had this problem running Rails on Windows or my Vagrant/Virtual Box VMs. I would love to get this working on Ubuntu for Windows though, so I don't need to worry about all of that VM stuff.

It appears your server is running out of memory. Either increase the amount of RAM, or add some swap space to help alleviate the problem.
Digital Ocean has a great tutorial on how to add swap space to a Ubuntu machine.

Unfortunately I think you might be out of luck with Ubuntu for Windows. The way it actually works is by translating the Linux commands into Windows, and Microsoft have only implemented some of those commands. Byebug (and many other gems) utilise native C extensions and it looks like some of these are failing.
Take a look at this article for more info. You might get the support you want one day, but since Microsoft don't want to focus on server technology, instead encouraging VMs, I would probably save myself the pain. Gem installs are flakey enough in native bash..

Add swap or increase you swap partition. Seems compiler using swap when compiling.
I have checked free mem state found there is free mem, but my ECS have no /swap, so I configured host swap on, then everything goes well. Hopes it can help.

Related

Ruby on Rails for Windows: how to get started without getting a different error every time?

I'm on Windows 8.1 and have been trying to get Rails to work on my computer for quite some time now. I followed the guides to install Ruby and Rails and everything correctly, but whenever I try to execute any kind of Rails command through PowerShell, I get an error with one of the gems. I can't run the server command, can't generate, can't run console. Here is the most recent error:
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/execjs-2.5.2/lib/execjs/runtimes.rb:48:in 'autodetect': Could not find a Javascript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)}
Other times I get errors with native gems follow guides to resolve those, but nothing ends up working.
How do I get Rails to do anything on my Windows machine? Should I just get a Linux vm?
I would recommend using a vm, I've used virtualbox in the past with ubuntu for rails development.
It's not impossible to get things to work in windows, but you'll probably thank yourself later if you move to the vm.
For the specific error you mention see this SO post which suggests adding therubyracer gem.
If you're getting a different error every time then providing an answer with the steps to get it running would be very hard so I'll stick to a general answer.
With persistence (which, don't get me wrong, you've already shown) you can get rails up and running on a Windows machine. You will spend longer getting native gems to work properly and you will have to search harder, and longer, for solutions to some problems.
I have run rails on both windows (admittedly a few years ago now) and on linux and I have found the latter to be much easier to develop on.
So, it's a trade off between the pain of running rails under windows and the pain of running some of your dev environment on a virtual machine. Only you can decide which is the least painful for you.

deploy ruby or rails on windows [duplicate]

I'm looking to run Redmine, a Ruby on Rails app, on a VPS windows box. The only thing I can really think of is running a virtual Linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine?
Also, this will be an internal app, so performance isn't my number once concern.
Windows is not the usual place to deploy production Rails apps, but there are people who do it. Mongrel was originally written to give better deployment options for Windows. As it turned out the UNIX deployment options weren't that good either. :)
Start with the Ruby One Click installer so you have a sane installation of ruby and rubygems.
From there, you install the rails gem and the gem for your database like you normally would. Most if not all of the databases have Windows gems.
Make sure to install mongrel_service to be able to control each mongrel like a normal windows service. See mongrel_rails service::install -h for details.
Once you have your mongrels set up, it's similar to a UNIX deployment. You set up a reverse proxy, such as Apache2 and you're set.
You might run into some gems (such as BackgroundRB) that will not work under Windows because they have C code that either rely on UNIX libraries or expect a UNIX-like build system at installation time. However, all of the really important Rails gems, such as Mongrel and the database adapters, have gems with pre-built binaries available, so you'll be fine.
Just grab the Bitnami RedMine stack.
Or the Bitnami Ruby on Rails stack.
Redmine ran fine on our Windows build server from the command line, sans IDE, using Mongrel and SQLite. Granted, ours isn't a VPS, but at any rate Linux isn't required for this app.
The BitNami Redmine Stack is a free, up to date Windows installer package for Redmine on Windows, Linux, OS X... give it a try. You can also download a VMWare Virtual Machine as well
I had good luck in the past with InstantRails, but I'm not sure how up-to-date it is now, as the project has changed hands several times.
You might also try ruby stack or flash rails, though I've not used either personally.
You can install SQLite and a Rails server like Mongrel on a Windows machine. I used Aptana to run a development environment, but I'm sure that there are better alternatives that don't require the IDE to be open to run. But this proves it is possible.
Try using a Rails distribution like: http://instantrails.rubyforge.org/wiki/wiki.pl
One download install for rails+ruby+mysql on Windows.

Passenger install fails. RAM too low?

I have been trying to install Passanger for apache on my VPS (running Ubuntu 10.10) and it seems to fail due to g++ as it fails at the point it compiles the module. The installation hangs for a while then:
g++: Internal error: Killed (program cc1plus)
After looking around on the net it seems this could be due to a lack of memory (I only have 256mb).
Is there any way around this? Or, is this in fact probably not the problem? I just need this server for a few days and so far it has been such a mess around just setting everything up so I'm not sure I really want to have to start again with a high RAM VPS. Any suggestions?
Use the debian package instead of building passenger yourself (apt-get install libapache2-mod-passenger).
256M seems pretty tight for a rails site though. I can't imagine you being able to run more than one or two passenger children (my passenger apache instances are using over 200M each).
I run into this problem, too. Then I tried to install the Debian package. But this package is used with Ruby 1.8 and is not compatible with 1.9 (I got problems with writing hash_name: value instead of :hash_name => value.
I'm trying to upgrade my VPS, but still looking for a way not to do so

No up to date guides for installing latest version of Rails on Windows 7

I've looked around the current answers for similar questions but still couldn't find the information I was looking for.
While there are countless guides to setting up rails, it seems there aren't that many which are up to date. The latest installation of Ruby 1.9.2 seems to come with RubyGems but I can't seem to install it by running the command gem install rails
On top of this I've read guides recommending to establish a linux environment. I'm even confused to what database to use "SQLite3" or "MySQL".
My question, is how the heck do I get Rails installed quickly on Windows 7, what database should I use with it and also whether it's worth installing a VM? Any up to date guides would also be appreciated. I'd like to have the most suitable environment to get started.
I started out with Windows, used Ruby/Rails for a month, then decided to go with Rails on Ubuntu under VirtualBox, using Putty to remote to it.
MySQL is installed on Windows (so that the VM doesn't become too slow).
All code is on VBox accessible Windows drive, everything else Rails-related is on Ubuntu.
All this lets me:
Use Ruby/Rails in it's "native" place i.e. *nix
Use my Windows 7 slick (IMO) GUI
Use my BeyondCompare, TortoiseGit
Learn linux (as mentioned below also)
Ask better questions / get more answers in the community (where everyone assumes ;) that you've either got Rails on Linux or a Mac) since everyone seems to be using *nix.
To me, it makes sense to not use Ruby/Rails on Windows, especially since hosting a Rails app will 99.999% be on a linux box. So, you will get to learn linux/Ubuntu and can be better prepared come hosting time. Bonus in resume + you won't be lost when asking questions down the road, and not wonder "is this problem installing this gem because I am using Windows?".
Also, I noticed that running things like rake was 2-3 times faster in Ubuntu than in Windows. And now I think it is good to have learnt linux. I must say linux excels at the command line, and I kind of like using it now. Linux/Ubuntu sucks at GUI (IM very strong O!).
Oh, and for Ruby/Rails on Windows, give Pik a try (it's the Windows version of RVM - Ruby Version Manager).
And just for the record, on Windows, I faced problems with installing RSpec; exceptions in WebBRICK; could not use imagemagick; and other small things I am glad to have forgotten.
The Rails Installer has recently been updated for Windows, and has the support of EngineYard to keep it up to date. But, it looks like it only installs Ruby 1.8.7 at the moment. But, it should be a good starting point.
You can read Engine Yard's announcement, and reasoning for getting the Rails Installer up to date here: http://www.engineyard.com/blog/2011/introducing-railsinstaller/
The problem with Windows is it's totally different than all the other OS's. Supporting it requires all this if WIN32 else business that's no fun at all, so support lags. And since no self-respecting developer would even want to run Rails on Windows, there's just very little incentive to keep support up to date.
Why not get a hosted Linux VM such as one at Slicehost and run your project there? The advantage of that is it's accessible from anywhere without having to set up port forwarding on your cable modem (assuming you have a static IP.)
Rails on Windows is poorly supported. And even if you can get the basic Rails environment up on Windows, you'll face various problems with many Ruby gems--they aren't tested in the Windows/Rails environment so they often have problems.
Alternatives
I use a windows machine for developing Rails apps. But I never run the apps on my win box. I did it once a couple of years ago but found it to be a waste of time since many ruby gems don't work properly on windows.
Instead, I run Linux on an old PC as my development environment. I use Samba to mount the Linux box's filesystem on windows. Then I can use Windows text editors such as UltraEdit.
Another option that doesn't require a second machine is to load Linux on a secondary partition on your windows box. You can then boot into the Linux os and run Rails there.

Is there anyway to run Ruby on Rails applications on a Windows box?

I'm looking to run Redmine, a Ruby on Rails app, on a VPS windows box. The only thing I can really think of is running a virtual Linux machine and hosting it from there. If that is my only option, am I going to run into problems running a virtual machine inside of a virtual machine?
Also, this will be an internal app, so performance isn't my number once concern.
Windows is not the usual place to deploy production Rails apps, but there are people who do it. Mongrel was originally written to give better deployment options for Windows. As it turned out the UNIX deployment options weren't that good either. :)
Start with the Ruby One Click installer so you have a sane installation of ruby and rubygems.
From there, you install the rails gem and the gem for your database like you normally would. Most if not all of the databases have Windows gems.
Make sure to install mongrel_service to be able to control each mongrel like a normal windows service. See mongrel_rails service::install -h for details.
Once you have your mongrels set up, it's similar to a UNIX deployment. You set up a reverse proxy, such as Apache2 and you're set.
You might run into some gems (such as BackgroundRB) that will not work under Windows because they have C code that either rely on UNIX libraries or expect a UNIX-like build system at installation time. However, all of the really important Rails gems, such as Mongrel and the database adapters, have gems with pre-built binaries available, so you'll be fine.
Just grab the Bitnami RedMine stack.
Or the Bitnami Ruby on Rails stack.
Redmine ran fine on our Windows build server from the command line, sans IDE, using Mongrel and SQLite. Granted, ours isn't a VPS, but at any rate Linux isn't required for this app.
The BitNami Redmine Stack is a free, up to date Windows installer package for Redmine on Windows, Linux, OS X... give it a try. You can also download a VMWare Virtual Machine as well
I had good luck in the past with InstantRails, but I'm not sure how up-to-date it is now, as the project has changed hands several times.
You might also try ruby stack or flash rails, though I've not used either personally.
You can install SQLite and a Rails server like Mongrel on a Windows machine. I used Aptana to run a development environment, but I'm sure that there are better alternatives that don't require the IDE to be open to run. But this proves it is possible.
Try using a Rails distribution like: http://instantrails.rubyforge.org/wiki/wiki.pl
One download install for rails+ruby+mysql on Windows.

Resources