Closed minhdanh closed 4 years ago
Did you do a system wide install? If so: /usr/local/rvm rubygems current
Hi, I didn't install it system wide. The error appears as I run this task:
- name: Install bundler
sudo: yes
sudo_user: webapp
gem: name=bundler state=latest
It tells me that the executable gem is not found. So I guess I need to install gem
first with this task:
- name: Install rubygems
sudo: yes
sudo_user: webapp
shell: >
executable=/bin/bash source ~/.rvm/scripts/rvm;rvm rubygems current
environment:
PATH: "{{ rvm_path }}:{{ ansible_env.PATH }}"
But this is not successful either. Yes, I'm not sure if that's the right way to call a command begin with rvm
when I've already have the role rvm_io.rvm1-ruby
.
As I notice when rvm
is being installed, it has a task called Install bundler if not installed
. But the following task is also failed:
- name: Install gem dependencies
sudo: yes
sudo_user: webapp
command: "bundle install --deployment --without=development,test chdir=/home/webapp/my-app"
With the errors:
failed: [128.199.196.85] => {"cmd": "bundle install --deployment --without=development,test", "failed": true, "rc": 2}
msg: [Errno 2] No such file or directory
failed: [128.199.203.144] => {"cmd": "bundle install --deployment --without=development,test", "failed": true, "rc": 2}
msg: [Errno 2] No such file or directory
FATAL: all hosts have already failed -- aborting
Are you using version rvm1-ansible 1.3.6
or 1.3.7
?
It's 1.3.7
.
➞ ansible-galaxy info rvm_io.rvm1-ruby
- rvm_io.rvm1-ruby:
average_composite:
avg_code_quality: 4.5
avg_documentation: 5.0
avg_reliability: 5.0
avg_wow_factor: 4.5
average_score: 4.8
bayesian_score: 0.0
company:
created: 2014-07-03T19:02:53.964Z
dependencies: []
description: The official rvm role to install and manage your ruby versions.
galaxy_info:
author: Nick Janetakis
categories: ['development', 'web']
company: None
description: The official rvm role to install and manage your ruby versions.
license: license (MIT)
min_ansible_version: 1.5
github_repo: rvm1-ansible
github_user: rvm
id: 1087
install_date: Thu May 7 06:56:58 2015
intalled_version: v1.3.7
issue_tracker_url: https://github.com/rvm/rvm1-ansible/issues
license: license (MIT)
min_ansible_version: 1.5
modified: 2015-04-27T17:27:53.319Z
name: rvm_io.rvm1-ruby
num_aw_ratings: 0
num_ratings: 2
scm: None
src: rvm_io.rvm1-ruby
version:
I faced a similar sympton described in https://github.com/rvm/rvm1-ansible/issues/46#issuecomment-99901857 (gem not found) For me the issue was gem (and other files) ended up in a different folder. In my case I had set up rvm1_install_path to /usr/local/rvm but rubies and gems had end up under /usr/local/lib/rvm. So I changed rvm1_install_path to the second path and things worked. It is as if when installing rvm all the paths ended up messed up.
Hi. I still have this problem and after hours of googling I still don't know how to solve this. in role main.yml
- name: Bundle project gems
command: chdir="{{prj_path}}/web" bundle install --without development test
produces
TASK: [deploy_webapp | Bundle project gems] ***********************************
failed: [192.168.0.7] => {"cmd": "bundle install --without development test", "failed": true, "rc": 2}
msg: [Errno 2] No such file or directory
env info:
which bundle
/usr/local/rvm/gems/ruby-2.2.3/bin/bundle
env
rvm_path=/usr/local/rvm
rvm_prefix=/usr/local
MAIL=/var/spool/mail/pepa
PATH=/usr/local/rvm/gems/ruby-2.2.3/bin:/usr/local/rvm/gems/ruby-2.2.3@global/bin:/usr/local/rvm/rubies/ruby-2.2.3/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/rvm/bin:/home/pepa/.local/bin:/home/pepa/bin
RUBY_VERSION=ruby-2.2.3
_system_name=CentOS (7)
rvm --version
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
..."bundle install" works from command line over ssh.
Can you help me please? Josef
@Pepan Did you try the solution listed above?
I found solution:
- name: Bundle project gems
command: chdir="{{prj_path}}/web" bundle install --without development test
environment:
PATH: /usr/local/rvm/gems/ruby-2.2.3/bin:/usr/local/rvm/gems/ruby-2.2.3@global/bin:/usr/local/rvm/rubies/ruby-2.2.3/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/rvm/bin
GEM_PATH: /usr/local/rvm/gems/ruby-2.2.3:/usr/local/rvm/gems/ruby-2.2.3@global
I confirm I had the same issue, and solved sort of the same way @Pepan did. Before the fix bundler gem was installed in default gemset - this is only available when you run "rvm use ruby-X.X.X" but we need it in any gemset: "rvm use ruby@gemset" and this is achieved by installing bundler gem in the "@global" gemset that is inherited by all the gemsets on given ruby. I realised this is a separate issue, so I opened a new one #72 I wonder if it's worth to merge this PR #71
I have installed ruby using rvm and I can install gems by doing ssh into the machine but its failing with ansible. Below is my playbook where I am trying to install rails 4.2.0
And its giving error as - ERROR: While executing gem ... (Errno::EACCES)\n Permission denied - /var/lib/gems
I found solution:
- name: Bundle project gems command: chdir="{{prj_path}}/web" bundle install --without development test environment: PATH: /usr/local/rvm/gems/ruby-2.2.3/bin:/usr/local/rvm/gems/ruby-2.2.3@global/bin:/usr/local/rvm/rubies/ruby-2.2.3/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/rvm/bin GEM_PATH: /usr/local/rvm/gems/ruby-2.2.3:/usr/local/rvm/gems/ruby-2.2.3@global
Following version works for me for a single user instalation:
roles:
- { name: rvm_io.ruby, rvm1_rubies: "['{{ ruby_version }}']" }
tasks:
- name: Install gems
bundler:
state: present
chdir: "{{ sample_app_path }}"
executable: "{{ ansible_env.HOME }}/.rvm/gems/ruby-{{ ruby_version }}/bin/bundler"
gem_path: "{{ ansible_env.HOME }}/.rvm/gems/ruby-{{ ruby_version }}"
environment:
PATH: "{{ ansible_env.HOME }}/.rvm/gems/ruby-{{ ruby_version }}/bin:\
{{ ansible_env.HOME }}/.rvm/gems/ruby-{{ ruby_version }}@global/bin:\
{{ ansible_env.HOME }}/.rvm/rubies/ruby-{{ ruby_version }}/bin:\
{{ ansible_env.HOME }}/.rvm/bin:\
{{ lookup('env', 'PATH') }}"
GEM_PATH: "{{ ansible_env.HOME }}/.rvm/gems/ruby-{{ ruby_version }}:\
{{ ansible_env.HOME }}/.rvm/gems/ruby-{{ ruby_version }}@global"
I can install executable gem with this command after installing rvm successfully:
rvm rubygems current
But how to do this with rvm1-ansible?