I'm trying to start learning Ruby On Rails in OpenAppAcademy but when I run on terminal of 18.04 Ubuntu rails console
I get
/var/lib/gems/2.5.0/gems/railties-6.1.4.1/lib/rails/app_loader.rb:53: warning: Insecure world writable dir /mnt/c in PATH, mode 040777
Traceback (most recent call last):
5: from bin/rails:3:in `<main>'
4: from bin/rails:3:in `load'
3: from /mnt/c/Users/RedmiBook/Desktop/projects/APPACADEMY/SQL/Active Record/Intro To Rails/bin/spring:10:in `<top (required)>'
2: from /mnt/c/Users/RedmiBook/Desktop/projects/APPACADEMY/SQL/Active Record/Intro To Rails/bin/spring:10:in `new'
1: from /usr/lib/ruby/vendor_ruby/bundler/lockfile_parser.rb:95:in `initialize'
/usr/lib/ruby/vendor_ruby/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)
My bundler is above version 2 so I try sudo gem update --system
Installing RubyGems 3.2.27
Traceback (most recent call last):
3: from setup.rb:22:in <main>'
2: from setup.rb:22:in require'
1: from /var/lib/gems/2.5.0/gems/rubygems-update-3.2.27/lib/rubygems.rb:1328:in <top (required)>'
/var/lib/gems/2.5.0/gems/rubygems-update-3.2.27/lib/rubygems.rb:1341:in rescue in <top (required)>': uninitialized constant Gem::BasicSpecification (NameError)
Loading the rubygems/defaults/operating_system.rb file caused an error. This file is owned by your OS, not by rubygems upstream. Please find out which OS package this file belongs to and follow the guidelines from your OS to report the problem and ask for help.
I don't really know were to go from here and it's a shame that I can't start using rails.
CodePudding user response:
Depending on how you install ruby (rvm
, rbenv
, asdf
, system-level install), you might need to prepend bundle exec
to your ruby commands:
bundle exec rails console
This way bundle will restrict execution to the gems declared in your Gemfile.lock, possibly including the bundle version.
You might have the rails
executable installed globally, and it might use a different version of ruby and rubygems.
Update (about the pains of installing ruby in a user-friendly way):
I definitely recommend you to install some user-level toolchain like rvm
or asdf
and have full control on the ruby version. You should not sudo
anything to run ruby and rails applications.
Go to either rvm or asdf sites and follow the instructions to install them in your operating system, and you will have your ruby under control.