简体   繁体   English

无法在 Rails 应用程序上启动克隆的 ruby - RubyMine

[英]Cannot launch cloned ruby on rails app - RubyMine

I have cloned an existing project from github.我从 github 克隆了一个现有项目。 I installed Ruby and installed Rails on my Terminal.我安装了 Ruby 并在我的终端上安装了 Rails。

When I do ruby -v I get ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]当我做ruby -v我得到ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]

When I do rails -v I get Rails 6.0.3.1当我做rails -v我得到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.对于ruby -v我得到ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]这是相同的。

and for rails -v I get:对于rails -v我得到:

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?有没有人有过这种情况,或者他们知道为什么rails不起作用?

Well, rails command is pretty smart and it knows it will be usually called within the rails project folder.好吧, rails命令非常聪明,它知道通常会在 rails 项目文件夹中调用它。 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.所以它有它的 binstubs - 基本上这些只是在你的项目bin文件夹中稍作修改的命令,还有一些额外的、与项目相关的电源。 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.常规rails命令(以及其他命令)将始终检查bin/rails是否存在于当前目录中,如果存在则使用它。 This is why rails -v worked fine outside of your project but didn't inside project folder.这就是为什么rails -v在您的项目之外工作正常但在项目文件夹中没有工作的原因。

One of the bin/rails superpowers is automatic requiring of all dependencies defined in your project Gemfile. bin/rails的超能力之一是自动要求项目 Gemfile 中定义的所有依赖项。 This is normally done through another gem called bundler .这通常是通过另一个名为bundler的 gem 来完成的。 Bundler is basically always the first gem you're gona install in your local Ruby environment. Bundler 基本上始终是您要在本地 Ruby 环境中安装的第一个 gem。

But, you didn't install it yet.但是,您还没有安装它。 Just run gem install bundler to get that running.只需运行gem install bundler即可运行。 You will still need to install all the dependencies, you do this via bundle install .您仍然需要安装所有依赖项,您可以通过bundle install来完成。

Did you do, gem install bundler before running bundle install after cloning the project?在克隆项目后运行bundle install之前,你做了gem install bundler吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM