Raaz
Raaz

Reputation: 1771

'bundle is not installed' error

I am not good with devops. I had created a user called deploy. Previously I could ssh into my server then

su deploy

and run

RAILS_ENV=production bundle exec rails c

.

Some days ago, I completely forgot that I had a user called deploy. Being the root user, I installed ruby using rvm. RVM was already installed.

Now I remember that I have a user called deploy. I ran su deploy then ran

RAILS_ENV=production bundle exec rails c

I got the following error

The program 'bundle' is currently not installed. To run 'bundle' please ask your administrator to install the package 'ruby-bundler'

Before I had installed ruby in super admin env I could run bundle in the deploy user env.

Is there a way to fix this?

PS: My capistrano deployment script is running without any problem even if it is being deployed by the "deploy" user

Upvotes: 1

Views: 1009

Answers (1)

seaify - Freelancer
seaify - Freelancer

Reputation: 748

The problem is that when you ssh into the directory, at the directory, no .ruby-version file exists, so it use the default ruby version(run which ruby to see the exactly path), not the rvm ruby version, so it can't find the installed gems like bundler.

It's a environment problem.The capistrano deployment is working because you have assign ruby version in your deploy.rb like

set :rvm_ruby_version, 'ruby-2.2.2@zhitaotao'

so it can find correct ruby version, then find installed gems for the version.

The solution is add a file called .ruby-version, set the content to something like ruby-2.3.1.

If this not works, i suggest to reinstall ruby, bundler, and run bundle install for deploy user. We need to make sure that at the production directory, the ruby version is matched with the ruby version assigned in the deploy.rb.

Upvotes: 3

Related Questions