Weird rails error "permission denied: bin/rails" for old rails apps

ArrC picture ArrC · Apr 25, 2014 · Viewed 11.8k times · Source

I'm getting this error whenever I run rails (or any rails command) _rails_command:2: permission denied: bin/rails ONLY when i'm inside some old rails app directory.

In these directories bundle exec rails c command works but rails or even rails -v don't work.

Background: I keep my coding workspace in dropbox folder. Now I recently installed Manjaro and hence all the rails apps which I downloaded back from my previous OS I call them old rails app.

In Short: Rails works fine everywhere except for old rails apps. bundle exec rails c works fine though. Ruby versions which I've tried: 2.0.0 (rvm), 2.1.1(rvm), 2.1.1 (system)

Gem Environment : 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

UPDATE: Its working fine in bash, the problem seem to be with oh-my-zsh.

Here is my rvm-info (from 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 <[email protected]>, Michal Papis <[email protected]> [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"

Answer

user944938 picture user944938 · Apr 25, 2014

In the directory you mentioned is your rails in executable mode. If not you can apply

chmod u+x bin/rails

and make it executable.