When I run
cap production rvm1:install:ruby
I get this error at the end of the console output:
Command: cd ~/apps/foo/releases/20140121133714 && ( PATH=/opt/ruby/bin:$PATH /usr/bin/env /tmp/foo/rvm-auto.sh rvm install . )
Could not determine which Ruby to use; . should contain .rvmrc or
.versions.conf or .ruby-version or .rbfu-version or .rbenv-version, or an appropriate line in Gemfile.
cap aborted!
EDIT
After adding an .ruby-version at the root of my app, with the contents I get
DEBUG [af3b80bc] Command: cd ~/apps/foo/releases/20140121160854 && /usr/bin/env /tmp/foo/rvm-auto.sh rvm install .
DEBUG [af3b80bc] ruby-2.0.0-p247 is not installed.
DEBUG [af3b80bc] To install do: 'rvm install ruby-2.0.0-p247'
DEBUG [af3b80bc] ruby-2.0.0-p247 is not installed.
DEBUG [af3b80bc] Searching for binary rubies, this might take some time.
DEBUG [af3b80bc] ruby-2.0.0-p247 is not installed.
DEBUG [af3b80bc] Searching for binary rubies, this might take some time.
DEBUG [af3b80bc] No binary rubies available for: ubuntu/12.10/x86_64/system.
DEBUG [af3b80bc] Searching for binary rubies, this might take some time.
DEBUG [af3b80bc] Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
DEBUG [af3b80bc] Searching for binary rubies, this might take some time.
DEBUG [af3b80bc] RVM does not have prediction for required space for system, assuming 150MB should be enough, let us know if it was not.
DEBUG [af3b80bc] Searching for binary rubies, this might take some time.
DEBUG [af3b80bc] Either the ruby interpreter is unknown or there was an error!.
I'm running Capistrano 3.1.1 with rvm1-capistrano gem. It's out of the box implementation; nothing special going on.
group :development do
gem 'capistrano', '~> 3.1.0'
gem 'capistrano-rails'
gem 'capistrano-bundler'
gem 'rvm1-capistrano3', require: false
# gem 'capistrano-rvm'
end
# capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rails'
require 'capistrano/bundler'
require 'rvm1/capistrano3'
Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
I'm also getting two other errors in the output:
Running /usr/bin/env [ -L ~/apps/foo/releases/20140121135720/public/assets ] on foo.com
Command: [ -L ~/apps/foo/releases/20140121135720/public/assets ]
Finished in 0.291 seconds with exit status 1 (failed).
Running /usr/bin/env [ -d ~/apps/foo/releases/20140121135720/public/assets ] on foo.com
Command: [ -d ~/apps/foo/releases/20140121135720/public/assets ]
Finished in 0.295 seconds with exit status 1 (failed).
Problem
If you go to the remote server and execute this:
cd ~/apps/foo/releases/20140121160854 && /usr/bin/env /tmp/foo/rvm-auto.sh rvm install .
you will get the same error but if you execute this instead
cd ~/apps/foo/releases/20140121160854 && /usr/bin/env /tmp/foo/rvm-auto.sh rvm install ruby-2.0.0-p247
success.
The problem appears when rvm-auto.sh execute the rvm install . command. Not sure if is a rvm problem but it looks so to my eyes..
Workaround
If you specify the desired version of ruby to install in config/deploy.rb:
set :rvm1_ruby_version, "ruby-2.0.0-p247"
before executing any rvm1 tasks. Everything should be fine
The application does not know which version of ruby to use.
All you need to do is add a file called .ruby-version to the root of your application, and have its contents be
1.9.3
Or whatever version of ruby you are using.
You may also need a .ruby-gemset file. In which case, its contents should be
some_gemset_name
You can call your gemset whatever you want. It is local to your application.
Related
visual studio code launch configuration (not terrible important) tries to start rdebug-ide via
bundle exec rdebug-ide
This works only if I add the gems to the Gemfile.
Is bundle exec supposed to only find binaries included in the Gemfiles or should those installed globally, e.g. gem install rdebug-ide, also be accessible from bundle exec?
So this works:
> rdebug-ide
Using ruby-debug-base 0.2.2 ...
but this doesn't
> bundle exec rdebug-ide
Gem::Exception: can't find executable rdebug-ide for gem ruby-debug-ide. ruby-debug-ide is not currently included in the bundle, perhaps you meant to add it to your Gemfile?
and even this works!
> bundle exec ls
Gemfile app ...
Extra info: I'm using rbenv, perhaps that affects bundler behavior somehow
UPDATE
#tadman pointed out that bundle exec is altering the path. But as I would have expected it seems to be extending it, not removing anything
$ diff <(gem env) <(bundle exec gem env)
24a25
> - /Users/eng/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bin
$ which rdebug-ide
/Users/eng/.rbenv/shims/rdebug-ide
$ bundle exec rdebug-ide
bundler: failed to load command: rdebug-ide
(/Users/eng/.rbenv/versions/2.5.3/bin/rdebug-ide)
Gem::Exception: can't find executable rdebug-ide for gem ruby-debug-ide. ruby-debug-ide is not currently included in the bundle, perhaps you meant to add it to your Gemfile?
furthermore the path is in there:
$ bundle exec gem env | grep $(dirname $(which rdebug-ide))
- /Users/eng/.rbenv/shims
I'm tending to think that rbenv is somehow messing things up.
bundle exec does a number of things, primarily changing the Gem environment, but most importantly it alters your search PATH for executables.
Many, like ls which exist outside of Ruby will still be present, but gem executables may be knocked out if not included in the Gemfile.
Check with:
bundle exec gem env
And compare with:
gem env
You'll see a number of changes in the "SHELL PATH" section.
I had RVM and RBENV installed on my computer and I decided to keep only RBENV So I followed this setup
I am on mac with high sierra
The first trouble I am facing is that ruby -v displays nothing.
I know that my ruby version is ok because of ohmyzsh [2.4.4]
When I try to run this command gem install rake bundler rspec rubocop pry pry-byebug hub colored octokitnothing happens... I can't install bundler nor rails.... I am not supposed to use the sudo... What could be wrong and how could I find fix this?
I can't even launch irb and gem install bundlerdoes nothing
there must be a conflict somewhere?
I ran this dignostic:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 320 100 320 0 0 858 0 --:--:-- --:--:-- --:--:-- 860
--- PATH ---
./bin:/Users/bill/.rbenv/shims:/usr/local/opt/rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/ImageMagick/bin:/usr/local/sbin
--- RBENV ---
rbenv is /usr/local/opt/rbenv/bin/rbenv
rbenv is /usr/local/bin/rbenv
system
* 2.4.4 (set by /Users/bill/.rbenv/version)
--- RUBY ---
ruby is /Users/bill/.rbenv/shims/ruby
ruby is /usr/bin/ruby
ruby is /usr/local/bin/ruby
--- GEM ---
gem is /Users/bill/.rbenv/shims/gem
gem is /usr/bin/gem
gem is /usr/local/bin/gem
--- POSTGRES ---
postgres is /usr/local/bin/postgres
postgres (PostgreSQL) 10.5
2018-09-11 17:04:51.406 CEST [30591] FATAL: database files are incompatible with server
2018-09-11 17:04:51.406 CEST [30591] DETAIL: The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.5.
See my .zshrc
ZSH=$HOME/.oh-my-zsh
# You can change the theme with another one:
# https://github.com/robbyrussell/oh-my-zsh/wiki/themes
ZSH_THEME="robbyrussell"
# Add ruby version on prompt (float right)
if [ -x "$(command -v rbenv)" ]; then RPS1='[$(ruby_prompt_info)]$EPS1'; fi
# Useful plugins for Rails development with Sublime Text
plugins=(gitfast brew rbenv last-working-dir common-aliases sublime zsh-syntax-highlighting history-substring-search)
# Prevent Homebrew from reporting - https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Analytics.md
export HOMEBREW_NO_ANALYTICS=1
# Actually load Oh-My-Zsh
source "${ZSH}/oh-my-zsh.sh"
# Rails and Ruby uses the local `bin` folder to store binstubs.
# So instead of running `bin/rails` like the doc says, just run `rails`
export PATH="./bin:${PATH}:/usr/local/sbin"
# Store your own aliases in the ~/.aliases file and load the here.
[[ -f "$HOME/.aliases" ]] && source "$HOME/.aliases"
# Encoding stuff for the terminal
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export BUNDLER_EDITOR="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"
export BUNDLER_EDITOR="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"
export BUNDLER_EDITOR="'/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl'"
eval "$(rbenv init -)"
Also ran this diganostic:
You seem to have multiple rbenv installs in the following locations.
Please pick just one installation and remove the others.
/usr/local/opt/rbenv/bin/rbenv
/usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20180822)
Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: %
here is a screenshot of my ~maybe something needs to be removed ? what about that .rvmrc it says rvm_auto_reload_flag=1
rvm_auto_reload_flag=2
EDIT
I am opening the folders and files:
in .profileit says:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Clarify the "nothing happens"
~ gem install rake bundler rspec rubocop pry pry-byebug hub colored octokit
➜ ~
I fixed with:
brew update
brew upgrade
brew uninstall ruby
When I run Capistrano task with dry run it tells me that rbenv Ruby version can't be found. I assume with dry run it should use local environment. But when I run the commands locally I can easily find below mentioned directory and Ruby is installed.
> ./bin/bundle exec cap --dry-run development t
DEBUG [8171d925] Running [ ! -d ~/.rbenv/versions/2.4.3 ] as user#dev
DEBUG [8171d925] Command: [ ! -d ~/.rbenv/versions/2.4.3 ]
ERROR rbenv: 2.4.3 is not installed or not found in ~/.rbenv/versions/2.4.3
> ls ~/.rbenv/versions/2.4.3
bin include lib share
> rbenv global
2.4.3
> ruby -v
ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-darwin16]
> bundle info capistrano
* capistrano (3.4.0)
My Capfile contains below lines.
require 'capistrano/rbenv'
set :rbenv_type, :user
set :rbenv_ruby, '2.4.3'
I'm using Mac OS and installed rbenv with homebrew.
Check your PATH and make sure it contains $HOME/.rbenv/shims and $HOME/.rbenv/bin
To view your path do:
$ echo $PATH
Also check that you have the following in your ~/.bash_profile
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
To check bash profile enter in terminal:
touch ~/.bash_profile; open ~/.bash_profile
Make sure it's the last setting in your ~/.bash_profile
There must have been some bug in capistrano/rbenv. I have changed my Gemfile as follows and problem is solved.
# gem 'capistrano-rbenv', '2.0.2'
gem 'capistrano-rbenv', '~> 2.1'
I assume with dry run it should use local environment.
This is not true.
A Capistrano dry-run simply prints out the remote commands that it would run in an actual deploy, but it does execute them at all (local or otherwise).
Since Capistrano is not executing any commands, any plugins that rely on results of those commands may not work. For example, the rbenv plugin is apparently expecting to run this command:
[ ! -d ~/.rbenv/versions/2.4.3 ]
In a dry-run scenario, this is not actually executed. Instead, Capistrano just prints the command and continues as if the command succeeded.
In this particular case, for [ ! -d ~/.rbenv/versions/2.4.3 ] to "succeed" means that the ~/.rbenv/versions/2.4.3 does not exist. The rbenv plugin thus prints an error an halts the deployment.
To summarize: in practice, the --dry-run option is not particularly useful.
i have very strange error when deploy my rails app with capistrano. sometimes it's deploy and sometimes not.
for example i add something to css (just one string) e.g. .my_some_class{width:10px}
and after that deployment fails. before i add this - it's deploy ok.
i am sure what nothing else changed cause i make experimental commit which contain only one string of css.
my config:
rails 4.1.0
ruby 2.1.1p76
gem 'capistrano-rails', group: :development
gem 'capistrano-rvm', group: :development
gem 'capistrano-bundler', group: :development
end of deploy log:
Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: #<SSHKit::Command::Failed: rake exit status: 137
rake stdout: Nothing written
rake stderr: SafeYAML Warning
----------------
You appear to have an outdated version of libyaml (0.1.4) installed on your system.
Prior to 0.1.6, libyaml is vulnerable to a heap overflow exploit from malicious YAML payloads.
For more info, see:
https://www.ruby-lang.org/en/news/2014/03/29/heap-overflow-in-yaml-uri-escape-parsing-cve-2014-2525/
The easiest thing to do right now is probably to update Psych to the latest version and enable
the 'bundled-libyaml' option, which will install a vendored libyaml with the vulnerability patched:
gem install psych -- --enable-bundled-libyaml
I, [2014-04-30T09:42:41.121037 #12193] INFO -- : Writing /var/www/default/releases/20140430134522/public/assets/Thumbs-82e32ea0cc1ce375db2805ceadd707ef.db
I, [2014-04-30T09:42:41.123108 #12193] INFO -- : Writing /var/www/default/releases/20140430134522/public/assets/agency_no_logo-a8544e60b8a38abeb431c2eb5089f7c6.png
I, [2014-04-30T09:42:41.461121 #12193] INFO -- : Writing /var/www/default/releases/20140430134522/public/assets/swipebox/img/loader-a66dde050b0b2447862919f2c4c37eda.gif
bash: line 1: 12193 Killed ( RAILS_ENV=production ~/.rvm/bin/rvm default do bundle exec rake assets:precompile )
As was written above, probably, you have not enough RAM.
I solved problem by adding SWAP file on my Ubuntu 14.04 server:
Under the root:
dd if=/dev/zero of=/swapfile bs=1024 count=512k
mkswap /swapfile
swapon /swapfile
Add next line to /etc/fstab:
/swapfile none swap sw 0 0
and:
echo 0 > /proc/sys/vm/swappiness
sudo chown root:root /swapfile
sudo chmod 0600 /swapfile
check SWAP(maybe need reloading):
swapon -s
— How To Add Swap on Ubuntu 14.04 # Digital Ocean Community
if someone have same error - problem was on hosting. server have not enough ram(512mb), and process of compilation css/js was killed every time. than we change rate plan, which has 1gb ram, all deployed successfully. SO if you assets precompile failed - just try to add some resources to server.
P.S. similar problem i found here Capistrano deploy - assets precompile error
Try rebooting the server.Worked for me.
You appear to have an outdated version of libyaml
Update libyaml.
I want to install rvm via rvm1-capistrano. Every time I run the task it tells me that Ruby [version] is not installed. Which is weird because I already know its not installed, and this is why I'm running the task: To install it. Why is this?
This is a vanilla out of the box installation. I've not changed anything. I added the following:
set :rvm_ruby_version, '2.0.0-p353' # to deploy.rb, same error w/without
set :pty, true # deploy.rb
require 'rvm1/capistrano3' # to Capfile
Per others' recommendation, I added a .ruby-version to the root of my app with 2.0.0 as contents.
What am I not understanding correctly? Why would the task charged with installing ruby tell me ruby is not installed?
DEBUG [09203819] Command: cd ~/apps/simpleblog/releases/20140121174439 && /usr/bin/env /tmp/simpleblog/rvm-auto.sh rvm install .
DEBUG [09203819] ruby-2.0.0-p353 is not installed.
DEBUG [09203819]
DEBUG [09203819] To install do: 'rvm install ruby-2.0.0-p353'
DEBUG [09203819]
DEBUG [09203819] Searching for binary rubies, this might take some time.
DEBUG [09203819]
DEBUG [09203819] No binary rubies available for: ubuntu/13.10/x86_64/system.
DEBUG [09203819]
DEBUG [09203819] Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
DEBUG [09203819]
DEBUG [09203819] RVM does not have prediction for required space for system, assuming 150MB should be enough, let us know if it was not.
DEBUG [09203819]
DEBUG [09203819] Either the ruby interpreter is unknown or there was an error!.
DEBUG [09203819]