undefined method `require_relative' for main:Object (NoMethodError)

后端 未结 5 366
别那么骄傲
别那么骄傲 2021-01-12 08:09

When trying to update OpenSSL - I broke (seemingly) everything surrounding Ruby and Rails on my laptop. Even after uninstalling ruby and rails through gem uninstall

相关标签:
5条回答
  • 2021-01-12 08:32

    I was able to resolve this problem by simply running gem install rails.

    This problem occurred when I cloned a pre-existing Rails 4 app. I am using ruby-2.0.0-p317, and an RVM gemset specific to this app. I ran the initial bundle install, but then could not run rails console without getting the error.

    After running gem install rails, which used the cached copy in my app's gemset, the problem was resolved. Don't ask my why!

    0 讨论(0)
  • 2021-01-12 08:35

    This came up for me after installing rails with Rails Composer. Seems like a problem with RVM selecting the ruby version, the trick was to simply navigate out and back into the folder.

    $ cd ..
    $ cd myapp

    0 讨论(0)
  • 2021-01-12 08:39

    I fixed the problem by completely removing Rails, Ruby, and RVM altogether - then starting from scratch.

    I don't remember all of the commands exactly, but it was something like:

    sudo gem uninstall rails
    sudo rvm remove 2.0
    rvm implode
    sudo chown -R drewwyatt: ~/.rvm/
    rm -rf ~/.rvm
    \curl -L https://get.rvm.io | bash -s stable --rails
    rvm use 2.0
    gem install rails
    
    0 讨论(0)
  • 2021-01-12 08:41

    Try running bundle exec rails server instead of just rails server.

    I was seeing this error because I had a conflicting version of the rails gem installed globally.

    Prefixing commands with bundle exec ensures that you're using gems specified by your project's Gemfile.lock.

    0 讨论(0)
  • 2021-01-12 08:43

    Similar to @ncherro, I got this using ruby filename.rb. Running

    bundle exec ruby filename.rb   
    

    works.

    0 讨论(0)
提交回复
热议问题