I have Bundler 2, yet Ruby/Rails says is missing? - ruby-on-rails

Booting up localhost, I type in 'rails s' into my terminal. I get this error:
Traceback (most recent call last):
5: from bin/rails:3:in `<main>'
4: from bin/rails:3:in `load'
3: from /Users/macbookpro/flippingUnleashedCRM/bin/spring:10:in `<top (required)>'
2: from /Users/macbookpro/flippingUnleashedCRM/bin/spring:10:in `new'
1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/bundler/lockfile_parser.rb:95:in `initialize'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)
So, I type in bundler --version to see what I am using. The result is:
Bundler version 2.2.11
I take a look in my Gemfile.lock, I scroll down, and I see:
RUBY VERSION
ruby 2.5.1p57
BUNDLED WITH
2.2.11
What the heck is the problem?

It seems like a couple things could be going wrong here:
To potentially resolve your immediate issue, try running bundle exec rails s. This will run rails in the context of your bundle.
Secondly, you should also make sure your Ruby version matches the version specified. Like another comment mentioned, you seem to be running on Ruby 2.6 on a project that is on Ruby 2.5. A Ruby version manager like chruby will help you manage your Ruby versions and gem dependencies on each version better.

Related

Cannot launch cloned ruby on rails app - RubyMine

I have cloned an existing project from github. I installed Ruby and installed Rails on my Terminal.
When I do ruby -v I get ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]
When I do rails -v I get Rails 6.0.3.1
However when I navigate into my project that I want to run on local host and run the same commands:
for ruby -v I get ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18] which is the same.
and for rails -v I get:
Traceback (most recent call last):
4: from bin/rails:3:in `<main>'
3: from bin/rails:3:in `load'
2: from /Users/angelainniss/WebstormProjects/legitkitchen/bin/spring:8:in `<top (required)>'
1: from /Users/angelainniss/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/Users/angelainniss/.rbenv/versions/2.5.3/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- bundler (LoadError)
Has anyone ever had this or do they understand why rails isn't working?
Well, rails command is pretty smart and it knows it will be usually called within the rails project folder. So it have its binstubs - basically those are just a slightly modified commands that lives in your project bin folder, with some additional, project-related power-ups. Regular rails command (and other commands as well) will always check if bin/rails is present in current directory and will use it if it exists. This is why rails -v worked fine outside of your project but didn't inside project folder.
One of the bin/rails superpowers is automatic requiring of all dependencies defined in your project Gemfile. This is normally done through another gem called bundler. Bundler is basically always the first gem you're gona install in your local Ruby environment.
But, you didn't install it yet. Just run gem install bundler to get that running. You will still need to install all the dependencies, you do this via bundle install.
Did you do, gem install bundler before running bundle install after cloning the project?

Ensure in require runtime error when setting up ruby on rails

I've been trying to set up ruby on rails.
I'd create a new project with
# rails new test
and I'd get this error message
Traceback (most recent call last):
6: from /usr/bin/rails:23:in `<main>'
5: from /usr/lib/ruby/2.7.0/rubygems.rb:295:in `activate_bin_path'
4: from /usr/lib/ruby/2.7.0/rubygems.rb:295:in `synchronize'
3: from /usr/lib/ruby/2.7.0/rubygems.rb:297:in `block in activate_bin_path'
2: from /usr/lib/ruby/2.7.0/rubygems.rb:230:in `finish_resolve'
1: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:175:in `require'
/usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:175:in `ensure in require': CRITICAL: RUBYGEMS_ACTIVATION_MONITOR.owned?: before false -> after true (RuntimeError)
I have been at for quite some time and I can't find a solution.
I've also made sure everything is updated with # gem update
And sorry if this is a simple problem, I am rather new to ruby on rails. I gather it might be a problem with the monitor package?
I'm running Linux with kernel 5.6.11-arch1-1 if that helps
Not sure if this is the same problem or not, but I had a similar error (not in Rails) and this page is the first that appears in Google, so I am posting a solution if someone else happens to land here.
For me, what solved it was to run:
$ gem clean
Try reinstalling the Bundler by using
gem install bundler
Then you can run
bundle install

How do I solve this error message regarding rails server?

I'm trying to run a rails s command in the terminal,but I keep receiving a trace back: of multiple errors.
I tried have multiple ways to solve this issue but to no avail not has granted me with a solution.
Traceback (most recent call last):
4: from ./bin/rails:3:in `<main>'
3: from ./bin/rails:3:in `load'
2: from /home/zac/code2/rails-mister-cocktail/bin/spring:8:in `<top (required)>'
1: from /home/zac/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/home/zac/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- bundler (LoadError)
I expected the server to run without any issues.
I was having the same error. If you have versions of ruby, bundler or rails installed on your machine that are different than the ones being used in the rails app you're trying to run, then installing the matching versions can make it work. Check the bundler version that was used on the app so you can run in the terminal:
gem install bundler -v '~> 1.17.3' (replace 1.17.3 with the version being used)
Also check the ruby and rails versions you have match the versions described in the Gemfile. You can check the versions you have installed with ruby -v and rails -v

Running local server for Rails 2.3 app?

I am trying to run a Rails 2.3 app locally.
script/server gives me these errors:
bash: script/server: Permission denied
bash: parse_git_branch: command not found
script/server gives me the error:
/Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': cannot load such file -- initializer (LoadError)
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:55:in `load_initializer'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:38:in `run'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:11:in `boot!'
from /Users/stevenbrooks1111/Desktop/cssmixonline/cssweb/config/boot.rb:110:in `<top (required)>'
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/stevenbrooks1111/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from script/server:2:in `<main>'
bash: parse_git_branch: command not found
Any ideas of how I can get this to run locally?
This question is what I've been doing for the past month. I would have loved to use Rails 4, but I know better than to try it!
Install rvm or rbenv, then get into a server that correctly runs this app, and run
ruby --version
gem list > ~/myGems.txt
Using rvm or rbenv, install the exact same version of Ruby.
(Tip: whenever I say "exact same", you can fudge by bumping the revision. For example, given a gem with version 0.1.4, if it has subsequent versions 0.1.5, 0.1.6, and 0.2.0, you can bump to 0.1.6, if that will save you some grief. The revision numbers, 0.1.*, are supposed to be only bug fixes. But a minor version bump, 0.2.0, has higher odds of breaking things. I kept the same version of Ruby, but I bumped rails to 2.3.14.)
Using rvm or rbenv, install the same version of Ruby as currently runs on this app's main server.
Inside this Ruby environment (with both which ruby and ruby --version reporting the correct answers), install each gem in myGems.txt, like this:
gem install --ignore-dependencies --no-rdoc --no-ri my_gem -v=0.1.4
The --ignore-dependencies is critical, because some gems from the Pleistocene Epoch, 2009, don't specify their dependencies' versions. When some dumb 2009 gem pulls in the 2013 rake, you will be utterly screwed, because reverting that rake is really hard. And don't forget to set the -v to the same value as myGems.txt reports!
After all that, try simple rake commands like rake routes. Post any bugs you get as fresh questions, but remember to point out Rails 2.3 in the subject so nobody mis-answers with the modern fixes.
And if this app has tests or specs, getting them running should be a top priority, so you can resume TDD, leaning on the tests to allow you to make sick changes.

no such file to load -- initializer (LoadError)

I have following installed on ubuntu 12
ruby 1.9.2p320
Rails 3.2.6
Now I have old project which is developed into Rails 2 & Ruby 1.8.7
Problem:
When i run below command under old project root directory
ruby ./script/plugin install git://github.com/rails/rails_upgrade.git
Following error comes
Invalid gemspec in [/usr/local/rvm/gems/ruby-1.9.2-p320/specifications/ZenTest-4.9.1.gemspec]: Illformed requirement ["< 2.1, >= 1.8"]
/usr/local/rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': no such file to load -- initializer (LoadError)
from /usr/local/rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'
from /var/www/project/client/softwallet/config/boot.rb:54:in `load_initializer'
from /var/www/project/client/softwallet/config/boot.rb:38:in `run'
from /var/www/project/client/softwallet/config/boot.rb:11:in `boot!'
from /var/www/project/client/softwallet/config/boot.rb:109:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from ./script/plugin:2:in `<main>'
Upgrading the old rails project to new one and getting the invalid gemspec problem.
Then you have to do the following:
Run gem update --system followed by bundle install.
UPDATE:
You are using the same old config/boot.rb from your older version of rails application.
Do the following:
1) Create a new project directory.
2) Generate a new rails app (Of your new latest rails version)
3) Use boot.rb that is created by it.
This happens when you have incompatible version of the same gem already installed on your environment.
To rectify, either you can uninstall and reinstall the gem or install the gem of the specific version.
Make sure that you do a gem cleanup operation before doing so.
This is how my problem was solved . I was using RVM and if you have edited those .bashrc files then each time while you log in to the shell , do a /bin/bash --login . What this does is , it makes the command line take note of the rvm path you had set and installs them first .
I did this on Ubuntu 12 and it did solve my issue , i don't think doing gem update --system is a good idea as it really kind of messes up the environment forcing one to do an rvm implode and install it all over again .

Resources