简体   繁体   中英

fatal: Not a git repository (or any of the parent directories): .git on every rails command but git commands works fine

I've got a problem with git and my rails project.

I have set up a github repository and successfully pushed four commits. Every git command i'm trying is working as expected ( git status, git add, git commit, git push etc.). But each time I try to execute a rails command (eg bundle show, bundle install, rails s, rails generate, rake test etc.) I get following message in my console:

fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git

Every time the message appears on three lines. Sometimes on six lines. The .git folder is in my project and I'm in the correct folder. all rails commands are working as expected. But this annoying message comes with each rails command. I cloned the repository into another folder and created another repository and pushed the code to that new repositiory. The error is in my new folder, too.

I reinitialized my existing Git repository with git init but that changed nothing.

When I set up a fresh rails project and push it into a new repository etc. there are no errors. What could be wrong with my project? Any idea, why this is happening and how to fix this?

I'm working with ruby 1.9.3 , rails 3.2.1 and git 1.7.9 .

thx to @manojlds I could isolate the problem a little bit more. It's the therubyracer gem. I don't know what exactly is the problem but because I'm on windows I use this special therubyracer gem: https://github.com/hiranpeiris/therubyracer_for_windows . So I will ask the developer of this special gem and will show him the bundler bug. Maybe he will know if it's a problem with his gem or with the bundler. The bundler has an updated pre release. But I can't install the prerelease on windows. So I have to wait and therefore I must live for now with this annoying messages. Or is there a way to disable these messages?

Here is my github issue: https://github.com/hiranpeiris/therubyracer_for_windows/issues/1

Try running git init in

RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/therubyracer-0.11.0beta1-x86-mingw32 .

It will initialize a new empty git repo there.

There is a bug for Bundler, which could be related: https://github.com/carlhuda/bundler/issues/2039

Definitely not a problem with git or your git repo. Try updating bundler. ( not sure if the fix is in stable version yet )

Make sure you are in the right directory when you run that command:

git tag

I had the same problem while installing node.js from git and found that I had to be in a subdirectory after downloading it for the tag versions to display.

For example, I ran this command to get node.js:

git clone https://github.com/joyent/node.git

... but then had to cd node to be in the node subdirectory before the git tag command worked.

The rubytheracer gem has lots of issues.

Switch to node or execjs to avoid them.

More at: Rails - Could not find a JavaScript runtime?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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