Search code examples
ruby-on-railsrubyruby-on-rails-4devisepermission-denied

'devise' gem - permission denied @rb_sysopen


I have installed 'devise' gem.

When I tried to run

rails g devise User

I get the following error.

/home/cbls-2/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:101:in `initialize': Permission denied @ rb_sysopen - /home/cbls-2/academics/assistant/config/routes.rb (Errno::EACCES)
from /home/cbls-2/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:101:in `open'
from /home/cbls-2/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:101:in `replace!'
from /home/cbls-2/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:59:in `invoke!'
from /home/cbls-2/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
from /home/cbls-2/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:30:in `insert_into_file'
from /home/cbls-2/.rvm/gems/ruby-2.3.0/gems/railties-4.2.6/lib/rails/generators/actions.rb:224:in `block in route'
from /home/cbls-2/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:194:in `block in in_root'
from /home/cbls-2/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:184:in `block in inside'
from /home/cbls-2/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/fileutils.rb:128:in `chdir'
from /home/cbls-2/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/fileutils.rb:128:in `cd'
from /home/cbls-2/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:184:in `inside'
from /home/cbls-2/.rvm/gems/ruby-2.3.0/gems/thor-0.19.1/lib/thor/actions.rb:194:in `in_root'
from /home/cbls-2/.rvm/gems/ruby-2.3.0/gems/railties-4.2.6/lib/rails/generators/actions.rb:223:in `route'
from /home/cbls-2/.rvm/gems/ruby-2.3.0/gems/devise-4.1.0/lib/generators/devise/devise_generator.rb:22:in `add_devise_routes'

I have Rails 4.2.6, Ruby 2.3.0

This is my gemfile

 gem 'rails', '4.2.6'
 gem 'mysql2'
 gem 'devise'
 gem 'sass-rails', '~> 5.0'
 gem 'uglifier', '>= 1.3.0'
 gem 'coffee-rails', '~> 4.1.0'
 gem 'therubyracer', platforms: :ruby

gem 'jquery-rails'

gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

 gem 'bcrypt', '~> 3.1.7'
 gem 'unicorn'
 gem 'capistrano-rails', group: :development

group :development, :test do
      debugger console
   gem 'byebug'
end

group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
end

Could not run 'rails g activeadmin:resource User' also. It throws the same error.


Solution

  • Hi Please change the permissions for the file /home/cbls-2/academics/assistant/config/routes.rb It will work.