对于旧的rails应用程序,奇怪的rails错误“权限被拒绝:bin / rails”

时间:2014-04-25 15:56:28

标签: ruby-on-rails ruby ruby-on-rails-3 rvm oh-my-zsh

每当我运行rails(或任何rails命令)时,我都会收到此错误 _rails_command:2: permission denied: bin/rails 仅当我在一个 rails app目录中时。

在这些目录中bundle exec rails c命令有效,但rails甚至rails -v不起作用。

背景 我将编码工作区保留在dropbox文件夹中。 现在我最近安装了Manjaro,因此我从之前的操作系统中下载的所有rails应用程序都称之为 rails app。

简而言之: 除了旧的rails应用程序外,Rails在任何地方都可以正 bundle exec rails c可以正常工作。 我试过的Ruby版本: 2.0.0 (rvm), 2.1.1(rvm), 2.1.1 (system)

宝石环境: RubyGems Environment: - RUBYGEMS VERSION: 2.2.2 - RUBY VERSION: 2.0.0 (2014-02-24 patchlevel 451) [x86_64-linux] - INSTALLATION DIRECTORY: /home/tat/.rvm/gems/ruby-2.0.0-p451@latest - RUBY EXECUTABLE: /home/tat/.rvm/rubies/ruby-2.0.0-p451/bin/ruby - EXECUTABLE DIRECTORY: /home/tat/.rvm/gems/ruby-2.0.0-p451@latest/bin - SPEC CACHE DIRECTORY: /home/tat/.gem/specs - RUBYGEMS PLATFORMS: - ruby - x86_64-linux - GEM PATHS: - /home/tat/.rvm/gems/ruby-2.0.0-p451@latest - /home/tat/.rvm/gems/ruby-2.0.0-p451@global - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - https://rubygems.org/ - SHELL PATH: - /home/tat/.rvm/gems/ruby-2.0.0-p451@latest/bin - /home/tat/.rvm/gems/ruby-2.0.0-p451@global/bin - /home/tat/.rvm/rubies/ruby-2.0.0-p451/bin - /home/tat/bin - /usr/local/bin - /usr/local/sbin - /usr/local/bin - /usr/bin - /usr/bin/core_perl - /home/tat/.rvm/bin

更新: 它在bash中运行良好,问题似乎与oh-my-zsh有关。

这是我的rvm-info(来自zsh):

ruby-2.0.0-p451@latest:

  system:
    uname:       "Linux tat-box 3.10.37-1-MANJARO #1 SMP Mon Apr 14 20:56:29 UTC 2014 x86_64 GNU/Linux"
    system:      "manjaro/0.8.9/x86_64"
    bash:        "/usr/bin/bash => GNU bash, version 4.3.8(1)-release (x86_64-unknown-linux-gnu)"
    zsh:         "/usr/bin/zsh => zsh 5.0.5 (x86_64-unknown-linux-gnu)"

  rvm:
    version:      "rvm 1.25.23 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
    updated:      "21 hours 33 minutes 15 seconds ago"
    path:         "/home/tat/.rvm"

  ruby:
    interpreter:  "ruby"
    version:      "2.0.0p451"
    date:         "2014-02-24"
    platform:     "x86_64-linux"
    patchlevel:   "2014-02-24 revision 45167"
    full_version: "ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-linux]"

  homes:
    gem:          "/home/tat/.rvm/gems/ruby-2.0.0-p451@latest"
    ruby:         "/home/tat/.rvm/rubies/ruby-2.0.0-p451"

  binaries:
    ruby:         "/home/tat/.rvm/rubies/ruby-2.0.0-p451/bin/ruby"
    irb:          "/home/tat/.rvm/rubies/ruby-2.0.0-p451/bin/irb"
    gem:          "/home/tat/.rvm/rubies/ruby-2.0.0-p451/bin/gem"
    rake:         "/home/tat/.rvm/gems/ruby-2.0.0-p451@latest/bin/rake"

  environment:
    PATH:         "/home/tat/.rvm/gems/ruby-2.0.0-p451@latest/bin:/home/tat/.rvm/gems/ruby-2.0.0-p451@global/bin:/home/tat/.rvm/rubies/ruby-2.0.0-p451/bin:/home/tat/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:/home/tat/.gem/ruby/2.1.0/bin:/home/tat/.rvm/bin"
    GEM_HOME:     "/home/tat/.rvm/gems/ruby-2.0.0-p451@latest"
    GEM_PATH:     "/home/tat/.rvm/gems/ruby-2.0.0-p451@latest:/home/tat/.rvm/gems/ruby-2.0.0-p451@global"
    MY_RUBY_HOME: "/home/tat/.rvm/rubies/ruby-2.0.0-p451"
    IRBRC:        "/home/tat/.rvm/rubies/ruby-2.0.0-p451/.irbrc"
    RUBYOPT:      ""
    gemset:       "latest"

6 个答案:

答案 0 :(得分:33)

您提到的目录是可执行模式下的rails。如果没有,你可以申请

chmod u+x bin/rails

并使其可执行。

答案 1 :(得分:7)

运行

bundle exec rake rails:update:bin

它将更新bin / rails和bin / rake文件。

答案 2 :(得分:1)

当我尝试使用rails 4.0版本时,我有这个。 因此,当我尝试将bundle exec放在首位时,例如:

bundle exec rake db:migrate

bundle exec rails s

工作的。

答案 3 :(得分:0)

我有同样的问题,这里有什么帮助我。 打开〜/ .zshrc 并添加此

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

答案 4 :(得分:0)

对我来说,解决方案是:

bundle exec rake rails:update:bin

或仅使用:

对于新的rails版本:

 bundle exec rake app:update:bin

对于旧的rails版本:

bundle exec rake rails:update:bin

答案 5 :(得分:0)

所以对我有用的是,遇到此问题的任何人都可以运行

display: grid;
grid-template-columns: 170px auto;
height: 100%;

系统会提示您是否要覆盖?这里的选项是:

  • Y-是(默认值,只需按Enter即可)
  • n-否(不更改,保留当前文件)
  • a-全部(应用所有更改)
  • q-退出
  • d-差异
  • h-帮助

我选择了一个,它似乎正常运行。