简体   繁体   English

rails 命令不起作用。 出现错误“找不到 Gemfile 或 .bundle/ 目录”

[英]rails command does not work. getting error "Could not locate Gemfile or .bundle/ directory"

Whenever I try any rails command, even rails -v , I keep getting the error - Could not locate Gemfile or .bundle/ directory每当我尝试任何 rails 命令,甚至rails -v ,我都会收到错误 - Could not locate Gemfile or .bundle/ directory

Things I have already tried:我已经尝试过的事情:

gem install rails (successfully installed) gem install rails (安装成功)

gem update rails

gem update bundler

tried uninstalling bundler and reinstalling it.尝试卸载捆绑程序并重新安装它。

Current ruby -v is: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]当前的 ruby​​ -v 是: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]

None of the above worked.以上都没有奏效。 Any ideas?有任何想法吗?

If you have installed rails successfully rails -v should work fine.如果您已成功安装 rails rails -v应该可以正常工作。 For running bundle you have to be in a Gemfile directory.要运行bundle您必须位于Gemfile目录中。 Are you sure you are in the root directory of your app?您确定您在应用程序的根目录中吗? If not cd to your root directory and run the commands如果不是 cd 到您的根目录并运行命令

$ rails new my_app
$ cd my_app
$ bundle


EDIT 编辑
The problem can occur if you have to be logged in as an admin user to run the command but the gemfile was in a directory under a different user. 如果您必须以管理员用户身份登录才能运行命令,但 gemfile 位于不同用户下的目录中,则可能会出现此问题。

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

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