Starting Rails with Foreman and ruby 2.0.0 - bundler

I'm just upgrading a Rails app to Ruby 2.0.0, deploy to Heroku works fine. ruby "2.0.0" is specified in the Gemfile, but when I try to start Rails locally using
bundle exec foreman start
I get...
Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0
I've installed the latest Bundler, done a bundle instal and I've gor rvm running ruby 2.0.0.
ruby -v in the console returns ruby 2.0.0p0
I'm just not sure where this is falling down.
Running foreman start works as expected. It just wont start with bundle exec
Can anyone point me in the right direction? What am I missing?

I ended up including the foreman gem in the app's Gemfile. This works, but since the Gem is deprecated, it's really just a workaround.

Related

Server not running with pg and postgresql on Ruby on Rails

I need some help with this setup on ruby on rails:
ruby version 2.7.1
ruby on rails version 6.0.3.3
In my application gemfile I have:
gem 'postgres'
gem 'pg', '~> 0.19.0'
But, when I run 'bundle install' and I will try to run the server, the following message appears:
This is an old, deprecated version of the Ruby PostgreSQL driver that hasn't
been maintained or supported since early 2008.
try to install using command gem 'pg' without specifying the version.

(Rails app deployment) capistrano bundles with invalid ruby version

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.

Cannot start up rails server or rails console

I have a rails project. I run command rails server and rails console, but both give me this error:
So, I ran the command sudo gem install polyglot. It successfully installed polyglot-0.3.5, but the same error still persists. I am wondering what the problem is. Is there anything wrong in my Gemfile?
My Rails version is "Rails 5.0.0.1" and my Ruby version is "ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]".
You should add in Gemfile this line gem 'polyglot' , then run bundle install. It will be better to add gem locally in Gemfile instead globally through gem install.

'bundle exec' complains about gem not being installed, even after 'bundle install'

I have a website using Jekyll with Github Pages. After previously messing about with versions and RVM on another computer, on this one I opted to stick with just one version of Ruby and per-project environments using bundler.
I have a pretty simple Gemfile:
[$]> cat Gemfile
source 'https://rubygems.org'
gem 'github-pages'
and bundler config:
[$]> cat .bundle/config
---
BUNDLE_PATH: env
BUNDLE_DISABLE_SHARED_GEMS: '1'
When I run any command (jekyll, gem, irb) through bundle exec, I get a dependency error:
[$]> bundle exec jekyll
Could not find RedCloth-4.2.9 in any of the sources
Run `bundle install` to install missing gems.
However, the bundle is already installed:
[$]> bundle install
Using RedCloth 4.2.9
Using i18n 0.6.11
Using json 1.8.1
[snip]
Using github-pages 29
Using bundler 1.7.7
Your bundle is complete!
It was installed into ./env
I'm at a bit of a loss as to how bundler can think the gems are installed when using one subcommand, but think they're missing when using another.
[$]> which ruby
/usr/local/bin/ruby
[$]> which bundler
/usr/local/bin/bundler
[$]> ruby --version
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
[$]> bundler --version
Bundler version 1.7.7
After deleting the env directory and reinstalling, I noticed it created subdirectories for two Ruby versions - 2.1.0 and 2.2.0. The latter was my current version of Ruby, but the directory was empty (all the gems were installed into the env/ruby/2.1.0/gems directory). This, combined with Oliver's answer about rbenv, got me thinking about mismatched versions.
I reinstalled bundler with a simple gem install bundler, reran bundle install, and all is good.
It seems in general the answer is to sort out issues with bundler installing for a different version of Ruby than you're actually using. It seems strange to me it would use one thing for bundle install and another for bundle exec, but *shrug* whatever.
I had exactly the same problem after installing rbenv as my Ruby manager. In the end I solved the problem with:
rbenv rehash
(additionally you may need to restart terminal, as per #joel-glovier's comment)
That fact it's complaining about Redcloth 4.2.9 is actually a red herring. Bundler probably can't find any of the gems but Redcloth is the first one it looks for and so it exits imediately with that error.
Basically I'd installed rbenv and ruby 2.2.2 and changed to that version with rbenv global 2.2.2 but I'd forgotten to run rbenv rehash. So I'm guessing when running bundle install it was looking at my previously used version of ruby (system ruby) to see what gems were installed but when running bundle exec jekyll serve it was looking at my new ruby version and not finding any of the gems.
I had to open ./.bundle/config and set
BUNDLE_DISABLE_SHARED_GEMS to true for bundle the gems to be properly locally stored.
I had defined BUNDLE_GEMFILE = /home/app/current/Gemfile in .bashrc file. That broke the bundle exec while deploying a new version to the server. Check with env that you don't have the BUNDLE_GEMFILE defined in your environment variables.
I added the BUNDLE_GEMFILE into the .bashrc file to ease with monit commands. Now I just define the variable in the beginning of the monit command.

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