Rails 3 and Bundler. How to deploy and NOT package gems - ruby-on-rails

I'm having lots of problems trying to deploy using capistrano. I keep on getting errors about libv8 not in any of the sources.
Could not find libv8-3.11.8.13 in any of the sources
Here https://github.com/cowboyd/libv8/issues/56 tells you that you could "not to use packaging", that way, the deployed app won't use the bundle package.
How can I deploy and use the gems NOT IN THE BUNDLE PACKAGE? I want the app do run bundle everytime I deploy instead or to just run bundle when the Gemfile has changed.

This is how I got it working: https://github.com/cowboyd/libv8/issues/77#issuecomment-12711634
I'm doing development on a mac and deploying to a red hat server. It seems Rails needs a OS, platform-specific version of the gem. So when I'm running bundle on my development machine (mac) and then deploy it with capistrano to the production server (red hat), it won't work.
What I ended up doing is...
manually download the libv8 gem I needed from http://rubygems.org/gems/libv8
copy the downloaded gem to the vendor/cache folder
then deployed the app (cap deploy:cold)
and it worked.

If I understand your question correctly it sounds like you're missing the bundle capistrano task. See https://github.com/carlhuda/bundler/blob/master/lib/bundler/capistrano.rb for more. You should be able to "require 'bundler/capistrano'" to your capistrano deploy.rb file so that bundle is run on every deploy.

Related

No gem file in my Ruby on Rails project, bundle install/update doesn't work?

I am working on a project in which Gemfile is not present.
That project is working fine on production server having Apache with passenger.
But, Bundle install and bundle update does not work when I try try to start project in development environment. How to get that project working in development environment?
Unless someone from systems engineering can tell you, where the Gems were defined, You can reverse engineer a Gemfile from the contents of Gemfile.lock.
Or you can try to run your project by using this command, after you copied the Gemfile.lock from production, also put an empty Gemfile, as the bundler requires it.
bundle install --deployment
see this answer, but sooner or later you will need the Gemfile.

Where are Ruby gems located on a server?

My understanding is that the gemfile in a Rails app only provides references to the actual code of these gems on your local computer. So when you're running your app locally, it's pulling the gem code from your local computer. What happens when you deploy though? The server runs your rails code, but does it also hold all the references in your gem file and automatically download them as well?
Yep. If you deploy on Heroku, you can see bundler doing its work and pulling down the gems.
As per the Bundler docs, you can use bundle show --paths to see exactly where your gems are being loaded from.
Additionally, if you aren't using bundler, you can use the command gem environment to see gem paths on the system.
See this existing answer for more info: How can I find where gem files are installed?

Deploying error with capistrano: "bundler: not executable: cap"

I am supposed to work on a quite antique Ruby On Rails project to make some minor (mostly HTML and CSS) changes on some webpages. I did not work with Ruby On Rails before and I am just getting into it.
I have cloned the project via git from github and installed all gems via 'bundler install'. Note that I am using an old version of Ruby (1.8.7) since I was told the project would not work with a newer version. Note also I am on Windows 7 and the project was built with Mac OS X.
Now I am trying to get the changes I made to the live site (after commiting and pushing the changes to the git repository) with Capistrano (Installed and Version 2.8.0) which should be possible with
bundle exec cap production deploy
However when I try this I just get:
bundler: not executable: cap
Any ideas what is going wrong here? Thanks alot in advance!
Kind regards,
Peter
Generally, capisrano is not defined as a gem in a project's Gemfile. Try installing the gem with gem install capistrano.
You can also check if Capistrano is installed on your system by running cap -T in your project folder. This should give you a list of all tasks in that project.

Can't access Rails console for app deployed on Passenger using Capistrano & RVM

After finally managing to get my Rails app working, I've got stuck with a slightly perplexing problem. I've deployed my Rails 3.0.5 app to a Ubuntu 10.10 server with Capistrano, RVM and Nginx. All is working nicely and I can confirm Rails is working as I'm getting data from the database and meaningful log messages.
The problem is that on the server, I can't access the console. When I try
rails c
It says "The program 'rails' is currently not installed. To run 'rails' please ask your administrator to install the package 'rails'"
However it is installed otherwise my application wouldn't work! I've only got two RVM gemsets installed, the global one and one called "rails305". Trying
rvm gemset use rails305
then
gem list
doesn't show any of the gems that my app needs, however they must be installed because 1) the app wouldn't work without them and 2) in my Capistrano deploy script, bundler installs them (to that gemset). So the problem is obviously something to do with RVM but I can't work out what it is... anyone any ideas?
It looks like Capistrano uses bundler so you might want to try
bundle exec rails c
from the deployment directory.
See the Bundler deployment page for more information.
Bundler by default doesn't install gems into the default rvm environment when deployed via capistrano, it installs to the "shared/bundle" directory instead, to try and accommodate production installation environments that aren't using RVM. If you are using RVM in production, and want to just have bundler install to your default ruby/gemset (which is terribly useful if you are going to be logging into the production, running rake scripts, console, etc), add the following options to your config/deploy.rb:
set :bundle_dir, ""
set :bundle_flags, ""
This will remove the "--deployment" (and "--quiet", which you may or may not want to keep) and --path flags which cause bundler to try and package everything up nicely, so bundler will now install to the user's RVM environment; making your server environment work a lot more like your dev environment (which can be good or bad depending on what your needs are).

Error while running rails on remote host. "Could not find crack-0.1.8 in any of the sources"

I am trying to deploy my rails app that is working fine on my local machine , to a remote host. I am using railsplayground.com to be exact. When I try to run the app using Passenger,I get this error
"Could not find crack-0.1.8 in any of the sources"
But when I did a,
$gem list
the gem , crack (0.1.8) is present. I am using Rails 3 btw.
Any suggestions is welcome. Thanks in advance.
Make sure the Gem is installed via Bundler. Check your Gemfile and see if the gem is listed.
Then, when deploying the application, make sure to execute the $ bundle install command.
If you deploy the project with capistrano, you can use the default bundler recipe by including the recipe at the top of your deploy.rb file.
require 'bundler/capistrano'

Resources