I have a Ubuntu 12.04 server and several rails 3.2.14 sites on it. Every time I do a new site deployment (via capistrano) the first install takes 20 - 30 minutes because it does a full install of libv8, even though I have already installed the libv8 gem on the machine (and see it when I do a gem list).
I've tried the binary version and tried changing versions of therubyracer.
Here's therubyracer part of my Gemfile
group :assets do
gem 'sass-rails', '~> 3.2.6'
gem 'coffee-rails', '~> 3.2.2'
gem 'uglifier', '>= 1.0.3'
gem 'therubyracer', '~> 0.12.0'
end
I've turned on verbose output in Capistrano and here's where it hangs up for ~20 minutes
** [out :: 198.58.99.7] Installing libv8 (3.16.14.3)
Any suggestions? Really tired of new sites taking this long to deploy.
As I said in my comment, bundle with the --deployment flag (as Capistrano does) installs gems into a your_app/shared/bundle. One of the reasons for this isolation and location is because the user you're deploying with may not have access to install gems to a system location, and more reasons described here (under the Deploying Your Application heading).
I believe there are ways to force bundler to use the system gems but I don't have any first hand experience of it; see here.
There's probably a conflict in dependencies in your Gemfile.
Remove the version constraint for therubyracer in your Gemfile and bundling should be much faster.
gem 'therubyracer'
Related
I have some gems needed outside development environment. So I moved them to the corresponding group in Gemfile as follows:
group :staging, :production do
gem 'activerecord-oracle_enhanced-adapter', '~> 5.2.0'
gem 'ruby-oci8', '~> 2.2', '>= 2.2.7'
gem 'aws-sdk-s3', '~> 1.48', require: false
end
Nevertheless, after cloning the project, when running bundle install it still requires to install ruby-oci8. What am I missing?
By default, bundle install will install all gems in all groups in your Gemfile, except those declared for a different platform.
However, you can explicitly tell Bundler to skip installing certain groups with the --without option. This option takes a space-separated list of groups.
While the --without option will skip installing the gems in the specified groups, it will still download those gems and use them to resolve the dependencies of every gem in your Gemfile.
This is so that installing a different set of groups on another machine (such as a production server) will not change the gems and versions that you have already developed and tested against.
ref: https://bundler.io/man/bundle-install.1.html
Disclaimer before reading: I have resolved this issue but I am asking because I still don't know the reasons behind it.
I'm working on an old gem that pulls assets into the asset pipeline. I'm not positive how the gem was originally created I imagine it was with rails plugin new static_assets.
Since it is a gem the Gemfile is not overly complex (I haven't made any changes to it):
source "http://rubygems.org"
gemspec
# jquery-rails is used by the dummy application
gem "jquery-rails"
But the Gemfile.lock has dozens of gems and dependencies showing up. For the most part, the gems seem up to date.
When I run a bundle update several of the gems go back to much older versions; like Rails 5 to Rails 3.
I believe I solved this by updating the Gemfile to
gem 'jquery-rails', '~> 4.3', '>= 4.3.3'
but I want to know why this was happening.
I'm not overly familiar with how Gemfile.lock gets created and updated but I was under the impression that it was based on the Gemfile, pulling all gems and their dependencies from the Gemfile. If all the gems in Gemfile.lock are dependant on jquery-rails why was it automatically downgrading them so unilaterally and by so much?
I'm trying to deploy an app to heroku. I'm running an ubuntu VM. I just had a lot of trouble getting postgres set up, but I think I'm good to go with that.
I've run
heroku create
and i've committed the most recent changed upon my master branch. When I run bundle install - everything is ok. And when I run
git push heroku master
Everything is smooth, including the installing of the gems. Until I reach the line
------> Writing config/database.yml to read from DATABASE_URL
Everything stalls and I'm greeted with this message 15 minutes later
Timed out compiling ruby app (15 minutes)
for good measure here is my database.yml code
development:
adapter: postgresql
database: saasbook
pool: 5
password:
And here is my gem file
gem 'rails', '4.0.2'
gem 'rails_12factor' , group: :production
gem 'pg'
gem 'saas-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'oauth2'
gem 'figaro'
gem 'rake'
gem devise'
gem 'bootstrap-sass'
gem 'rails_layout'
gem 'zxing'
gem 'rmagick'
gem 'carrierwave'
gem 'rqrcode_png'
ruby "2.0.0"
The heroku deployment tutorial stated to insert the line ruby "2.0.0" after bundle install, and before the commit. I am currently running ruby 1.9.3 if that matters/ would have a conflict.
Any suggestions would be a huge help! thanks!
Edit
I'll leave this out here in case this problem ever arises again for someone
Alas, heroku doesn't like java/C dependent gems, and the QR decoding gem ZXING cannot be used on heroku, that was the reason it was stalling.
For starters, you're missing a quote in your Gemfile for devise:
gem devise' should be gem 'devise'
I would also recommend moving the ruby "2.0.0" line to the top of the Gemfile. It may not matter, but it's worth a shot.
Could be a network issue. Be sure the network you are using has all the appropriate ports open for GIT and heroku. You will need more than port 80.
I am sure you solved this already but for ref:
Make sure that your IDE (mine is RubyMine) is not open on that project or the build will stall/fail.
I have been repeating this tutorial for weeks now:
https://www.digitalocean.com/community/articles/how-to-1-click-install-ruby-on-rails-on-ubuntu-12-10-with-digitalocean
Here are the specifics of my project:
I am using Mongoid with database.yml production set to my tested and working Droplet (DigitalOcean VPS) running MongoDB.
My gem file is here, I am new to Rails and am not quite sure if it's set up right, so I just moved them all to assets hoping Unicorn might serve these gems for me?
source 'https://rubygems.org'
gem 'rails', '3.2.14'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"
gem 'redcarpet', '1.17.2'
gem 'uglifier', '>= 1.0.3'
gem "will_paginate_mongoid"
gem 'will_paginate', '~> 3.0.5'
gem 'will_paginate-bootstrap'
gem 'devise'
gem 'jquery-rails'
gem "mongoid", "~> 3.0.0"
end
Here's what I did:
I used DigitalOcean's 1 click installer. Then I used FileZilla to SFTP into the credentials they provided me with. I deleted all the files in /home/rails and put my new files in from my project. Then I executed bundle install, and restarted the unicorn service. In the tutorial I had seen I can track the log of unicorn, so I executed this: tail -f /home/unicorn/log/unicorn.log
Here is the output which concerns me:
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup': You have already activated rack 1.5.2, but your Gemfile requires rack 1.4.5. Using bundle exec may solve this. (Gem::LoadError)
I saw some other solutions to this, all failed. Here are the solutions I tried:
Deleting my Gemfile.lock, and re bundle installing it. Going into the file and removing where it said rack. Running bundle install --binstubs. Restarting the unicorn service with bundle exec before it. The error remains the same.
I've had many different errors before, but I feel this is the closest I have gotten. If someone could explain this to me (I'm new to Rails and would like a thorough explanation) and possibly help me fix the error that would be fantastic and end this frustration.
Just a wild guess
gem "rack", "~> 1.4.5"
May work for you, then of course bundle install afterwards.
This solves the problem:
gem uninstall rack -v 1.5.2
Possibly reload your Ubuntu installation from the DigitalOcean control panel, then try and install Ruby on Rails with Apache and Passenger?
Install RoR
Install Passenger (skip to passenger installation)
You will have errors when first creating your site with rails new as it will try and use SQL when it won't be installed, if you wish to use MongoDB
I'm learning Ruby on Rails from Michael Hartl's website. I have a Gemfile that looks like this:
source 'https://rubygems.org'
ruby '2.0.0'
#check and remove below if not relevant
#ruby-gemset=railstutorial_rails_4_0
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.1'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
.
.
.
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
Why is this sequence of commands correct:
`$ bundle install --without production`
`$ bundle update`
`$ bundle install`
Shouldn't it first be bundle update then bundle install --without production. Why call bundle install twice? I think the second call is redundant.
Why is this sequence of commands correct:
$ bundle install --without production $ bundle update $ bundle install
Without context, it's difficult to answer this—but one can intuit from the commands that it probably doesn't appear as one string of commands to be executed dutifully.
bundle install --without production installs exactly the versions in your lockfile, skipping any gems in a production group or with a production tag. This allows you to install only what you need to test and develop your application. (e.g., you probably don't want to waste lines with your logging service or pollute your monitoring service.) More importantly, this gives you a known-good working state for development on any machine you use.
bundle update updates the lockfile with permissible newer versions of the gems in the Gemfile. This can and will break your application if the Gemfile has not been well-crafted and versions of your dependencies have changed in the mean time. (So to answer your other question, no, you wouldn't run an update before an install.)
bundle install is most likely there to illustrate the correct command for deploying your production application: It wouldn't make any sense to skip the production gems and immediately turn around to install the production gems.
Where actually are these stuff being downloaded saved? Where are they
being installed? On my computer? I never got where they actually go or
hide. Maybe in my applications folder? But where exactly?
On your computer, in your Ruby installation. Ruby, like Perl and Python, maintains a portion of its directory structure specifically for add-on libraries.
In Ruby 2.0.0, for example, they live someplace similar to [RUBY_ROOT]/lib/ruby/gems/2.0.0/gems. For very specific purposes, it's also possible to install them locally in your Rails application's directory.
My recommendation is
1) Just do bundle, forget the rest. Not important to your learning
2) bundle install
OK, so for whatever version of ruby you are currently using this will take your Gemfile and get the right versions of those gems from rubygems.org (the site). and then install those gems on your machine for version of ruby that you are using if that version doesn't already exist on your machine. If the version exist, no download is needed, the gem version will be able to be immediately included, e.g. when offline.
If you switch ruby version then you'll usually need to bundle install again to get the right versions of those gems for the version of ruby that is currently being used on your machine.
If you use a tool such as rvm to manage your ruby versions then this is as simple as:
cd the_application_directory_for_your_rails_application
rvm use 1.9.3
bundle install
then to switch to ruby 2.0
rvm use 2.0
bundle install
You can specify specific ruby versions with
rvm use 1.9.3-p448 # e.g. for the -p448 version
You can see the 'currently available' ruby versions on your machine with
rvm list rubies
You can install a specific ruby with, e.g.
rvm install 1.9.3-p194