attempting to execute any command starting “rails” yields “Could not locate Gemfile”

旧街凉风 提交于 2019-12-10 20:10:48

问题


I am trying to install a new rails app. I've already got several rails apps on my machine, all working fine.

$ rails new app
Could not locate Gemfile

Then I figured I'd run a trace to figure out what was going on, as you wouldn't expect to have a Gemfile at this point anyway, as typically the above command would create an entire new rails app in a directory named app with the Gemfile contained within that directory.

$ rails new app --trace
Could not locate Gemfile

So I tried to reinstall everything on my computer via this detailed guide:

http://railsapps.github.com/installing-rails.html#gems

After the first 20 or so steps, I got to this command:

$ rake -v
Could not locate Gemfile

I assume something is off on my setup somewhere, but I can't see anything off.

Here are my rvm settings:

$ rvm version

rvm 1.18.10 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

$ rvm list

rvm rubies

   jruby-1.6.7 [ x86_64 ]
   ruby-1.9.1-p431 [ i386 ]
   ruby-1.9.3-p194 [ x86_64 ]
   ruby-1.9.3-p286 [ x86_64 ]
   ruby-1.9.3-p327 [ x86_64 ]
=* ruby-1.9.3-p385 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

$ rvm gemset list

gemsets for ruby-1.9.3-p385 (found in /Users/paul/.rvm/gems/ruby-1.9.3-p385)
   (default)
   global
=> rails32

Here are the gems installed on my rails32 gemset

$ gem list

*** LOCAL GEMS ***

actionmailer (3.2.12, 3.2.11)
actionpack (3.2.12, 3.2.11)
activemodel (3.2.12, 3.2.11)
activerecord (3.2.12, 3.2.11)
activeresource (3.2.12, 3.2.11)
activesupport (3.2.12, 3.2.11)
arel (3.0.2)
builder (3.0.4)
bundler (1.2.4)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
json (1.7.7)
mail (2.4.4)
mime-types (1.21)
multi_json (1.6.1)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.12, 3.2.11)
railties (3.2.12, 3.2.11)
rake (10.0.3)
rdoc (3.12.1)
rubygems-bundler (1.1.0)
rvm (1.11.3.6)
sprockets (2.2.2)
thor (0.17.0)
tilt (1.3.3)
treetop (1.4.12)
tzinfo (0.3.35)

Bundler Version

$ bundle --version
Bundler version 1.2.4

.gemrc file

$ cat ~/.gemrc
---
:backtrace: false
:benchmark: false
:bulk_threshold: 1000
:sources:
- http://rubygems.org/
- https://rubygems.org
:update_sources: true
:verbose: true

Everything seems to look fine, very frustrated, please help.


回答1:


This errors happens only with commands prefixed with bundle exec or for bundle install without Gemfile in current dir.

My assumption is you might be running commands that enable bundler, check:

which rake

to find out what command is run.




回答2:


bundle install

in the project directory fixed it for me. After that, I ran into this error:

There was an error in your Gemfile, and Bundler cannot continue.

And this was fixed with:

gem update bundler

Then my re-install of Ruby and Rails finally worked. It only took about four hours to make it work :-/



来源:https://stackoverflow.com/questions/15047899/attempting-to-execute-any-command-starting-rails-yields-could-not-locate-gemf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!