Question

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 <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"
Was it helpful?

Solution

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.

OTHER TIPS

So what worked for me, anyone coming across this issue is to run

bundle exec rake app:update:bin

You'll be given a prompt asking if you want to overwrite? The options here are:

  • Y - yes (default one, just press Enter for it)
  • n - no (leave current file without changes)
  • a - all (apply all changes)
  • q - quit
  • d - diff
  • h - help

I chose a and it seemed to work ok.

Run

bundle exec rake rails:update:bin

It will update bin/rails and bin/rake files.

I have this when I try to use a rails 4.0 version. So when I try to put bundle exec first, like:

bundle exec rake db:migrate

or

bundle exec rails s

work's.

I had the same issue and here's what helped me. Open ~/.zshrc and add this

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

The solution for me was:

bundle exec rake rails:update:bin

or just use:

For new rails versions:

 bundle exec rake app:update:bin

For old rails versions:

bundle exec rake rails:update:bin
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top