(Rails app deployment) capistrano bundles with invalid ruby version - ruby

I have Digital Ocean ubuntu droplet, I have installed RVM and set ruby version to 2.1.1
On server:
> env
RUBY_VERSION=ruby-2.1.1
ruby -v in my project: ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]
I've tried to deploy app with capistrano, but it failed, because of bundler
command cap production deploy creates
/home/deploy/app_name/shared/bundle/ruby/2.3.0
Where can I set a valid bundle ruby version? Why cap production deploy creates 2.3.0 v. directory?

I believe this can happen because you have system-wide ruby 2.3.0, and capistrano uses it by default.
You can give a try to https://github.com/capistrano/rvm or some related, more up to date gem, that provides rvm integration with capistrano.

I had a similar issue and it was like Stanislav said, it's a problem with the rvm system-wide installation. I'm sure that you have installed the Ruby on Rails One click Application. In order to solve it I created a new clean Ubuntu Droplet, and installed rvm single-user manually.

Related

Install ruby 2.7.3 on Mac M1 issue

When I try to install the ruby 2.7.3 version on mac m1 it installs, it shows in my machine also but when I try sudo bin/setup_dev this command its show me error like
Bundling rails dependencies Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on
this machine. Your Ruby version is 2.6.3, but your Gemfile specified ~> 2.7.3
bin/setup_dev:
Failed to run 'bundle install > log/setup_dev.log', check log/setup_dev.log for more information.
aim#aim-MacBook-Air openproject % rbenv global 2.7.3
aim#aim-MacBook-Air openproject % ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
please any one can help to install ruby v 2.7.3 on mac.
Things that I try
Install ruby using rosetta 2
I am new on ruby please help on this.
thanks in advance.
Specifying a ruby version in a bundler gemfile doesn’t magically install that version of ruby. You need to start by learning to use a ruby version management system. I recommend Homebrew and rbenv.
(And not just in order to get a different ruby version. Always install your own ruby. Never use the built in system ruby for anything! If you have to say sudo you’re doing it wrong.)

Bundler version for Ruby 2.3.8?

I currently have 2 ruby versions, 2.5.5 and 2.3.8, I am managing them with rbenv, and for gems, I use bundler to manage my specific gem versions. I have an issue when I want to switch to a project that uses 2.3.8 or a version that has to do with Ruby version 2.3.
My question is how do I get bundler to run the command to bundle install interact with my 2.3 projects.
My current version of bundler is 2.0.2.
I have already tried installing a lower version of bundler of which the bundler website claims to interact with ruby version 2.3.
I thought that if I specified the command to run bundle _version_ install it would work, but it still gave me the response that it needed ruby version 2.5 for bundler to work.
Lots of help appreciated.
In some situations, isolation can help. I would like to recommend rvm (https://github.com/rvm/rvm) for managing ruby versions. This tool is very similar to rbenv but in comparison, it allows you to create gemsets which are kind of containers of gems for special purposes. For instance:
rvm install 2.5.5 --disable-binary
rvm use 2.5.5#name-of-gemset --create
gem install bundler
bundle install # inside your project folder with Gemfile
I think that you will not have problems with versions again.

local ruby version not registering in gemfile

The Ruby project that I'm trying to run specifies a requirement for Ruby version 2.1.2 in the Gemfile. Accordingly, I installed that version using rbenv and set it as the version for that repo using rbenv's local command. However, even after powering off my computer and restarting (not to mention running rbenv rehash), I still can't start the project, however rbenv confirms that I'm running 2.1.2 in that directory
bundle exec foreman start
Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2
travis-web > rbenv version
2.1.2 (set by /Users/me/sites/travis-web/.ruby-version)
Do you know how I can get the gemfile to read/acknowledge the local version (2.1.2)?
Switching versions might have dropped your bundler. The previous version had it, the new one doesn't. See here for another related case.
Within that repo:
gem install bundler
rbenv rehash
rbenv-bundler is a handy library that can do this for you upon each bundle install

How to use ruby 2.0.0 is a single rails app

I originally had ruby 1.9.3 installed on my computer as the only ruby version. I would like to make an app for Heroku which requires ruby 2.0.0. I just successfully installed ruby-2.0.0-p353 onto my computer and would like to use that for a single app. How can I do this?
You can specify a Ruby version in your Gemfile by adding: ruby "2.0.0"
For more info: https://devcenter.heroku.com/articles/ruby-versions
If you use rvm or rbenv you can have default version 1.9.3, and for any project set version 2.0.0 in .ruby-version or Gemfile
See https://rvm.io/workflow/projects

rvm ruby version and rails server different ruby version

It seems rails server uses different ruby then the one that is set up by rvm.
How to make the rails server command use the same ruby as its set up in the rvm?
When I start the rails server, (write rails server in console) it outputs
ruby 1.8.7 for ruby version.
But when I write
`ruby -v`
to see the ruby version, I get ruby 1.9.3p0 for ruby version.
Also I have installed rvm and when I type
rvm list
it returns that I'm using ruby-1.9.3-p286, so rvm uses different ruby version than the rails server.
I need to be able to start rails server with ruby-1.9.3.
First I have installed ruby 1.8.7 that I installed rvm so I can use ruby-1.9.3.
But it seems that I still can't use it with rails server.
Thanks
When you say "rails server", how are you running the server? Is it through Bundler? Or through a terminal command?
I believe each rvm Ruby version has its own Bundler (which uses the correct Ruby version specified from rvm). If you were to do rvm install ruby-2.x.x, you'll most likely run into ERROR: Gem bundler is not installed, run 'gem install bundler' first. Once you have run bundle exec rails console and are in the console, you can run RUBY_VERSION to see which version you're running.
If you're simply calling rails server, then your PATH might be messed up. You could run which -a rails to see the list of directories your computer searches through for the executables. If you see something like /usr/bin/rails, then this rails server version probably uses the system version of Ruby. I suspect that might be why the rvm Ruby version and Rails Ruby version are different.
the easiest way it to have .rvmrc file in the app directory where you specify which version of ruby you want to use
echo "rvm use 1.9.3" >> .rvmrc

Resources