Ruby missing psych for YAML ouput - ruby-on-rails

I created a Rails/React app with Webpacker on my Mac running Ruby 2.5.3 and it runs without issue. However when I clone it to my Ubuntu 18.04 machine, I get the below error :
/usr/lib/ruby/2.5.0/yaml.rb:5: warning: It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
My Ubuntu machine is also running Ruby 2.5.3, so I'm confused why it references 2.5.0 in the error.
I am able to launch the Rails server with rails s, but when I try to launch the full app with foreman start -f Procfile.dev, I get the error. I've tried reinstalling libyaml and all the Ruby versions on my machine with RVM with no impact on the error. I've also changed my local Ruby version to 2.5.0, and I get a different error message about how my machine is running Ruby 2.5.0 but the project is running 2.5.3.
Procfile.dev file:
rails: bundle exec rails s
webpack: ./bin/webpack-dev-serer

It says the project is running 2.5.0 based on a directive like ruby '~> 2.5' in the Gemfile. Try changing that to the actual version you're running, run bundle to setup Gemfile.lock again, and retry the command.

I had Ruby 2.5.1 installed from ‘sudo apt install Ruby’ and 2.5.3 installed from RVM. I wiped all installed Rubies and RVM, reinstalled 2.5.3 via RVM on the root directory and was good to go.

Related

Rails ignores ruby installed by rbenv

I am using ruby 2.7.6 for my project. On my laptop (KDE Neon) it was installed via rbenv and was working correctly.
After KDE was updated today I started getting
Your Ruby version is 3.0.2, but your Gemfile specified 2.7.6
To fix that I tried reinstalling both rbenv and ruby that comes with Ubuntu. Also tried rbenv rehash with no results. So far rbenv installs ruby correctly and correct vesion is displayed when I do ruby -v or bundle install in project folder but trying to run rails s gives me an error
Your Ruby version is 3.0.2, but your Gemfile specified 2.7.6
rbenv is installed into /home/some_user/.rbenv/
$PATH shows
bash: /home/some_user/.rbenv/shims:/home/some_user/.rbenv/shims:/home/some_user/.rbenv/bin:/home/some_user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin which I am not sure is correct.
You're not running the correct rails executable. Try prefixing your rails command with bundle exec, for example if you want to run the dev server, type bundle exec rails s instead of rails s.

rbenv reports different version of ruby than bundler

I'm trying to setup a rails app on a new machine and I'm having some trouble. I'm using a .ruby-version file to specify the ruby version we're using for the project which contains the following:
2.0.0-p643
Here's what happens when I try to look at what ruby versions I'm using
➜ app git:(master) ✗ rbenv versions
system
* 2.0.0-p643 (set by /Users/stephen/workspace/prm/.ruby-version)
➜ app git:(master) ✗ ruby -v
ruby 2.0.0p643 (2015-02-25 revision 49749) [x86_64-darwin14.5.0]
So far so good. And yet when I try to install my dependencies with bundler, I get this:
➜ app git:(master) ✗ bundle
Your Ruby version is 2.2.3, but your Gemfile specified 2.0.0
Why does rbenv report to me that I'm using the version I've intended by my ruby-version file yet when I try to run bundle it complains that I'm using the wrong version? I could see if it said that the patch level is causing problems because my gemfile just specifies 2.0.0 but why is it telling me that I'm using 2.2.3 when rbenv is telling me otherwise.
I tried uninstalling bundler, thinking that perhaps the bundler was the system bundler for some reason and that's what was causing the problem. Same problem.
For reference this is using the latest version of rbenv that was installed using homebrew on OSX Yosemite.

Openshift ssh incorrect ruby version on bundle install?

I have a Ruby 2.0 rails 4 app on openshift.
When I ssh into my application and run bundle install I get a message saying: 'Your Ruby version is 1.8.7, but your Gemfile specified 2.0.0'.
When running ruby -v, I get : "ruby 2.0.0p353..."
Running gem environment it also says Ruby 2.0.
Also on my local machine everything is working fine.
Why does my bundle install think I'm using ruby 1.8.7 on the openshift server?
I think your bundler was installed before Ruby upgrade to 2. Try to install your bundler again using gem install bundler and then run bundle install
Let me know if it works

Rails 3.2 not using bundled gems, Capistrano needs sudo gem install and rbenv not finding rails

I have 2 Rails 3.2.11 apps running on an Ubuntu 12.04 server with Nginx, Unicorn and Postgresql. Deployment is by git and capistrano.
After I installed the second app I found that Capistrano would fail during cap deploy because it "could not find a gem source" and I needed to install each missing gem using sudo. After this, cap deploy worked fine and so did the apps. Running bundle install from the current dir in either app reported using all the correct gems.
I am perplexed that Capistrano needs to find the gems before updating my app as my past experience (I think) was that I could run bundle install from the current dir to install any new or updated gems after cap deploy.
Today, I decided to update my Ruby version using rbenv on my dev laptop. I needed to run git pull from .rbenv/plugins/ruby-build and then rbenv rehash then I could install the new Ruby version. All good, ruby-v reports the new version 19.3-p374.
Now, when I run rails server (rails s) from my app dev dir I get rbenv: rails: command not found. The rails' command exists in these Ruby versions: 1.9.3-p327. rbenv version reports
1.9.3-p374. Rbenv which rails and bundle install both report "command not found: with rbenv error "Therails' command exists in these Ruby versions: 1.9.3-p327".
So, two issues which I believe are related:-
How to make each app on my server independently run its own gems using bundle install? I don't want to freeze the gems and am quite happy to keep both apps up to date simultaneously. Should I just keep installing the required gems using sudo?
How to fix the rbenv issue of not finding rails in the new version?
I needed to reinstall all gems again. Gem install bundler and then bundle update from each application directory.

Ubuntu not detecting Rails installation

I recently reinstalled Ubuntu 12.04 after the upgrade package broke my last install. I've been following this walkthrough to restore Rails and continue working on my existing projects. I've already installed rvm, all the packages listed by rvm requirements, and all my development tools (e.g., vim, git, etc.).
However, I get stuck on the rails command, whether I'm trying rails (n,s,g), and returns the error message
$ rails
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
I've already done the following:
$ gem install rails
Successfully installed rails-3.2.3
1 gem installed
But based on the following checks, it still hasn't installed.
$ which gem
/home/eyoung/.rvm/bin/gem
$ which ruby
/home/eyoung/.rvm/bin/ruby
$ which rails
(no output)
I'm at my wit's end; any ideas on what's going on?
Extra details:
OS: Ubuntu 12.04 x86_64
Packages: RVM installed Ruby 1.9.3p194 w/ openssl & Rubygems
ruby and gem are on the system $PATH
EDIT: By request,
$ gem list rails
*** LOCAL GEMS ***
rails (3.2.3)
As rails gem was installed and all the other paths look correct, you need to set rvm to use that ruby as your default version. It will set all the paths correctly so you can use your gems and rails command.
rvm use 1.9.3 --default
I updated to 12.04 as well, and ran into the issue as well. After quite a bit of head scratching, I decided to reinstall rvm.
Referencing a previous question.

Resources