0

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?

Clara
  • 2,677
  • 4
  • 16
  • 31
Angela Inniss
  • 359
  • 1
  • 2
  • 18

2 Answers2

1

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.

BroiSatse
  • 44,031
  • 8
  • 61
  • 86
  • I tried this @BroiSatse but i get another error when I do `gem install bundler`. error message is this: `ERROR: While executing gem ... (Errno::EACCES) Permission denied @ rb_sysopen - /Users/angelainniss/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/CHANGELOG.md ` Any ideas why – Angela Inniss May 25 '20 at 10:39
  • @AngelaInniss - This is now another question: https://stackoverflow.com/questions/17550903/why-do-i-get-a-permission-denied-error-while-installing-a-gem – BroiSatse May 25 '20 at 11:12
0

Did you do, gem install bundler before running bundle install after cloning the project?

Sushant
  • 377
  • 4
  • 8