I am using CentOS. Here is my output:
# which rvm
/usr/local/rvm/bin/rvm
# rvm ruby-1.9.3-p392#gemset
# /usr/local/rvm/bin/rvm ruby-1.9.3-p392#gemset
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
As you can see if I am using just rvm everything is working. But capistrano using full path in commands like this
[46f28bd9] Command: cd /var/www/app/releases/20140718172057 && /usr/local/rvm/bin/rvm ruby-1.9.3-p392#gemset do bundle install --binstubs /var/www/app/shared/bin --path /var/www/app/shared/bundle --without development test --deployment --verbose
So it just fails and all gems being installed on default ruby instead of ruby-1.9.3-p392#gemset
Thanks for any suggestions.
My assumptions:
you are using Capistrano v3
have already included require 'capistrano/rvm' in your Capfile
when you cd into your project directory you have something like .ruby-version and .ruby-gemset setting up RVM for you.
You might want to try something like this
within fetch(:current_path) do
with rails_env: fetch(:rails_env) do
execute :bundle, "install"
end
end
The way Tasks work in v3 is different: https://github.com/capistrano/capistrano#tasks
tl;dr: execute(:bundle, :install) and execute('bundle install') don't behave identically!
Related
I am required to run the following Ubuntu bash script as "sudo" (FYI, this is because I am running it through Upstart):
cd /u/apps/MyRailsApp/current && /usr/bin/env RAILS_ENV=production script/delayed_job restart >> /var/log/upstart/delayed_job.log
However, when I run it as "sudo", I get the following error:
/var/lib/gems/1.9.1/gems/bundler-1.7.6/lib/bundler/source/git.rb:188:in rescue in load_spec_files': git#github.com:MyRemoteRepo/my_gem.git (at 1.0.1) is not yet checked out. Runbundle install` first. (Bundler::GitError)
It's not recommended to run "bundle install" as Sudo. When I run "bundle install" as a non-admin user, it is working and all the gems are recognized. How do I get the root user to recognize the gem?
The gem is in /home/ubuntu/.bundler/ruby/1.9.1/. My other gems are in /var/lib/gems/1.9.1/gems/
Thanks so much for your help.
Try adding "source /home/[username]/.bashrc" where [username] is non-admin user that can run the script successfully.
Why doesn't the second command of
$ bundle install
not need
--without production
(As this is how it went in a tutorial, so I assume its correct)
What is happening/reasoning behind it not being needed?
From http://ruby.railstutorial.org/chapters/a-demo-app#sec-demo_users_resource
$ bundle install --without production
$ bundle update
$ bundle install
I believe it's because bundler creates a .bundle/config file inside your project's folder. This file stores the --without production option for later execution so that you don't have to type it every time.
When you run your bundle command on your development machine, it won't install the gems for use in your production environment.
See here: http://bundler.io/man/bundle-install.1.html
NAME
bundle-install - Install the dependencies specified in your Gemfile
SYNOPSIS
bundle install [--binstubs[=DIRECTORY]] [--clean] [--full-index] [--gemfile=GEMFILE] [--jobs=NUMBER] [--local] [--deployment] [--no-cache] [--no-prune] [--path PATH] [--system] [--quiet] [--retry=NUMBER] [--shebang] [--standalone[=GROUP[ GROUP...]]] [--trust-policy=POLICY] [--without=GROUP[ GROUP...]]
I'm trying to deploy my app for the first time on a ubuntu server.
I keep hitting this error:
2013-03-24 15:13:36 executing `deploy:run_migrations'
* executing "rvm gemset use vapin"
servers: ["111.111.111.11"]
[111.111.111.11] executing command
** [out :: 111.111.111.11]
** [out :: 111.111.111.11]
** [out :: 111.111.111.11] RVM is not a function, selecting rubies with 'rvm use ...' will not work.
** [out :: 111.111.111.11]
** [out :: 111.111.111.11]
** [out :: 111.111.111.11]
** [out :: 111.111.111.11] You need to change your terminal emulator preferences to allow login shell.
** [out :: 111.111.111.11]
** [out :: 111.111.111.11] Sometimes it is required to use `/bin/bash --login` as the command.
** [out :: 111.111.111.11]
** [out :: 111.111.111.11] Please visit https://rvm.io/integration/gnome-terminal/ for a example.
Here's some of my deploy.rb file:
require 'bundler/capistrano'
require 'rvm/capistrano'
# set the ruby version
#set :rvm_ruby_string, 'ruby-1.9.3-p392'
#set :rvm_type, :system
# set the rvm gemset to use
set :rvm_gemset, 'vapin'
...
task :install do
run "rvm gemset use #{rvm_gemset}"
run "cd #{current_path} && bundle install --without=test"
end
RVM is installed on my server.
$ which rvm
/usr/local/rvm/bin/rvm
$ which ruby
/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby
Any help is appreciated. I've been googling this one for days.
EDIT
I've uninstalled my multiuser installation of RVM and reinstalled the single user version.
I added this line to my deploy.rb script:
set :default_shell, "/bin/bash --login" # required for rvm scripts to work properly
and now i do not get the "RVM is not a function...." error.
The problem is that when bundle install runs, the gems are not installed in my rvm gemset.
In my deploy.rb file, setting this line:
set :bundle_dir, "/usr/local/rvm/gems/ruby-1.9.3-p392"
before this line:
require 'bundler/capistrano'
seemed to help bundler know where to install the gems. Not sure why this is needed. I've never needed it before.
Don't use rvm1/capistrano3 or rvm/capistrano; don't set :pty.
Change ~/.rvmrc for the runner user, on the server, to this — note that it has to come before the line where it kills itself when not running interactively:
# get rvm for non-interactive shells (eg capistrano) too
source /etc/profile.d/rvm.sh
export BASH_ENV=$HOME/.bashrc
export rvm_is_not_a_shell_function=0
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
I've just been struggling with this issue. Tried everything listed above, nothing worked. Deploying from osx, to ubuntu.
Finally, on ubuntu, "su-ed" as my deploy user, I did "rvm get head" (where I had been using "rvm get stable"). (I have it setup in a single-user environment, with rvm under "/home/deploy/.rvm".)
Like magic, it started working! Phew. So I guess maybe there's some fix in the latest rvm, that isn't in stable yet?
Maybe you need to add the RVM bin directory to your $PATH for scripting:
PATH=$PATH:$HOME/.rvm/bin
Although it seems you've answered your own question, I'll throw my hat in the ring as well...
I had a similar issue with the whole RVM is not a function error when trying to create a Rails template, and got around it by getting the rvm environment instance on a specific Ruby version, and then setting the gemset/running bundle install directly on it. In your case, it may be something like:
require 'bundler/capistrano'
require 'rvm/capistrano'
# set the ruby version
set :rvm_ruby_string, 'ruby-1.9.3-p392'
# set the rvm gemset to use
set :rvm_gemset, 'vapin'
...
task :install do
require 'rvm'
env = RVM::Environment.new(rvm_ruby_string)
# If you need to create a new app-specific gemset
# env.gemset_create(rvm_gemset)
env.gemset_use!(rvm_gemset)
# If you need to install bundler in a new gemset
# env.system("gem", "install", "bundler")
env.system("bundle", "install", "--without=test")
end
Obviously, the above code is not tested, but I created similar code that I've had success with in this Rails template file that will hopefully serve as some reference to you if the above code completely fails.
I've installed my gems in production with:
cd /app/releases/current && bundle install --gemfile /app/releases/current/Gemfile --path /app/shared/bundle --deployment --quiet --without development test
I can't bundle exec any of my gems (except rake and gem):
$ bundle exec whenever
bundler: command not found: whenever
Install missing gem executables with `bundle install`
The gems are correctly installed in /app/shared/bundle:
$ cd /app/shared
$ find . -name whenever
./bundle/ruby/1.9.1/gems/whenever-0.6.8/bin/whenever
./bundle/ruby/1.9.1/gems/whenever-0.6.8/lib/whenever
My (generated) bundle config (in /app/current/.bundle/config) is:
---
BUNDLE_FROZEN: "1"
BUNDLE_PATH: /app/shared/bundle
BUNDLE_DISABLE_SHARED_GEMS: "1"
BUNDLE_WITHOUT: development:test
I'm running ruby 1.9.2p290, manually installed to /usr/local/bin.
Do I have to bundle install my gems with the --binstubs option? Why wouldn't bundle exec be searching the stored BUNDLE_PATH?
Using Capistrano and Rails and using deploy.rb as deployer file.
I realized that changing the order where appears require "whenever/capistrano" really matters. I put that at almost the last line:
In deploy.rb:
#first lines:
set :rvm_ruby_string, "1.9.3"
set :rvm_type, :user
set :whenever_command, "bundle exec whenever"
# others...
# last lines
require 'rvm/capistrano'
require 'bundler/capistrano'
require "whenever/capistrano"
after "deploy:update_code", "customs:config"
after "deploy:create_symlink","deploy:create_symlink"
after "deploy", "deploy:cleanup"
load 'deploy/assets'
# end
I had this problem and had the requires in the correct order, i.e.
require 'rvm/capistrano'
require 'bundler/capistrano'
require 'whenever/capistrano'
It still wanted to run the crontab update before bundle:install. The solution was to update my local bundler with
gem update bundler
After that it started working again. Not sure exactly what changed between versions that broke all of this.
Check where your bundle:install is being set, and try moving it above require 'whenever/capistrano' in your deploy.rb file.
It seems like this was triggered when I did a bundle update that increased the whenever gem version in my Gemfile.lock.
It looks like whenever tries to run it's chrontab update before my deploy file runs bundle:install
from https://github.com/javan/whenever/blob/master/lib/whenever/capistrano.rb
before "deploy:finalize_update", "whenever:update_crontab"
And my deploy.rb had
after 'deploy:finalize_update', 'bundle:install'
Like everyone else in this thread, I tried a few things and I'm not sure this is what fixed it for me, but changing bundle install to before deploy:finalize_update, and also setting it as "before" above requiring 'whenever/capistrano' seems like it's the likely fix in my scenario.
I think when whenever gem is not in your Gemfile, or it's in the test or development section of your Gemfile
I changed the --path from /app/shared/bundle to vendor/bundle, which made it work.
This seemed wrong to me, so I removed /app/shared/bundle and vendor/bundle, and ran bundle install again to /app/shared/bundle.
This clean bundle install fixed the problem. I have no idea why!
If anyone has an explanation for this, I'd love to mark you as the accepted answer. But this fixed the problem for me.
Probably different issues cause the same error message. For me, I had to update capistrano gem after having updated whenever gem to get roles support. bundle exec whenever had worked prior to my upgrade of whenever.
Using the brightbox deployment gem, which handles bundler etc for me (by magic, in some other recipes) I found this works:
Replace
require "whenever/capistrano"
with the contents of https://github.com/javan/whenever/blob/master/lib/whenever/capistrano/v2/hooks.rb
then modify it to load after bundler:install finishes (you may or may not have that task, I don't know if it's standard)
# require "whenever/capistrano"
# hacked whenever/lib/whenever/capistrano/v2/hooks.rb below to work with brightbox bundler installation
require "whenever/capistrano/v2/recipes"
# Write the new cron jobs near the end.
after "bundler:install", "whenever:update_crontab"
# If anything goes wrong, undo.
after "deploy:rollback", "whenever:update_crontab"
Having some issues deploying this. I've tried to deploy it twice now. Here's what I've done so far....
Installed the gems and versions required on the install page:
gem install -v=2.3.5 rails
gem install -v=1.0.1 rack
gem install -v=0.8.7 rake
gem install -v=0.4.2 i18n
Downloaded the package:
git clone git://github.com/chiliproject/chiliproject.git
cd chiliproject
git checkout stable
Had to find and set bundle since it wasn't in my path:
BUNDLE="/usr/lib/ruby/gems/1.8/bin/bundle"
Put my database info into database.yml:
And then started the bundle stuff:
$BUNDLE install --without=postgres rmagick
$BUNDLE exec rake generate_session_store
The last command got the error:
rake aborted!
can't activate rails (= 2.3.5, runtime), already activated rails-2.3.12. Make sure all dependencies are added to Gemfile.
So I changed 2.3.12 to 2.3.5 in the Gemfile and carried on:
RAIL_ENV=production $BUNDLE exec rake db:migrate
Then I got an error on this command too:
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
undefined method `autoload_paths' for #<Rails::Configuration:0x68a68dbb82c0>
/home/USERNAME/DOMAIN/public/config/environment.rb:44
I tried commenting out line 44 there, but then it threw another error undefined methodconvert_to_without_fallback_on_iso_8859_1' for class Class' so I didn't want to play around with it further. Note this only happened the second time I tried to deploy it. The first time I tried db:migrate succeeded (and I checked there was not data already in the DB).
*So for the second try I am stuck here :-( *
But this is what happened the first time after db:migrate succeded....
RAILS_ENV=production $BUNDLE exec rake redmine:load_default_data
With the last command however it failed saying permission denied for mysql 'user'#'173.236.128.0/255.255.128.0' and I was like WTF is it trying to connect to a network as if it were a host?
So I moved on, copied my configuration file and environment files in. Changed/added these lines:
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.5'# unless defined? RAILS_GEM_VERSION
if ENV['RAILS_ENV'] == 'production' # don't bother on dev
ENV['GEM_PATH'] = '/home/USERNAME/.gems' + ':/usr/lib/ruby/gems/1.8'
end
Then made this stuff writable and restarted Passenger:
chmod -R 777 files log tmp public/plugin_assets/
touch tmp/restart.txt
Sorry for the wall of text, is anybody able to shine some light on something I've done wrong?
Thanks in advance.
EDIT: So this is all wrong, here's how I got it working
rm ~/.gem*
gem install bundler
PATH=$PATH:/usr/lib/ruby/gems/1.8/bin
cd ~
git clone git://github.com/chiliproject/chiliproject.git
cd chiliproject
git checkout stable
cp * ../example.com/ -R
cd ../example.com
# Make sure database is working
bundle install --without postgres rmagick test
bundle exec rake generate_session_store
RAILS_ENV=production bundle exec rake db:migrate
# No output is no good, check database.yml
RAILS_ENV=production bundle exec rake redmine:load_default_data
Or see this: https://gist.github.com/1127306
The current ChiliProject stable releases (2.x) require the use of bundler. Thus the answer by Slotos is incorrect here. gen install doesn't work anymore, we NEED bundler.
Also, we require Rails 2.3.12 now. You won't get any working results if you arbitrarily edit files. On certain platforms, you need to adapt the Gemfile (e.g. when using Ruby 1.8.6 or for certain versions of ImageMagick). For the currently suggested setup using Ruby 1.8.7 or REE, you don't need to adapt anything though.
For installing the dependencies of the currently stable ChiliProject 2.x releases, you basically need to do the following:
At first you need to make sure that the directory where gem binaries re installed to is in your $PATH. This can be temporarily be achieved by running this (in your case)
export PATH=/usr/lib/ruby/gems/1.8/bin:$PATH
Then you need to install the bundler gem and instruct it to install all dependencies
gem install bundler
bundle install --without rmagick postgres test # in your case
What is really strange in your case is that rake seems to try to enable Rails 2.3.5. It should not do that (and doesn't unless you have changed certain files). I strongly recommend to start with a new clean source tree and don't change any arbitrary files.
Don't mix up gem install commands with bundler package management. You will get unexpected results from doing so.
If you really want to use bundler - add all the gems you want into a Gemfile.
Otherwise just omit it.
Quick search for "bundler chiliproject" lead me to chiliproject-gemfile. Apparently it have been merged into unstable already.